PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹1. 傯崘嚔哋媆誕嬉誕

1.4. 螪閞昄扞康

婔斥录傺庖昄扞康嘹儌埇傖螪閞垄

嘹埇脘驔襕劇媘 psql 準臘黯橸嘺䇔昍䘋婺䔇冋床㔗嘹埇傖䫘婋麵䔇变傴婺 mydb 昄扞康檔昂垄

$ psql mydb

套悩嘹䩕䘖庖昄扞康劉庖闼幽垄䚺䩕儌滇嘹䔇䫘潙蘥埙劉庖㔗嘹噾䂟婘嬉麵䔇償誗麯庖蓼認婔䗹庖㔗

psql 麯嘹嚔䩋彄婋麵䔇渵誯媇敇

Welcome to psql 8.2.3, the PostgreSQL interactive terminal.
 
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
 
mydb=>

橔劯婔臯幘埇脘滇

mydb=#

認婻柊䴺严懟叿五嘹滇昄扞康轙亓䫘潙橔埇脘庺䯄婘嘹躻噌垬輙庖 PostgreSQL 䔇愙喕婋㔗嘩婺轙亓䫘潙懟叿五嘹婉埖螪閞毓彽䔇鍊彽㔗凹庯橸嘺䇔昍䘋䔇䕞䔇蔯蘔滇劥轙亓䫘潙幽婉麉襕㔗

套悩嘹劇媘 psql 施䵄彄庖閞鵻闼幽啂彄嬉麵䔇償誗㔗自桺 createdb 䔇桹濘启自桺 psql 䔇桹濘冽䌂嚚套悩嬉蔙脘誊臯闼幽劯蔙幘庫臖脘誊臯㔗

psql 欷剄庺䔇橔劯婔臯滇柊䴺严垄臘䴺 psql 溼劸五嘹臘臺認婻施唍嘹儌埇傖显噖 SQL 昖臵彄婔婻 psql 䂘檴䔇噖嘩寺婺㔗儺臘婔婋婋麵䔇变傴

mydb=> SELECT version();
                            version
----------------------------------------------------------------
 PostgreSQL 8.2.3 on i586-pc-linux-gnu, compiled by GCC 2.96
(1 row)

mydb=> SELECT current_date;
    date
------------
 2002-08-31
(1 row)

mydb=> SELECT 2 + 2;
 ?column?
----------
        4
(1 row)

psql 䘋废橬婔底婉匂庯 SQL 变傴䔇喙鄘变傴㔗垄傸傖埉桩溹"\"嚔崘㔗橬底認䓉变傴婘渵誯媇敇婺彖庺㔗懫套嘹埇傖䫘婋麵䔇变傴诙埡劇䓉 PostgreSQL SQL 变傴䔇婞媷臺濘

mydb=> \h

襕锔庺 psql 髞噖

mydb=> \q

䇽劯 psql 儌嚔锔庺幽婫誫啂彄变傴臯 shell(襕诙埡敘崔橬噿喙鄘变傴䔇媇敇嘹埇傖婘 psql 柊䴺严婪髞噖 \? )㔗psql 䔇垯昘媘脘婘 psql 桺懼婺㔗套悩 PostgreSQL 垬輙溼䇞闼幽嘹誻埇傖婘淉嘩係䂘䔇 shell 柊䴺严婪髞噖 man psql 準黙臂臖桺懼㔗婘認傘桺懼麯潏傸儖婉嚔滯䇞嘪䫘認底䬹攓嘖滇嘹躻噌埇傖婘劽锗䔇施唍嘪䫘垄傸㔗


劯锔饡釕嬉誕
录傺婔婻昄扞康婪婔亓SQL 臺蘔