PostgreSQL - 사용자, 그룹, 데이터베이스, 테이블 관리
출처 : http://www.davidpashley.com/articles/postgresql-user-administration.html
http://www.faqs.org/docs/ppbook/x17149.htm
0. DB 콘솔 로그인
C:\pgsql\bin>psql -U postgres template1
psql (8.4.0)
Type "help" for help.
1. 사용자 관리
1-1. 사용자 추가
template1=# CREATE USER scott WITH PASSWORD 'tiger';
CREATE ROLE
1-2. 사용자 조회
template1=# select * from pg_shadow;
usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig
----------+----------+-------------+----------+-----------+--------+----------+-----------
postgres | 10 | t | t | t | | |
scott | 16384 | f | f | f | f91290 | |
(2 rows)
template1=# select * from pg_user;
usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil| useconfig
----------+----------+-------------+----------+-----------+----------+----------+-----------
postgres | 10 | t | t | t | ******** | |
scott | 16384 | f | f | f | ******** | |
(2 rows)
2. 그룹관리
3. 데이터베이스 관리
3-1. 데이터베이스 생성
template1=# create database db_study;
CREATE DATABASE
4. 테이블 관리
4-1. 테이블 생성
C:\pgsql\bin>psql -U scott db_study
psql (8.4.0)
Type "help" for help.
db_study=> create table eng_word (
db_study(> inx integer,
db_study(> end_word varchar(100),
db_study(> primary key ( inx )
db_study(> );
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "eng_word_pkey" for table "eng_word"
CREATE TABLE