PostgreSQLのDB操作
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[PostgreSQL]]
*データベース一覧確認 [#x706cff6]
psql -l
または
psql
postgres=# ¥l
*データベース作成 [#jacb05ca]
# su - posgres
$ createdb -U postgres -O testuser01 testdb
$ psql -l
名前 | 所有者 | エンコーディング | 照合順...
------------+--------------+------------------+---------...
testdb | testuser01 | UTF8 | ja_JP.UTF-8 | j...
postgres | postgres | UTF8 | ja_JP.UTF...
template0 | postgres | UTF8 | ja_JP.UTF...
| | ...
template1 | postgres | UTF8 | ja_JP.UTF...
| | ...
*データベースの所有者変更 [#a8f79abc]
postgres=# alter database hogedb01 owner to hogeuser01;
ALTER DATABASE
*データベースの権限確認 [#k19b1734]
psql
postgres=#
postgres=# ¥c 対象のデータベース名(例:testdb)
testdb=# ¥z
Schema | Name ...
--------+-----------------------------------------------...
public | dtb_alliances ...
Access pribileges の部分が空だとselectすらも出来ない。
*アクセス権付与 [#a716e76b]
psql
postgres=#
postgres=# ¥c 対象のデータベース名(例:testdb)
testdb=# grant all on テーブル名 to ユーザー名
testdb=# ¥z
※テーブルごと
※全テーブルへのアクセス権付与についてはPostgreSQL8.5以降...
*全テーブルへアクセス権を付与するシェル [#f3e5ec29]
#!/bin/bash
for table in `echo '\dtvs' | psql -t -A -F ',' データベ...
do
#echo $table
echo "GRANT ALL ON TABLE $table to ユーザー名;"
echo "GRANT ALL ON TABLE $table to ユーザー名;" | psql ...
done
参考:http://yanor.net/wiki/?PostgreSQL%2F%E3%83%A6%E3%83...
終了行:
[[PostgreSQL]]
*データベース一覧確認 [#x706cff6]
psql -l
または
psql
postgres=# ¥l
*データベース作成 [#jacb05ca]
# su - posgres
$ createdb -U postgres -O testuser01 testdb
$ psql -l
名前 | 所有者 | エンコーディング | 照合順...
------------+--------------+------------------+---------...
testdb | testuser01 | UTF8 | ja_JP.UTF-8 | j...
postgres | postgres | UTF8 | ja_JP.UTF...
template0 | postgres | UTF8 | ja_JP.UTF...
| | ...
template1 | postgres | UTF8 | ja_JP.UTF...
| | ...
*データベースの所有者変更 [#a8f79abc]
postgres=# alter database hogedb01 owner to hogeuser01;
ALTER DATABASE
*データベースの権限確認 [#k19b1734]
psql
postgres=#
postgres=# ¥c 対象のデータベース名(例:testdb)
testdb=# ¥z
Schema | Name ...
--------+-----------------------------------------------...
public | dtb_alliances ...
Access pribileges の部分が空だとselectすらも出来ない。
*アクセス権付与 [#a716e76b]
psql
postgres=#
postgres=# ¥c 対象のデータベース名(例:testdb)
testdb=# grant all on テーブル名 to ユーザー名
testdb=# ¥z
※テーブルごと
※全テーブルへのアクセス権付与についてはPostgreSQL8.5以降...
*全テーブルへアクセス権を付与するシェル [#f3e5ec29]
#!/bin/bash
for table in `echo '\dtvs' | psql -t -A -F ',' データベ...
do
#echo $table
echo "GRANT ALL ON TABLE $table to ユーザー名;"
echo "GRANT ALL ON TABLE $table to ユーザー名;" | psql ...
done
参考:http://yanor.net/wiki/?PostgreSQL%2F%E3%83%A6%E3%83...
ページ名: