使用 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 \dList tables in database\d employeesDescribe a table\lList all databases\dnList all schemas-
\dfList all functions \d+List all tables in database along with some additional information\d+ usersDescribe 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 dbnameConnect to another database \qQuit from postgres shell\eText editor inside psql
Comments