-- ------------------------------------------------------------------------------------------------
-- [ 공통관리] 코드 테이블 생성
conn system/built123$@ndb;
-- ------------------------------------------------------------------------------------------------
-- 테이블 생성
drop table bcom.com_code cascade constraints;
create table bcom.com_code
(
corp_id number
,code_id number
,code_type_id number
,code varchar2(50) not null
,code_name varchar2(200) not null
,code_short_name varchar2(100) not null
,start_date date default trunc(sysdate) not null
,end_date date
,sort_order number default 1
,attr_chr_1 varchar2(200)
,attr_chr_2 varchar2(200)
,attr_chr_3 varchar2(200)
,attr_chr_4 varchar2(200)
,attr_chr_5 varchar2(200)
,attr_num_1 number
,attr_num_2 number
,attr_num_3 number
,attr_num_4 number
,attr_num_5 number
,attr_date_1 date
,attr_date_2 date
,attr_date_3 date
,attr_date_4 date
,attr_date_5 date
,remark varchar2(4000)
,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 bcom.com_code is '[공통관리] 코드';
comment on column bcom.com_code.corp_id is '법인ID';
comment on column bcom.com_code.code_id is '코드ID';
comment on column bcom.com_code.code_type_id is '코드유형ID';
comment on column bcohttp://m.com_code.code is '코드';
comment on column bcom.com_code.code_name is '코드명';
comment on column bcom.com_code.code_short_name is '코드명(약칭)';
comment on column bcom.com_code.start_date is '시작일자';
comment on column bcom.com_code.end_date is '종료일자';
comment on column bcom.com_code.sort_order is '정렬순서';
comment on column bcom.com_code.attr_chr_1 is '추가문자필드1';
comment on column bcom.com_code.attr_chr_2 is '추가문자필드2';
comment on column bcom.com_code.attr_chr_3 is '추가문자필드3';
comment on column bcom.com_code.attr_chr_4 is '추가문자필드4';
comment on column bcom.com_code.attr_chr_5 is '추가문자필드5';
comment on column bcom.com_code.attr_num_1 is '추가숫자필드1';
comment on column bcom.com_code.attr_num_2 is '추가숫자필드2';
comment on column bcom.com_code.attr_num_3 is '추가숫자필드3';
comment on column bcom.com_code.attr_num_4 is '추가숫자필드4';
comment on column bcom.com_code.attr_num_5 is '추가숫자필드5';
comment on column bcom.com_code.attr_date_1 is '추가날짜필드1';
comment on column bcom.com_code.attr_date_2 is '추가날짜필드2';
comment on column bcom.com_code.attr_date_3 is '추가날짜필드3';
comment on column bcom.com_code.attr_date_4 is '추가날짜필드4';
comment on column bcom.com_code.attr_date_5 is '추가날짜필드5';
comment on column bcohttp://m.com_code.remark is '비고';
comment on column bcom.com_code.create_date is '생성일시';
comment on column bcom.com_code.create_by is '생성자';
comment on column bcom.com_code.update_date is '수정일시';
comment on column bcom.com_code.update_by is '수정자';
-- primary 인덱스
alter table bcom.com_code add constraint com_code_pk primary key (code_id) using index tablespace bdb_idx;
-- unique 인덱스
create unique index bcom.com_code_uk on bcom.com_code (corp_id, code_type_id, code) tablespace bdb_idx;
-- nomaral 인덱스
create index bcom.com_code_ix01 on bcom.com_code (code_name) tablespace bdb_idx;
-- 권한부여
grant select, insert, update, delete on bcom.com_code to bsys with grant option;
grant select, insert, update, delete on bcom.com_code to bhrm with grant option;
-- 트리거
create or replace trigger bcom.com_code_trg
before insert or update on bcom.com_code
for each row
begin
if :new.code_type_id is null then
:new.code_id := com_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 bsys/1234@ndb;
create or replace synonym com_code for bcom.com_code;
conn bhrm/1234@ndb;
create or replace synonym com_code for bcom.com_code;
'오라클 > 테이블(공통관리)' 카테고리의 다른 글
[ 메뉴 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
---|---|
[ 사용자권한 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 권한 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 사용자 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 코드유형 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |