postgres的使用命令

一、更新源sql

yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm -y  

二、查看pg源数据库

yum list | grep postgresql

三、安装pgcentos

yum install postgresql10-contrib postgresql10-server -y

四、初始化数据库post

Postgresql安装目录是/usr/pgsql-10,而Postgresql的数据目录是/var/lib/pgsql/版本号/data目录

/usr/pgsql-10/bin/postgresql-10-setup initdb

五、启动pgspa

service postgresql start

六、进入pgpostgresql

su - postgres
psql

七、经常使用命令code

\password           设置密码
\q                  退出
\h                  查看SQL命令的解释,好比\h select
\?                  查看psql命令列表
\l                  列出全部数据库
\c [database_name]  链接其余数据库
\d                  列出当前数据库的全部表格
\d [table_name]     列出某一张表格的结构
\x                  对数据作展开操做
\du                 列出全部用户
相关文章
相关标签/搜索