-- ------------------------------------------------------------------------------------------------
-- [ 시스템관리 ] 우편번호 테이블 생성
conn system/built123$@ndb;
-- ------------------------------------------------------------------------------------------------
-- 테이블 생성
drop table bsys.sys_postal_code cascade constraints;
create table bsys.sys_postal_code
(
postal_id number
,postal_cd varchar2(5)
,sido varchar2(60)
,sido_en varchar2(120)
,sigungu varchar2(60)
,sigungu_en varchar2(120)
,eupmyeon varchar2(60)
,eupmyeon_en varchar2(120)
,road_cd varchar2(100)
,road_name varchar2(240)
,road_name_en varchar2(240)
,under_yn varchar2(50)
,building_num_main varchar2(200)
,building_num_sub varchar2(200)
,building_mgmt_num varchar2(200)
,large_name varchar2(200)
,building_sigungu_name varchar2(600)
,legal_code varchar2(60)
,legal_name varchar2(200)
,ri varchar2(200)
,admin_name varchar2(120)
,mountain_yn varchar2(50)
,num_main varchar2(50)
,eupmyeondong_seq varchar2(20)
,num_sub varchar2(50)
,old_postal_cd varchar2(40)
,postal_seq varchar2(20)
,create_date timestamp default systimestamp
,create_by varchar2(50) default '-1'
,update_date timestamp default systimestamp
,update_by varchar2(50) default '-1'
) tablespace bdb_data;
-- 테이블 설명
comment on table bsys.sys_postal_code is '[시스템관리] 우편번호';
comment on column bsys.sys_postal_code.postal_id is '우편번호ID';
comment on column bsys.sys_postal_code.postal_cd is '우편번호';
comment on column bsys.sys_postal_code.sido is '시도';
comment on column bsys.sys_postal_code.sido_en is '시도영문';
comment on column bsys.sys_postal_code.sigungu is '시군구';
comment on column bsys.sys_postal_code.sigungu_en is '시군구영문';
comment on column bsys.sys_postal_code.eupmyeon is '읍면';
comment on column bsys.sys_postal_code.eupmyeon_en is '읍면영문';
comment on column bsys.sys_postal_code.road_cd is '도로명코드';
comment on column bsys.sys_postal_code.road_name is '도로명';
comment on column bsys.sys_postal_code.road_name_en is '도로명영문';
comment on column bsys.sys_postal_code.under_yn is '지하여부';
comment on column bsys.sys_postal_code.building_num_main is '건물번호본번';
comment on column bsys.sys_postal_code.building_num_sub is '건물번호부번';
comment on column bsys.sys_postal_code.building_mgmt_num is '건물관리번호';
comment on column bsys.sys_postal_code.large_name is '다량배달처명';
comment on column bsys.sys_postal_code.building_sigungu_name is '시군구용건물명';
comment on column bsys.sys_postal_code.legal_code is '법정동코드';
comment on column bsys.sys_postal_code.legal_name is '법정동명';
comment on column bsys.sys_postal_code.ri is '리명';
comment on column bsys.sys_postal_code.admin_name is '행정동명';
comment on column bsys.sys_postal_code.mountain_yn is '산여부';
comment on column bsys.sys_postal_code.num_main is '지번본번';
comment on column bsys.sys_postal_code.eupmyeondong_seq is '읍면동일련번호';
comment on column bsys.sys_postal_code.num_sub is '지번부번';
comment on column bsys.sys_postal_code.old_postal_cd is '구우편번호';
comment on column bsys.sys_postal_code.postal_seq is '우편번호일련번호';
comment on column bsys.sys_postal_code.create_date is '생성일시';
comment on column bsys.sys_postal_code.create_by is '생성자';
comment on column bsys.sys_postal_code.update_date is '수정일시';
comment on column bsys.sys_postal_code.update_by is '수정자';
-- primary 인덱스
alter table bsys.sys_postal_code add constraint sys_postal_code_pk primary key (postal_id) using index tablespace bdb_idx;
-- unique 인덱스
--create unique index sys_postal_code_uk on bsys.sys_postal_code (corp_id, profile_cd) tablespace bdb_idx;
-- normal 인덱스
create index bsys.sys_postal_code_ix01 on bsys.sys_postal_code (postal_cd) tablespace bdb_idx;
create index bsys.sys_postal_code_ix02 on bsys.sys_postal_code (road_name) tablespace bdb_idx;
-- 권한부여
grant select, insert, update, delete on bsys.sys_postal_code to bcom with grant option;
grant select, insert, update, delete on bsys.sys_postal_code to bhrm with grant option;
-- 트리거 생성
create or replace trigger bsys.sys_postal_code_trg
before insert or update on bsys.sys_postal_code
for each row
begin
if :new.postal_id is null then
:new.postal_id := sys_postal_code_s.nextval;
end if;
if inserting then
:new.create_date := systimestamp;
:new.create_by := nvl(wwv_flow.g_user, user);
end if;
:new.update_date := systimestamp;
:new.update_by := nvl(wwv_flow.g_user, user);
end;
/
-- 시노님 생성
conn bcom/1234@ndb;
create or replace synonym sys_postal_code for bsys.sys_postal_code;
conn bhrm/1234@ndb;
create or replace synonym sys_postal_code for bsys.sys_postal_code;
'오라클 > 테이블(시스템관리)' 카테고리의 다른 글
[ 프로파일 ] 테이블 생성을 아래와 같이 진행합니다. (1) | 2024.04.12 |
---|---|
[ 국가 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 데이터이관 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 오브젝트 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 로그 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |