Postgresql 学习笔记

1 创建role [postgres中role==user]

(1) 在sql

CREATE USER test

CREATE role test2

SELECT * FROM pg_roles


drop role test

drop test test


(2) 在命令行 (需在postgres用户下)

createuer test;

dropuser test;


2 创建好的role可以用于连接数据库 (例如使用psql连接)

psql -h localhost -p 5432 -U raissa -d mydb


3 psql

\?打开帮助文档

(options: S = show system objects,+ = additional detail) \d[S+] list tables,views,and sequences \d[S+] NAME describe table,view,sequence,or index \da[S] [PATTERN] list aggregates \db[+] [PATTERN] list tablespaces \dc[S] [PATTERN] list conversions \dC [PATTERN] list casts \dd[S] [PATTERN] show comments on objects \ddp [PATTERN] list default privileges \dD[S] [PATTERN] list domains \det[+] [PATTERN] list foreign tables \des[+] [PATTERN] list foreign servers \deu[+] [PATTERN] list user mappings \dew[+] [PATTERN] list foreign-data wrappers \df[antw][S+] [PATRN] list [only agg/normal/trigger/window] functions \dF[+] [PATTERN] list text search configurations \dFd[+] [PATTERN] list text search dictionaries \dFp[+] [PATTERN] list text search parsers \dFt[+] [PATTERN] list text search templates \dg[+] [PATTERN] list roles \di[S+] [PATTERN] list indexes \dl list large objects,same as \lo_list \dL[S+] [PATTERN] list procedural languages \dn[S+] [PATTERN] list schemas \do[S] [PATTERN] list operators \dO[S+] [PATTERN] list collations \dp [PATTERN] list table,and sequence access privileges \drds [PATRN1 [PATRN2]] list per-database role settings \ds[S+] [PATTERN] list sequences \dt[S+] [PATTERN] list tables \dT[S+] [PATTERN] list data types \du[+] [PATTERN] list roles \dv[S+] [PATTERN] list views \dE[S+] [PATTERN] list foreign tables \dx[+] [PATTERN] list extensions \l[+] list all databases \sf[+] FUNCNAME show a function's definition \z [PATTERN] same as \dp

相关文章

来源:http://www.postgres.cn/docs/11/ 4.1.1. 标识符和关键词 SQL标识符和关键词必须以一个...
来源:http://www.postgres.cn/docs/11/ 8.1. 数字类型 数字类型由2、4或8字节的整数以及4或8...
来源:http://www.postgres.cn/docs/11/ 5.1. 表基础 SQL并不保证表中行的顺序。当一个表被读...
来源:http://www.postgres.cn/docs/11/ 6.4. 从修改的行中返回数据 有时在修改行的操作过程中...
来源:http://www.postgres.cn/docs/11/ 13.2.1. 读已提交隔离级别 读已提交是PostgreSQL中的...
来源:http://www.postgres.cn/docs/11/ 9.7. 模式匹配 PostgreSQL提供了三种独立的实现模式匹...