使用 Docker 镜像创建 PostgreSQL 数据库服务
λ docker run --name my-postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres-pw-w4ker972mj6kGhQhLbkJzL2V -d postgres
然后再创建一个客户端,输入上面命令中设置的密码后便可使用数据库服务了
λ docker run -it --rm --link my-postgres:postgres postgres psql -h postgres -U postgres
Password for user postgres:
常用命令
-
\?
help \d
List tables in database\d employees
Describe a table\l
List all databases\dn
List all schemas-
\df
List all functions \d+
List all tables in database along with some additional information\d+ users
Describe a table with additional information\l+
List all databases with additional information\dn+
List all schemas with additional information-
\df+
List all functions with additional information -
\c dbname
Connect to another database \q
Quit from postgres shell\e
Text editor inside psql
Comments