Tiven Wang
Wang Tiven May 03, 2018
425 favorite favorites
bookmark bookmark
share share

使用 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



Back to Top