postgresql 常用操作
2023-05-09 18:56:58
建库
- create user uuuu with password 'pppp';
- create database dddd owner uuuu;
- grant all privileges on database dddd to uuuu;
常用命令
- \l 列出所有库
- \d 列出所有表 -\d table_name 列出表结构
- \dn 列出所的schema
- set search_path to ssss; 设置默认schema
- \connect dddd 切换数据库
- select user 察看当前用户
- drop schema ssss cascade; 删除schema
- alter sequence xxx restart with xxx 重置sequence.
- trunc table table_name restart identity cascade 清数据并重置sequence.