postgre常用命令

介绍

常用命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 登录
psql -U postgres
# 查询库
postgres=# \l
# 切换库
postgres=# \c test
# 查询所有表
postgres=# \dt
# 创建库
postgres=# create database test
# 删除库
postgres=# drop database test
# 删除表
postgres=# drop table tablename

备份恢复

1
2
3
4
# 备份
pg_dump -h localhost -U postgres databasename > databasename.bak
# 恢复
psql -h localhost -U postgres -d databasename < databasename.bak

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!