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                 列出全部用戶
相關文章
相關標籤/搜索