Postgresql入門

1)安裝參照(http://www.if-not-true-then-false.com/2012/install-postgresql-on-fedora-centos-red-hat-rhel/) sql

經常使用查詢數據庫

select current_database()
select current_schema
select current_user
select current_date
select version()

經常使用命令centos

\dn   數據庫列表post

\du   當前數據庫的用戶列表spa

chkconfig --level 235 postgresql-9.4 on2) 啓動數據庫服務 
postgresql

service postgresql-9.4 startcode

service postgresql-9.4 stopget

3) 建立用戶及遠程鏈接
it

sudo -u postgres psqlio

create user twdpm with password 'twdpm'

create database test;

grant all privileges on database test to twdpm;

4)配置

配置/var/lib/pgsql/9.4/data/postgresql.conf

配置/var/lib/pgsql/9.4/data/pg_hba.conf

主要是配置用戶的訪問權限和訪問的主機控制。

5)鏈接到數據庫

psql -h 192.168.0.103 -d test -U twdpm

退出數據庫鏈接 \q


6)建立數據庫的兩種方式

create database atm with encoding='UTF8' OWER=user1 CONNECTION LIMIT=25;

createdb -h 192.168.0.103 -U postgres testdb2;

7)刪除數據庫

drop database test;

查詢當前建立的數據庫

select datname from pg_database where datistemplate = false;

建立數據庫的schema的兩種放式

create schema employee;

create schema employee authorization user1;

相關文章
相關標籤/搜索