-- ------------------------------------------------------------------------------------------------
-- [ 인사관리 ] 부서 테이블 생성
conn system/built123$@ndb;
-- ------------------------------------------------------------------------------------------------
-- 테이블 생성
drop table bhrm.hrm_dept cascade constraints;
create table bhrm.hrm_dept
(
corp_id number not null
,dept_id number not null
,dept_cd varchar2(50) not null
,dept_name varchar2(200) not null
,dept_short_name varchar2(100)
,dept_type_cd varchar2(50) not null
,start_date date default trunc(sysdate) not null
,end_date date
,cost_center_cd varchar2(50)
,budget_cd varchar2(50)
,expense_cd varchar2(50)
,dept_built123$_id number
,region_cd varchar2(50)
,tel_num varchar2(20)
,fax_num varchar2(20)
,sort_order number default 1 not null
,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 bhrm.hrm_dept is '[인사관리] 부서';
comment on column bhrm.hrm_dept.corp_id is '법인ID';
comment on column bhrm.hrm_dept.dept_id is '부서ID';
comment on column bhrm.hrm_dept.dept_cd is '부서코드';
comment on column bhrm.hrm_dept.dept_name is '부서명';
comment on column bhrm.hrm_dept.dept_short_name is '부서명(약칭)';
comment on column bhrm.hrm_dept.dept_type_cd is '부서유형코드';
comment on column bhrm.hrm_dept.start_date is '시작일자';
comment on column bhrm.hrm_dept.end_date is '종료일자';
comment on column bhrm.hrm_dept.cost_center_cd is '원가코드';
comment on column bhrm.hrm_dept.budget_cd is '예산코드';
comment on column bhrm.hrm_dept.expense_cd is '비용코드';
comment on column bhrm.hrm_dept.dept_built123$_id is '부서관리자id';
comment on column bhrm.hrm_dept.region_cd is '지역코드';
comment on column bhrm.hrm_dept.tel_num is '전화번호';
comment on column bhrm.hrm_dept.fax_num is '팩스번호';
comment on column bhrm.hrm_dept.sort_order is '정렬순서';
comment on column bhrhttp://m.hrm_dept.remark is '비고';
comment on column bhrm.hrm_dept.create_date is '생성일시';
comment on column bhrm.hrm_dept.create_by is '생성자';
comment on column bhrm.hrm_dept.update_date is '수정일시';
comment on column bhrm.hrm_dept.update_by is '수정자';
-- primary 인덱스
alter table bhrm.hrm_dept add constraint hrm_dept_pk primary key (dept_id) using index tablespace bdb_idx;
-- unique 인덱스
create unique index bhrm.hrm_dept_uk01 on bhrm.hrm_dept (corp_id, dept_cd) tablespace bdb_idx;
-- normal 인덱스
create index bhrm.hrm_dept_ix01 on bhrm.hrm_dept (dept_name) tablespace bdb_idx;
-- 권한부여
grant select, insert, update, delete on bhrm.hrm_dept to bsys with grant option;
grant select, insert, update, delete on bhrm.hrm_dept to bcom with grant option;
-- 트리거 생성
create or replace trigger bhrm.hrm_dept_trg
before insert or update on bhrm.hrm_dept
for each row
begin
if :new.dept_id is null then
:new.dept_id := hrm_dept_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 hrm_dept for bhrm.hrm_dept;
conn bcom/1234@ndb;
create or replace synonym hrm_dept for bhrm.hrm_dept;
'오라클 > 테이블(인사관리)' 카테고리의 다른 글
[ 임직원 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
---|---|
[ 조직도상세 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 조직도 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 사업장 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |
[ 법인 ] 테이블 생성을 아래와 같이 진행합니다. (0) | 2024.04.12 |