postgresql??????????????????????????????SQL??????

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了postgresql??????????????????????????????SQL??????相关的知识,希望对你有一定的参考价值。

?????????tables   select   man   gre   mysql   ??????   ??????   lin   mac   


???1?????????

[email protected]:~$ sudo -u postgres psql

?????????postgres???????????????postgres?????????????????????????????????????????????????????????????????????????????????????????????psql?????????

???2??????????????????


??????????????????psql?????????????????????????????????????????????psql?????????
c dbname username serverIP port
????????????????????????????????????????????????????????????????????????????????????????????????-???????????????
???????????????????????????????????????????????????
???3???????????????
psql?????????????????????????????????????????????????????????help????????????????????????????????????
vsb9=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  copyright for distribution terms
       h for help with SQL commands?????????SQL????????????)
       ? for help with psql commands?????????psql???????????????
       g or terminate with semicolon to execute query???g?????????????????????????????????????????????????????????????????????
      
       ?????????????????????select id from courses??????#??????"-"???????????????????????????????????????????????????????????????????????????g??????????????????????????????select id from courses;????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????id???????????????
       q to quit??????????????????

?????????????????????SQL??????????????????psql?????????????????????????????????????????????????psql???????????????????????????psql???????????????????????????????????????????????????SQL???????????????????????????

(4)????????????????????????mysql???MySQL????????????????????????psql???postgresql??????????????????
1????????????????????????
mysql: show databases
psql: l???list

2???????????????
mysql: use dbname
psql: c dbname

3????????????????????????????????????
mysql: show tables
psql: d

4??????????????????????????????
mysql: show columns from table name
psql: d tablename

5????????????????????????
mysql: describe tablename
psql: d+ tablename

SQL????????????
????????????????????????????????????
select attr from tablename;???????????????????????????????????????????????????????????????????????????????????????????????????????????????
select attr
from tablename;??????????????????????????????????????????????????????????????????????????????????????????
































以上是关于postgresql??????????????????????????????SQL??????的主要内容,如果未能解决你的问题,请参考以下文章