|
|
||
=> \pset null <NULL> Null display is "<NULL>".
=> SELECT * FROM accounts WHERE
まで入力したところで「あれ?カラム名何だっけ」となった場合、そのまま \d accounts してしまいましょう。さらにそのまま続けてSQLを入力できます。
=> SELECT * FROM accounts WHERE\d accounts
Table "public.accounts"
Column | Type | Modifiers
----------+---------------+-----------
aid | integer | not null
bid | integer |
abalance | integer |
filler | character(84) |
Indexes:
"accounts_pkey" PRIMARY KEY, btree (aid)
-> aid = 1;
aid | bid | abalance | filler
-----+-----+----------+--------------------------------------------------------------------------------------
1 | 1 | 0 |
(1 row)
psql -f [ファイル名]
エラーが発生した場合に中断したい場合:
psql --set ON_ERROR_STOP=On -f [ファイル名]
1つのトランザクション内で実行したい(8.2以降):
psql -1 --set ON_ERROR_STOP=On -f [ファイル名]
\t
contrib_regression=# select attname, attnum from pg_attribute where attrelid = 'pg_database'::regclass; tableoid | -7 cmax | -6 xmax | -5 cmin | -4 xmin | -3 oid | -2 ctid | -1 datname | 1 datdba | 2 encoding | 3 datcollate | 4 datctype | 5 datistemplate | 6 datallowconn | 7 datconnlimit | 8 datlastsysoid | 9 datfrozenxid | 10 dattablespace | 11 datconfig | 12 datacl | 13
* はてなダイアリーキーワード:psql