ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux下操作PostgreSQL数据库

Linux下操作PostgreSQL数据库

原创 Linux操作系统 作者:wwd_wang 时间:2010-12-31 08:49:10 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/12137615/viewspace-682944/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-05-08

  • 博文量
    236
  • 访问量
    233977