jaywcjlove / jaywcjlove/reference
【备忘清单】 请求添加备忘清单: PostgreSQL
- Dominant language
- Dockerfile
- Stars
- 15.3k
- Forks
- 2.2k
- Avg merge
- 2h 17m
- Merged PRs (30d)
- 4
Description
您可以在这里简单的提供一些资料,方便我们在 Quick Reference 中添加您想添加的备忘清单(速查表)。
【请您在这里介绍一下工具或者语言,这很重要】
- The world's most advanced open source database
#### 提供参考资料地址
提供更多参考资料有助于我们整理成备忘清单(速查表)
-
> psql -h {host} -U postgres
\l 列出所有数据库
\du 列出所有用户
\c - {user_name} 切换用户
drop database {name}; 删除数据库
\c {database_name} 切换数据库
drop user {username}; 删除用户
SELECT datname FROM pg_database;
psql -h {host_name} -U postgres -d {db_name} -c "SELECT COUNT(1) FROM {table_name}"
添加user
psql -U postgres -h xxxx -c "CREATE USER xxxx WITH PASSWORD 'xxxx';"
添加db
psql -U postgres -h xxxx -c "CREATE DATABASE xxxx ENCODING 'UTF-8' LC_COLLATE 'ja_JP.UTF-8' LC_CTYPE 'ja_JP.UTF-8' TEMPLATE 'template0';"
db权限变更
psql -U postgres -h xxxx -c "ALTER DATABASE xxxx OWNER TO xxxx;"
pg 备份
pg_dump -h xxxx -U postgres -Ft -b $params_dbname > $pgdump_file
pg 恢复
pg_restore -h xxxx -U postgres -d $params_dbname -Ft $pgdump_path
- [官方文档](https://www.postgresql.org/docs/)
- [PostgreSQL](https://www.postgresql.org/): The world's most advanced open source database
_⚠️ 注意: 随着内容越来越多,可能甚至找不到这个工具或者语言的官网,请您在这里提供以便大家共同参与贡献内容_
Contributor guide
Assessment
This issue has not been assessed yet.