본문 바로가기
  • 노란색 세상은 어디에 있을까?
  • 봄이 오면 여기에 있겠지.
  • 잠시나마 유유자적 하겠네.
오라클/테이블(공통관리)

[ 권한메뉴 ] 테이블 생성을 아래와 같이 진행합니다.

by 태백성 2024. 4. 12.

-- ------------------------------------------------------------------------------------------------
-- [ 공통관리] 권한메뉴 테이블 생성
conn system/built123$@ndb;
-- ------------------------------------------------------------------------------------------------
-- 테이블 생성
drop   table bcom.com_auth_menu cascade constraints;
create table bcom.com_auth_menu
(
 corp_id                 number         not null
    ,auth_menu_id            number         not null
    ,auth_id                 number         not null
    ,menu_id                 number         not null
    ,use_yn                  varchar2(1)    default 'Y' not null
    ,search_yn               varchar2(1)    default 'Y' not null
    ,save_yn                 varchar2(1)    default 'N' not null
    ,delete_yn               varchar2(1)    default 'N' not null
    ,print_yn                varchar2(1)    default 'N' not null
    ,excel_down_yn           varchar2(1)    default 'N' not null
    ,excel_up_yn             varchar2(1)    default 'N' not null
    ,create_yn               varchar2(1)    default 'N' not null  
    ,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  bcom.com_auth_menu                   is '[공통관리] 권한메뉴';
comment on column bcom.com_auth_menu.corp_id           is '법인ID';
comment on column bcom.com_auth_menu.auth_menu_id      is '권한메뉴ID';
comment on column bcom.com_auth_menu.auth_id           is '권한ID';
comment on column bcom.com_auth_menu.menu_id           is '메뉴ID';
comment on column bcom.com_auth_menu.use_yn            is '사용여부';
comment on column bcom.com_auth_menu.search_yn         is '조회여부';
comment on column bcom.com_auth_menu.save_yn           is '저장여부';
comment on column bcom.com_auth_menu.delete_yn         is '삭제여부';
comment on column bcom.com_auth_menu.print_yn          is '출력여부';
comment on column bcom.com_auth_menu.excel_down_yn     is '엑셀업로드여부';
comment on column bcom.com_auth_menu.excel_up_yn       is '엑셀다운로드여부';
comment on column bcom.com_auth_menu.create_yn         is '생성여부';
comment on column bcom.com_auth_menu.sort_order        is '정렬순서';
comment on column bcohttp://m.com_auth_menu.remark is '비고';

comment on column bcom.com_auth_menu.create_date       is '생성일시';
comment on column bcom.com_auth_menu.create_by         is '생성자';
comment on column bcom.com_auth_menu.update_date       is '수정일시';
comment on column bcom.com_auth_menu.update_by         is '수정자';

-- primary 인덱스
alter table bcom.com_auth_menu add constraint com_auth_menu_pk primary key (auth_menu_id) using index tablespace bdb_idx;

-- unique 인덱스
create unique index bcom.com_auth_menu_uk01 on bcom.com_auth_menu (corp_id, auth_id, menu_id) tablespace bdb_idx;

-- 권한부여
grant select, insert, update, delete on bcom.com_auth_menu to bsys with grant option;
grant select, insert, update, delete on bcom.com_auth_menu to bhrm with grant option;

-- 트리거
create or replace trigger bcom.com_auth_menu_trg
    before insert or update on bcom.com_auth_menu
    for each row
begin
    if :new.auth_menu_id is null then
        :new.auth_menu_id := com_auth_menu_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_auth_menu for bcom.com_auth_menu;

conn bhrm/1234@ndb;
create or replace synonym com_auth_menu for bcom.com_auth_menu;