强制kill数据库活动连接
1
dbname=# select pg_terminate_backend(pid) from pg_stat_activity where datname = 'dbname' and pid <>pg_backend_pid();
删除数据库
1
dbname=# drop database dbname;
新建数据库
1
dbname=# create database dbname;
授权给用户
1
dbname=# grant all privileges on database dbname to dbuser;
shell命令行删除数据库
$ dropdb -h localhost -p 5432 -U postgres dbname
shell命令行导入数据库
$ psql -h host -U postgres -d dbname < database_export.sql