PostgreSQL的一些基本操作

$ psql database_name -U myuser -h myhost # connect databse

\connect database_name # switch database

\du # list database roles, A role can be thought of as either a database user, or a group of database users, depending on how the role is set up.

\l # list all databases

\d # list all visible tables, views, sequences and foreign tables

\dt # list all tables in the current database

\dp # Lists tables, views and sequences with their associated access privileges

\d+ table_name # describe table structure

\q # exit psql

\x # Sets or toggles expanded table formatting mode. Like MySQL "\G". 

psql -c '\x' -c 'SELECT * FROM foo;'

psql <<EOF
\x
SELECT * FROM foo;
EOF

\password postgres # change password for postgres

参考:


PostgreSQL

这篇文章: 有用 无用
创建 2017-03-16 02:42:47 / 更新 2017-04-26 22:01:01