Linux下操作PostgreSQL数据库

postgreSQL数据库图形管理工具:pgadmin3-1.10.2.zip

[root@test Server]# service postgresql restart
Stopping postgresql service: [  OK  ]
Starting postgresql service: [  OK  ]

[root@test Server]# su - postgres
-bash-3.2$ psql -U postgres
postgres-# \q

[root@test Server]# service postgresql stop
Stopping postgresql service: [  OK  ]
[root@test Server]# su - postgres
-bash-3.2$ pg_ctl start
postmaster starting

选择登录的数据库:
-bash-3.2$ psql -d template1
Welcome to psql 8.1.11, the PostgreSQL interactive terminal.

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

template1=# \q

重置“postgres”用户的密码
postgres=# alter user postgres with password '123456';

创建数据库:
-bash-3.2$ createdb test
CREATE DATABASE
-bash-3.2$ psql -d test
Welcome to psql 8.1.11, the PostgreSQL interactive terminal.

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

test=# \q

删除数据库
dropdb mydb

创建新表;
test=# create table weather(
test(# city varchar(80),
test(# temp_lo int,
test(# temp_hi int,
test(# prcp real,
test(# date date
test(# );
CREATE TABLE
test=#

向表中添加行;
test=# insert into weather values('beijing',-10,15,0.5,'2010-12-24');
INSERT 0 1

查询一个表;
test=# select * from weather;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12137615/viewspace-682944/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/12137615/viewspace-682944/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值