#title PostgreSQL 테이블만들기
[[TableOfContents]]

테이블 만들기는 다른 DBMS와 유사하다. 역시 모델링이 문제다. 어떤 데이타 타입을 쓰는지도 중요하다. 
{{{
CREATE TABLE weather (
	city varchar(80),
	temp_lo int, -- low temperature
	temp_hi int, -- high temperature
	prcp real, -- precipitation
	date date
);

CREATE TABLE cities (
	name varchar(80),
	location point
);
}}}

테이블을 삭제할 때는 drop table 문을 쓰면 된다. 
{{{
drop table table_name
}}}

{{{
INSERT INTO weather VALUES (’San Francisco’, 46, 50, 0.25, ’1994-11-27’);
INSERT INTO cities VALUES (’San Francisco’, ’(-194.0, 53.0)’);
}}}

필자는 이전에 보지 못했던 point 데이터 타입을 지금 처음 테이블에 삽입해 보았다..작은 따옴표와 작은 따옴표 사이에 괄호로 묶어 콤마로 구분하여 X, Y를 구분한 것으로 보인다. 쿼리를 날려보면 알 것이라 예상된다. 
{{{
select * from cities;

     name      | location
---------------+-----------
 San Francisco | (-194,53)
(1 row)
}}}

흠...뭔가... 잘 모르것다...웬지 Point.x 와 같이 하면 되지 않을까??
{{{
select name, location.x from cities;
}}}

{{{
Pervasive Demo DB=> select name, location.x from cities;
ERROR:  relation "location" does not exist
}}}

ㅡㅡ;;
안 된다..메뉴얼을 보다보면 나오겠지...

{{{
CREATE TABLE cities (
	city varchar(80) primary key,
	location point
);

CREATE TABLE weather (
	city varchar(80) references cities(city),
	temp_lo int,
	temp_hi int,
	prcp real,
	date date
);
}}}

references cities(city) 부분을 보면 알 수 있을 것이다. cities 테이블의 city 컬럼을 참조한다는 
뜻이다.