windows安装解压版postgresql9.6

1、下载并解压postgresql到系统一个目录。


2、初始化数据库。

初始化之前,需要设置一个存储数据库的文件夹data目录。这里设置在postgresql安装目录下。

进入安装目录,运行如下命令。

bin\initdb.exe -D E:\wangyu\soft\pgsql\data -E UTF8


3、启动数据库。

根据初始化数据库的结果,我们可以知道通过如下命令启动postgresql数据库:

bin\pg_ctl.exe -D E:\wagnyu\soft\pgsql\data -l logfile start

启动成功,我们可以通过查看进程来验证postgresql是否运行,postgresql开启5432监听端口,可以查看是否有5432端口被进程占用。


4、查看数据库。


5、简单的使用数据库。

通过命令行进入postgresql  : bin\psql.exe 

查看数据库                          : \l

创建数据库                          : create database testdb

连接数据库                          : \c testdb

postgres=# \c testdb
WARNING: Console code page (437) differs from Windows code page (936)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
You are now connected to database "testdb" as user "Administrator".

查看数据库中的表                : \dt

testdb-# \dt
 public | employees | table | postgres

新建表                                : create table employees(id int primary key not null,name text,age int,sallary real);

查看表结构                         : \d employees

testdb=# \d employees
 id      | integer | not null
 name    | text    |
 age     | integer |
 sallary | real    |

查询表数据                         : select * from employees

testdb=# select * from employees;
  1 | baba    |  30 |    1000
  2 | mama    |  29 |     100
  3 | baby    |   2 |      10
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luffy5459

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值