各種オプションを付けてSQLを実行したい場合は、exec_sqlコマンドを使用します。書式は次です。
exec_sql [option] ["SQL"]
- SQL文の指定方法
SQL文は" "の中に記述します。SQL文の最後に';'はあっても無くてもかまいません。SQL文は、単語の切れ目で自由に改行することができます。
例) exec_sql "select aa,bb,cc from test_table
where a>'123' and dd<'999'"
- exec_sqlコマンドのオプション
-i set CGI mode and set DATA received from WWW server
-h item help item: select,insert,.. or next command:
(HElp,ALl,OPtion,ERrno,EXample) <2 char are judged>
-v display VERSION of pgbash(exec_sql)
-s display SQLCA(SQLCODE,etc..) (after SQL execution)
-d conn set current CONNect_name defined in CONNECT_SQL
-e turn on printing of QUERY sent to the backend
-q turn off printing of SYSTEM/SQL error messages
-P turn on PLAIN output(-P is default in normal mode)
-H turn on HTML output(-H is default in CGI mode)
-X set EXPANDED type (ex. -PX or -HX)
-C cap set CAPTION of HTML/PLAIN table (ex. -C 'TITLE')
-O opt set OPTION of HTML table (ex. -O 'BORDER=0')
-L turn on OUTER_FRAME of PLAIN table
-T turn off HEADINGS of PLAIN/HTML table
-B turn off ROW_COUNT of PLAIN/HTML table
-A turn off ALIGNMENT of PLAIN table (ex. -PXA)
-S sep set SEPARATOR of PLAIN table field(default is '|')
-N null set NULL value string (ex. -N 'NULL')
-Z zero set ZERO value string (ex. -Z '-0-' )
-m list all connected databases
-l obj list databases objects: <2 char are judged>
(DAtabases, TAbles, INdices, SEquences, GRant)
(FUnctions, OPerators, TYpes, SYstem_tables )
-p tbl list tables objects (tbl: table_name or '*')
-r des list description: <2 char are judged>
(TAble, FIeld, TYpe, FUnction, OPerator or '*')