Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【备忘清单】 请求添加备忘清单: PostgreSQL #26

Open
amaoo opened this issue Nov 8, 2022 · 1 comment
Open

【备忘清单】 请求添加备忘清单: PostgreSQL #26

amaoo opened this issue Nov 8, 2022 · 1 comment

Comments

@amaoo
Copy link

amaoo commented Nov 8, 2022

您可以在这里简单的提供一些资料,方便我们在 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

⚠️ 注意: 随着内容越来越多,可能甚至找不到这个工具或者语言的官网,请您在这里提供以便大家共同参与贡献内容

@jaywcjlove
Copy link
Owner

@amaoo 已经添加欢迎补充

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants