PostgreSQL之初使用

admindeMacBook-Pro:~ admin$ psql ehr //链接数据库
psql (10.5)
Type “help” for help.

ehr=# help
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit //退出
ehr=#

将数据库备份数据导入数据库:

pg_restore -d dbname -Fc -O dbfile

删除数据库:

ERROR: database "ehr" is being accessed by other users  详细:There are 2 other sessions using the database.

select pg_terminate_backend(pid) from (select pid from pg_stat_activity where datname = ‘数据库名’ ) a;//断开所有连接
drop database 数据库名;

启动 PostgreSQL:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

关闭 PostgreSQL:

pg_ctl -D /usr/local/var/postgres stop -s -m fast

参考资料:
https://www.cnblogs.com/shineqiujuan/p/4703304.html

猜你喜欢

转载自blog.csdn.net/qq_33733970/article/details/81664485