centos 7_CentOS 7 常用 PostgreSQL 命令

时间:2020-11-27  来源:PostgreSQL  阅读:

登录用户

CentOS 7 上安装完 PostgreSQL 后,会默认创建一个 postgres 的用户。要使用 PostgreSQL,我们需要先切换到该用户:

  $ sudo -i -u postgres

接着输入:

  $ psql

就可以进入 PostgreSQL 命令行。此时的命令行提示不再显示 $,而是 postgres=#。

这里,你可以执行各种 SQL 语句。

退出 PostgreSQL 命令行

  postgres=# \q

查看所有数据库

  postgres=# \l

连接数据库

  postgres=# \c test

查看表

在连接上数据库后,可以查看数据库下的所有数据表:

  postgres=# \d

\d 会罗列出所有的数据表,包括 PostgreSQL 自动创建的自增长字段的表。如果只想查看用户创建的,

  postgres=# \dt

如果想查看单个数据表的结构,则在命令后指定表名:

  postgres=# \d test

centos 7_CentOS 7 常用 PostgreSQL 命令

http://m.bbyears.com/shujuku/113054.html

推荐访问:centos7关闭防火墙 centos下载 centos7安装
相关阅读 猜你喜欢
本类排行 本类最新