Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【20161110】【SQL】PostgreSql常用命令总结 #49

Closed
zhongxia245 opened this issue Nov 10, 2016 · 0 comments
Closed

【20161110】【SQL】PostgreSql常用命令总结 #49

zhongxia245 opened this issue Nov 10, 2016 · 0 comments

Comments

@zhongxia245
Copy link
Owner

zhongxia245 commented Nov 10, 2016

时间:2016-11-10 14:22:03
地址:#49

背景

由于接收同事的项目,项目中使用 PostgreSql, 记录下 常用的一些命令

使用

  1. 连接数据库
psql -h 127.0.0.1 -p 54323 -U userName -d DbName

在 psql 中,切换数据库

\c dbname username serverIP port
  1. 列出所有数据库
mysql: show databases
psql: \l或\list
  1. 切换数据库
mysql: use dbname
psql: \c dbname
  1. 列出当前数据库下的数据表
mysql: show tables
psql: \d
  1. 列出指定表的所有字段
mysql: show columns from table name
psql: \d tablename
  1. 查看指定表的基本情况
mysql: describe tablename
psql: \d+ tablename
  1. 退出登录
mysql: quit 或者\q
psql:\q
@zhongxia245 zhongxia245 changed the title 【SQL】PostgreSql常用命令 【SQL】PostgreSql常用命令总结 Nov 10, 2016
@zhongxia245 zhongxia245 changed the title 【SQL】PostgreSql常用命令总结 【20161110】【SQL】PostgreSql常用命令总结 Nov 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant