
CREATE TABLE TB_CMMN_CODE
(
	CODE		  VARCHAR2(10)  NOT NULL ,
	CODE_NM		  VARCHAR2(100)  NOT NULL ,
	USE_AT		  CHAR(1)   DEFAULT  'Y' NOT NULL,
	PARNTS_CODE	  VARCHAR2(10)  NOT NULL ,
	DC		  	VARCHAR2(200)  NULL ,
	SORT_ORDR	  NUMBER  NOT NULL ,
	CREAT_DT	  DATE  NOT NULL ,
	CRTR		  VARCHAR2(100)  NOT NULL ,
	UPDT_DT		  DATE  NOT NULL ,
	UPDUSR		  VARCHAR2(100)  NOT NULL
);

CREATE UNIQUE INDEX XPKTB_CMMN_CODE ON TB_CMMN_CODE
(PARNTS_CODE  ASC,CODE  ASC);

ALTER TABLE TB_CMMN_CODE
	ADD CONSTRAINT  XPKTB_CMMN_CODE PRIMARY KEY (PARNTS_CODE,CODE);

ALTER TABLE TB_CMMN_CODE MODIFY creat_dt DEFAULT SYSDATE;

ALTER TABLE TB_CMMN_CODE MODIFY updt_dt DEFAULT SYSDATE;

CREATE TABLE TB_CMMN_PARNTS_CODE
(
	PARNTS_CODE	  VARCHAR2(10)  NOT NULL ,
	CODE_NM		  VARCHAR2(100)  NOT NULL ,
	USE_AT		  CHAR(1)   DEFAULT  'Y' NOT NULL,
	DC		  VARCHAR2(200)  NULL ,
	SORT_ORDR	  NUMBER  NOT NULL ,
	CODE_SE		  CHAR(1) NULL,
	CREAT_DT	  DATE  NOT NULL ,
	CRTR		  VARCHAR2(100)  NOT NULL ,
	UPDT_DT		  DATE  NOT NULL ,
	UPDUSR		  VARCHAR2(100)  NOT NULL
);

CREATE UNIQUE INDEX XPKTB_CMMN_PARNTS_CODE ON TB_CMMN_PARNTS_CODE
(PARNTS_CODE  ASC);

ALTER TABLE TB_CMMN_PARNTS_CODE
	ADD CONSTRAINT  XPKTB_CMMN_PARNTS_CODE PRIMARY KEY (PARNTS_CODE);

ALTER TABLE TB_CMMN_CODE
	ADD (CONSTRAINT  R_2 FOREIGN KEY (PARNTS_CODE) REFERENCES TB_CMMN_PARNTS_CODE(PARNTS_CODE));

ALTER TABLE TB_CMMN_PARNTS_CODE MODIFY creat_dt DEFAULT SYSDATE;

ALTER TABLE TB_CMMN_PARNTS_CODE MODIFY updt_dt DEFAULT SYSDATE;

CREATE TABLE TB_LOG
(
	SN					 NUMBER NOT NULL,
	PROGRM_NM            VARCHAR2(500) NOT NULL ,
	LOG                  VARCHAR2(2000) NOT NULL ,
	IP                   VARCHAR2(40) NULL ,
	CRTR                 VARCHAR2(100) NOT NULL ,
	UPDT_DT              DATE NOT NULL ,
	UPDUSR               VARCHAR2(100) NOT NULL ,
	CREAT_DT             DATE NOT NULL
);

CREATE UNIQUE INDEX XPKTB_LOG ON TB_LOG
(SN  ASC);

ALTER TABLE TB_LOG
	ADD CONSTRAINT XPKTB_LOG PRIMARY KEY (SN);

ALTER TABLE TB_LOG MODIFY creat_dt DEFAULT SYSDATE;

ALTER TABLE TB_LOG MODIFY updt_dt DEFAULT SYSDATE;

CREATE SEQUENCE SQ_TB_LOG
    START WITH 1
    INCREMENT BY 1
    MAXVALUE 9999999999
    NOCYCLE;


