シェルスクリプトとかでPostgresに繋ぐ場合、普通に書いてしまうと、psqlコマンドでパスワードオプションが無い為、passwordを聞かれて止まってしまう。バックアップ取りたい時とか直面する。
> pg_dump -U kapi -h 192.168.1.2(別サーバとか) kapi_db > kapi_db.dmp
これを回避するには、実行ユーザーのhomeに.pgpassを作ってやればいい。
# cd # cat
.pgpass192.168.1.2:5432:kapi_db:kap...
続きを読む
postgresqlでカラムの型をtextからintegerに変える時 ALTER TABLE
table_name ALTER COLUMN column_name type integer; とやったところ ERROR:
続きを読む
PostgresからMysqlへの移行記事は良く目にするが、MysqlからPostgresへの移行はあまりなかったのでまとめ。MySQLからエクスポートecho
"SELECT * FROM [TABLE_Name] INTO OUTFILE '/opt/tmp/[DB_Name]/[TABLE_Name].csv'...
続きを読む
webサーバとDBサーバを分けたい場合。[PG_DATA]/postgresql.conf#listen_addresses
= 'localhost'↓listen_addresses = '*'#port 5432↓port 5432[PG_DA...
続きを読む
truncateで空にはできるがシーケンスも戻さないとダメ。latest=#
TRUNCATE table名 ;TRUNCATE TABLElatest=# ALTER SEQUENCE シーケンス名 restart
with 1;ALTER SEQUENCEselect setval('シーケンス名',1);でもシ...
続きを読む
馬鹿でかいダンプデータのリストア実験やってる時にERROR:
続きを読む
MysqlからPostgresに引越ししたいんだよね・・。autoincrementとか色々問題でそう。http://d.hatena.ne.jp/kno2502/20071112/1194859121↑この人のように一回CVSに落としてプログラム側で吸収っていうのが一番近道か・・。参考URLPostgreSQL
覚...
続きを読む
コマンドの使い方 起動 $ pg_ctl start 停止 $ pg_ctl stop ユーザー登録 $
createuser testuser Shall the new user be allowed to create databases? (y/n) y Shall the new
user be allowed to create more new users? (y/n) n ユーザー削除 $ dropuser testuser
データベースの作成 $ createdb -U tes...
続きを読む
まずここ読む ↓ http://www005.upp.so-net.ne.jp/nakagami/Memo/psycopg.html
http://www005.upp.so-net.ne.jp/nakagami/Another/Cygwin.html#PostgreSQL
http://www.postgresql.jp/document/current/html/install-procedure.html
■用意するもの Postgresql取ってくる http://www.postgre...
続きを読む