最近由于工作需要,用到PostgreSQL,安装的是64 位的PostgreSQL 9.6版本,现将基本的命令行指令总结一下,以备忘。
特别说明:Command line execute files are in the folder <PostgreSQL install dir>\bin
(1)菜单是最简单的方法:
(2)指令创建:createdb -U postgres test
2、Restore db:pg_restore -d test -U postgres c:\\test.backup
or
psql -h localhost -U postgres -d dbname < C:\mydb.bak
3、delete db:dropdb -U postgres test
Sometimes the database couldn't be dropped because other sessions are using it. In this scenario, run the command in SQL Shell(psql) to close all the sessions:
SELECT
pg_terminate_backend(pg_stat_activity.pid)
FROM
pg_stat_activity
WHERE
datname=
'sm95'
AND
pid<>pg_backend_pid();
4、backup db:pg_dump -h ip -U postgres dbname > C:\mydb.bak
以上四部分是最常用的数据库操作指令,数据库建好之后,接下来就是在Server中配置数据库,由于时间关系,该部分现在不作说明,后面如果时间允许,再更新博文将此部分加进去。
PostgreSQL安装包下载:https://pan.baidu.com/s/1bFXlAQ