当前位置:Gxlcms > 数据库问题 > 【Gerrit】【Postgresql】psql数据库基本操作

【Gerrit】【Postgresql】psql数据库基本操作

时间:2021-07-01 10:21:17 帮助过:42人阅读

1.命令行登录数据库:

psql -p 5432 -Upostgres -W

2.列出所有数据库

\l

技术图片

3.切换数据库

\c dbname

4.列出当前数据库的所有表

\d

技术图片
5.查看指定表的所有字段

\d  tablename

技术图片
6.退出数据库

\q

7.数据库备份

pg_dump -h localhost -U postgres -p 5432 reviewdb|gzip > "`date +%Y%m%d%H%M%S`".db.gz
或
pg_dump --host hostname --port port --username username -t tablename -d dbname >/home/jihite/table.sql 

8.数据库恢复

psql -h 10.125.7.68 -p 5432 -d postgres -U postgres -W postgres -f 2.sql

9.命令导入sql数据文件

psql -h localhost  -d databaseName  -U username -f  filename

参开链接:https://www.cnblogs.com/kaituorensheng/p/4667160.html

【Gerrit】【Postgresql】psql数据库基本操作

标签:image   http   图片   strong   loading   链接   rri   令行   指定   

人气教程排行