CREATE TABLE EMSAPP.API_HISTORY
(
  API_ID      VARCHAR2(30),
  SEQ         NUMBER(22),
  SAVEDDATA   CLOB,
  USERID      VARCHAR2(20),
  SAVEDDT     VARCHAR2(14)
)
LOB (SAVEDDATA) STORE AS SECUREFILE (TABLESPACE  TS_AGW_D01)
TABLESPACE TS_EMS_D01;

COMMENT ON TABLE EMSAPP.API_HISTORY IS 'API 변경이력 테이블';
COMMENT ON COLUMN EMSAPP.API_HISTORY.API_ID IS 'API ID(TSEAIHE01.EAISVCNAME)';
COMMENT ON COLUMN EMSAPP.API_HISTORY.SEQ IS 'Sequence 값';
COMMENT ON COLUMN EMSAPP.API_HISTORY.SAVEDDATA IS '변경저장 정보';
COMMENT ON COLUMN EMSAPP.API_HISTORY.USERID IS '사용자ID';
COMMENT ON COLUMN EMSAPP.API_HISTORY.SAVEDDT IS '저장일시';

CREATE UNIQUE INDEX EMSAPP.PK_API_HISTORY ON EMSAPP.API_HISTORY
(API_ID, SEQ)
TABLESPACE TS_EMS_I01;

ALTER TABLE EMSAPP.API_HISTORY ADD (
  CONSTRAINT PK_API_HISTORY
  PRIMARY KEY
  (API_ID, SEQ)
  USING INDEX EMSAPP.PK_API_HISTORY
  ENABLE VALIDATE);

GRANT DELETE, INSERT, SELECT, UPDATE ON EMSAPP.API_HISTORY TO RL_EMS_ALL;
GRANT SELECT ON EMSAPP.API_HISTORY TO RL_EMS_SEL;
