CREATE TABLE SGC.TCS_SITE_TRADE (
	CMPN_CD VARCHAR(10) NOT NULL,
	SITE_CD VARCHAR(20) NOT NULL,
	COVEND_ID NUMBER NOT NULL,
	CONT_SEQ NUMBER DEFAULT 1 NOT NULL,
	JOB_GB_CD VARCHAR(20),
	CONT_ID VARCHAR(100),
	CONT_MOD_ID VARCHAR(100),
	MOD_NO VARCHAR(100),
	PO_DOC_NO VARCHAR(100),
	CONT_NM VARCHAR(1000),
	CONT_DT VARCHAR(8),
	COVEND_NM VARCHAR(100),
	COVEND_CORP_REG_NO VARCHAR(20),
	CONT_AMT NUMBER,
	CONT_SUPPLY_AMT NUMBER,
	CONT_TERM VARCHAR(100),
	CONT_START_DT DATE,
	CONT_END_DT DATE,
	CONT_GB VARCHAR(20),
	STATUS_CD VARCHAR(20),
	TEMPLATE_CD VARCHAR(20),
	TEMPLATE_NM VARCHAR(100),
	CHG_CONT_YN VARCHAR(20),
	CUR_GB VARCHAR(20),
	ADJ_GB VARCHAR(20),
	RMK_CN VARCHAR(4000),
	CRT_SYS_CD VARCHAR(20),
	WRTE_DT DATE DEFAULT sysdate,
	WRTE_PR VARCHAR(20),
	MDFT_DT DATE,
	MDFT_PR VARCHAR(20)
)
TABLESPACE TS_SGCDATA
PCTFREE 10
INITRANS 2
STORAGE (
	MAXEXTENTS UNLIMITED
)
LOGGING
NOPARALLEL;
COMMENT ON TABLE SGC.TCS_SITE_TRADE IS '하자)현장업체계약';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.ADJ_GB IS '정산 구분';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CHG_CONT_YN IS '변경 계약 여부';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CMPN_CD IS '회사 코드';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_AMT IS '계약 금액';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_DT IS '계약 일자';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_END_DT IS '계약 만료일';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_GB IS '계약 구분';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_ID IS '계약 번호';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_MOD_ID IS '변경 계약번호';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_NM IS '계약 명';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_SEQ IS '계약순번';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_START_DT IS '계약 시작일';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_SUPPLY_AMT IS '공급 금액';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CONT_TERM IS '계약 기간';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.COVEND_CORP_REG_NO IS '업체 사업자번호';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.COVEND_ID IS '협력업체 ID';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.COVEND_NM IS '업체 명';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CRT_SYS_CD IS '생성시스템코드';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.CUR_GB IS '통화 단위';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.JOB_GB_CD IS '협력업체유형코드[CS004]';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.MDFT_DT IS '수정 일자';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.MDFT_PR IS '수정 자';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.MOD_NO IS '변경 계약차수';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.PO_DOC_NO IS '발주 번호';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.RMK_CN IS '비고_내용';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.SITE_CD IS '현장코드';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.STATUS_CD IS '계약 상태';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.TEMPLATE_CD IS '계약서 코드';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.TEMPLATE_NM IS '계약서 코드명';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.WRTE_DT IS '작성 일자';
COMMENT ON COLUMN SGC.TCS_SITE_TRADE.WRTE_PR IS '작성 자';

CREATE UNIQUE INDEX SGC.PK_TCS_SITE_TRADE ON SGC.TCS_SITE_TRADE (
	CMPN_CD ASC,
	SITE_CD ASC,
	COVEND_ID ASC,
	CONT_SEQ ASC
)
LOGGING
TABLESPACE TS_SGCIDX
PCTFREE 10
INITRANS 2;

ALTER TABLE SGC.TCS_SITE_TRADE ADD CONSTRAINT PK_TCS_SITE_TRADE
PRIMARY KEY (
	CMPN_CD,
	SITE_CD,
	COVEND_ID,
	CONT_SEQ
);