답변:
또한 중 하나에 대해 별도의 열을 사용할 수 latitude및 longitude또는 자신의 유형을 작성 . 어느 쪽이든 허용 된 값 을 제한 하는 것이 좋을 수 있습니다 .이 예 에서는 유형이 둘 이상의 테이블에서 사용되는 경우 제한 조건이 반복되지 않도록 도메인 을 사용합니다.
create domain latitude_t as double precision not null
check(value>=-90 and value<=90);
create domain longitude_t as double precision not null
check(value>-180 and value<=180);
create type geocoord_t as (latitude latitude_t, longitude longitude_t);
create table my_table(id serial, geocoord geocoord_t);
insert into my_table(geocoord) values ((31.778175,35.22995));
select id, (geocoord).* from my_table;
id | latitude | longitude
----+-----------+-----------
1 | 31.778175 | 35.22995