postgresql数据管理系统使用命令方式有两种:
1. 内部命令,以反斜线开始 \ ,如: \l 显示所有数据库
2. 标准SQL命令,以分号 ; 或 \g 结束,可以使用多行
数据库的关键操作:
1. 启动服务 2. 登录 3. 建立数据库 4. 建立表 5. 插入记录到表中
6. 更新/删除/查询/修改操作 7. 退出 8. 停止服务
在windows7中安装的postgresql默认使用GBK字符集,经常不能使用显示中文的数据表,解决办法:
注意:在windows 7下的postgresql中写操作时要使用GBK,读操作时要用UTF8;
设置字符集为 utf-8 就可以了.
postgres=# \encoding utf-8 // 设置客户端的字元集
postgres=# \encoding // 显示客户端的字元集
postgres=# show client_encoding; // 显示客户端的字元集
postgres=# show server_encoding; // 显示服务器的字元集
启动服务:
net start postgresql-9.5
停止服务:
net stop postgresql-9.5
获取命令帮助:
c:\> psql --help
登录( 注意: postgres 是默认用户即管理员 ):
路径 psql -h 服务器 -U 用户名 -d 数据库 -p 端口地址 // -U 是大写
C:\> psql -h localhost -U postgres -p 5432 // 默认打开postgres数据库
C:\> psql -h 127.0.0.1 -U postgres -d fengdos -p 5432 // 打开fengdos数据库