/* FIXME: 카카오톡에 맞게 변경 필요 */
create table ENS_TMPLT_MNG_KKO_TALK
(
    ORG_CD               VARCHAR2(255 char) not null,
    TMPLT_CD             VARCHAR2(30 char)  not null,
    CI_TRANS_USE_YN      VARCHAR2(1 char)   not null,
    CS_NAME              VARCHAR2(10 char)  not null,
    CS_NUMBER            VARCHAR2(20 char)  not null,
    PRY_MESSAGE          VARCHAR2(2000 char),
    TMPLT_CS_INFO_USE_YN VARCHAR2(1 char)   not null,
    TMPLT_MSG_USE_YN     VARCHAR2(1 char)   not null,
    primary key (ORG_CD, TMPLT_CD),
    constraint FK_TMPLT_MNG_KKO_TALK
        foreign key (ORG_CD, TMPLT_CD) references ENS_TMPLT_MNG
);

create table ENS_SND_DTL_KKO_TALK
(
    SEND_DETAIL_ID              NUMBER(19) not null
        primary key,
    ENVELOPE_ID                 VARCHAR2(34),
    EXTERNAL_ID                 VARCHAR2(40),
    TITLE                       VARCHAR2(80),
    LINK                        VARCHAR2(500),
    HASH                        VARCHAR2(99),
    GUIDE                       VARCHAR2(2000),
    PAYLOAD                     VARCHAR2(500),
    READ_EXPIRES_AT             VARCHAR2(20),
    REVIEW_EXPIRES_AT           VARCHAR2(20),
    USE_NON_PERSONALIZED_NOTI   VARCHAR2(10),
    CI                          VARCHAR2(88),
    PHONE_NUMBER                VARCHAR2(30),
    NAME                        VARCHAR2(50),
    BIRTHDAY                    VARCHAR2(8),
    STATUS                      VARCHAR2(20),
    SENT_AT                     VARCHAR2(20),
    RECEIVED_AT                 VARCHAR2(20),
    READ_AT                     VARCHAR2(20),
    AUTHENTICATED_AT            VARCHAR2(20),
    OTT_VERIFIED_AT             VARCHAR2(20),
    IS_NOTIFICATION_UNAVAILABLE VARCHAR2(10),
    USER_NOTIFIED_AT            VARCHAR2(20),
    DISTRIBUTION_RECEIVED_AT    VARCHAR2(20),
    ERROR_CODE                  VARCHAR2(40),
    ERROR_MESSAGE               CLOB,
    MK_JID                      VARCHAR2(24),
    MK_TMPLT_MSG_JSON_DATA      VARCHAR2(4000),
    MK_BILL_USE_YN              VARCHAR2(1),
    LAST_UPDT_DT                TIMESTAMP(6),
    REGIST_DT                   TIMESTAMP(6),
    BILL_UID                    VARCHAR2(45)
        constraint FK_BILL_UID
            references IUP.ENS_BILL (BILL_UID),
    SEND_MAST_ID                NUMBER(19)
        constraint FK_SEND_MAST_ID
            references IUP.ENS_SND_MAST

);
comment on table ENS_SND_DTL_KKO_TALK is '카카오톡 상세';
comment on column ENS_SND_DTL_KKO_TALK.SEND_DETAIL_ID is '발송 상세 ID';
comment on column ENS_SND_DTL_KKO_TALK.TITLE is '제목';
comment on column ENS_SND_DTL_KKO_TALK.LINK is '웹링크';
comment on column ENS_SND_DTL_KKO_TALK.HASH is '해시';
comment on column ENS_SND_DTL_KKO_TALK.GUIDE is '메시지';
comment on column ENS_SND_DTL_KKO_TALK.PAYLOAD is 'PAYLOAD';
comment on column ENS_SND_DTL_KKO_TALK.READ_EXPIRES_AT is '최초 열람 만료 일시';
comment on column ENS_SND_DTL_KKO_TALK.REVIEW_EXPIRES_AT is '재열람 만료 일시';
comment on column ENS_SND_DTL_KKO_TALK.USE_NON_PERSONALIZED_NOTI is '알림톡 개인정보 제거 여부';
comment on column ENS_SND_DTL_KKO_TALK.CI is 'CI';
comment on column ENS_SND_DTL_KKO_TALK.PHONE_NUMBER is '수신인 전화번호';
comment on column ENS_SND_DTL_KKO_TALK.NAME is '수신인 이름';
comment on column ENS_SND_DTL_KKO_TALK.BIRTHDAY is '수신인 생년월일';
comment on column ENS_SND_DTL_KKO_TALK.EXTERNAL_ID is '문서 매핑 식별 ID';
comment on column ENS_SND_DTL_KKO_TALK.ENVELOPE_ID is '문서 고유 ID';
comment on column ENS_SND_DTL_KKO_TALK.STATUS is '문서 상태';
comment on column ENS_SND_DTL_KKO_TALK.SENT_AT is '문서 송신 일시';
comment on column ENS_SND_DTL_KKO_TALK.RECEIVED_AT is '문서 수신 일시';
comment on column ENS_SND_DTL_KKO_TALK.READ_AT is '문서 열람 일시';
comment on column ENS_SND_DTL_KKO_TALK.AUTHENTICATED_AT is '문서 열람 인증 일시';
comment on column ENS_SND_DTL_KKO_TALK.OTT_VERIFIED_AT is '토큰 검증 일시';
comment on column ENS_SND_DTL_KKO_TALK.IS_NOTIFICATION_UNAVAILABLE is '알림톡 수신 가능 여부';
comment on column ENS_SND_DTL_KKO_TALK.USER_NOTIFIED_AT is '알림톡 수신 일시';
comment on column ENS_SND_DTL_KKO_TALK.DISTRIBUTION_RECEIVED_AT is '유통정보 수신 일시';
comment on column ENS_SND_DTL_KKO_TALK.ERROR_CODE is '에러 코드';
comment on column ENS_SND_DTL_KKO_TALK.ERROR_MESSAGE is '에러 메시지';
comment on column ENS_SND_DTL_KKO_TALK.LAST_UPDT_DT is '수정 일시';
comment on column ENS_SND_DTL_KKO_TALK.REGIST_DT is '등록 일시';
comment on column ENS_SND_DTL_KKO_TALK.SEND_MAST_ID is '발송 마스터 ID';

create table ENS_SND_DTL_KKO_TALK_OTT_HIS
(
    ID               NUMBER(19) not null
        primary key,
    ENVELOPE_ID      VARCHAR2(255 char),
    EXTERNAL_ID      VARCHAR2(255 char),
    RECEIVED_AT      VARCHAR2(19),
    SENT_AT          VARCHAR2(19),
    PAYLOAD          VARCHAR2(255 char),
    SIGNED_AT        VARCHAR2(255 char),
    TOKEN            VARCHAR2(255 char),
    TOKEN_EXPIRES_AT VARCHAR2(19),
    TOKEN_STATUS     VARCHAR2(255 char),
    TOKEN_USED_AT    VARCHAR2(19),
    AUTHENTICATED_AT VARCHAR2(19),
    USER_NOTIFIED_AT VARCHAR2(19),
    ERROR_CODE       VARCHAR2(255 char),
    ERROR_MESSAGE    CLOB,
    REGIST_DT        TIMESTAMP(6)
);
create index IDX_SND_DTL_KKO_TALK_OTT_HIS_01
    on ENS_SND_DTL_KKO_TALK_OTT_HIS (REGIST_DT);

create table ENS_SND_DTL_KKO_TALK_REQ_HIS
(
    ID                     NUMBER(19)          not null
        primary key,
    SEND_DETAIL_ID         NUMBER(19),
    ENVELOPE_ID            VARCHAR2(255 char),
    EXTERNAL_ID            VARCHAR2(255 char),
    RESP_RAW_MSG           VARCHAR2(1000 char),
    SEND_RAW_MSG           VARCHAR2(4000 char) not null,
    ERROR_CODE             VARCHAR2(255 char),
    ERROR_MESSAGE          CLOB,
    REGIST_DT              TIMESTAMP(6)
);
create index IDX_SND_DTL_KKO_TALK_REQ_HIS_01
    on ENS_SND_DTL_KKO_TALK_REQ_HIS (REGIST_DT);

create table ENS_SND_DTL_KKO_TALK_STAT_HIS
(
    ID                       NUMBER(19) not null
        primary key,
    SEND_DETAIL_ID           NUMBER(19) not null,
    ENVELOPE_ID              VARCHAR2(255 char),
    EXTERNAL_ID              VARCHAR2(255 char),
    READ_AT                  VARCHAR2(19),
    READ_EXPIRED_AT          VARCHAR2(19),
    RECEIVED_AT              VARCHAR2(19),
    SENT_AT                  VARCHAR2(19),
    STATUS                   VARCHAR2(255 char),
    AUTHENTICATED_AT         VARCHAR2(19),
    DISTRIBUTION_RECEIVED_AT VARCHAR2(19),
    PAYLOAD                  VARCHAR2(255 char),
    TOKEN_USED_AT            VARCHAR2(19),
    USER_NOTIFIED_AT         VARCHAR2(19),
    OTT_VERIFIED_AT          VARCHAR2(19),
    ERROR_CODE               VARCHAR2(255 char),
    ERROR_MESSAGE            CLOB,
    REGIST_DT                TIMESTAMP(6)
);
create index IDX_SND_DTL_KKO_TALK_STAT_HIS_01
    on ENS_SND_DTL_KKO_TALK_STAT_HIS (REGIST_DT);


ALTER TABLE ENS_ORG_MNG ADD  KAKAO_PARTNER_REST_API_KEY VARCHAR2(100);
ALTER TABLE ENS_ORG_MNG ADD  KAKAO_DEALER_REST_API_KEY VARCHAR2(100);
ALTER TABLE ENS_ORG_MNG ADD  KAKAO_DEV_SETTLE_ID VARCHAR2(100);
ALTER TABLE ENS_ORG_MNG ADD  KAKAO_PROD_SETTLE_ID VARCHAR2(100);

ALTER TABLE ENS_INTGRN_SND_DTL ADD SEND_DETAIL_ID_KKO_TALK NUMBER(19);
ALTER TABLE ENS_INTGRN_SND_DTL ADD J_ACPT_DOC_KKO_TALK CLOB;



/* **********************************************
* 나이스 알림톡 추가
********************************************** */

CREATE TABLE TB_NICE_SMS_SNDNG_INQIRE_REPTI
(
    NICE_SMS_SNDNG_INQIRE_ID CHAR(10) NOT NULL ,
    SN                   NUMBER(2) NOT NULL ,
    INQIRE_DT            VARCHAR2(20) NULL ,
    INDVDL_BSNM_CPR_SE   VARCHAR2(1) NULL ,
    IHIDNUM              VARCHAR2(28) NULL ,
    NM                   VARCHAR2(20) NULL ,
    RANK_CTTPC_1         VARCHAR2(11) NULL ,
    RANK_CTTPC_2         VARCHAR2(11) NULL ,
    RANK_CTTPC_3         VARCHAR2(11) NULL ,
    RESULT_SE            VARCHAR2(2) NULL ,
    SMS_SNDNG_REQUST_SE  VARCHAR2(1) NULL ,
    SNDNG_MSSAGE         VARCHAR2(1000) NULL ,
    DSPTCH_NO            VARCHAR2(12) NULL ,
    SMS_SNDNG_CTTPC_RANK VARCHAR2(1) NULL ,
    SMS_SNDNG_CTTPC_NO   VARCHAR2(11) NULL ,
    SMS_SNDNG_DT         VARCHAR2(14) NULL ,
    OPETR_ID             VARCHAR2(9) NULL ,
    CTTPC_INQIRE_SE      VARCHAR2(1) NULL ,
    MSSAGE_SNDNG_RESULT_SE VARCHAR2(1) NULL ,
    RSPNS_REPTIT_BLNK    VARCHAR2(11) NULL ,
    CREAT_DT             DATE NULL ,
    CRTR                 VARCHAR2(50) NULL
);

CREATE UNIQUE INDEX TB_NICE_SMS_SNDNG_INQIRE_REPTI ON TB_NICE_SMS_SNDNG_INQIRE_REPTI
    (NICE_SMS_SNDNG_INQIRE_ID   ASC,SN   ASC);

ALTER TABLE TB_NICE_SMS_SNDNG_INQIRE_REPTI
    ADD CONSTRAINT  TB_NICE_SMS_SNDNG_INQIRE_REPTI PRIMARY KEY (NICE_SMS_SNDNG_INQIRE_ID,SN);

CREATE TABLE TB_NICE_SMS_SNDNG_INQIRE_REQUS
(
    NICE_SMS_SNDNG_INQIRE_ID CHAR(10) NOT NULL ,
    TRNSC_ID             VARCHAR2(10) NULL ,
    SPCLTY_GROUPCODE     VARCHAR2(9) NULL ,
    DELNG_ASORTCODE      NUMBER(4) NULL ,
    DELNG_SECODE         NUMBER(5) NULL ,
    TRSMRCV_AT           VARCHAR2(1) NULL ,
    TRMNL_SE             VARCHAR2(3) NULL ,
    RSPNS_CODE           VARCHAR2(4) NULL ,
    PARTCPT_INSTT_ID     VARCHAR2(9) NULL ,
    INSTT_SPCLTY_MANAGENO VARCHAR2(10) NULL ,
    INSTT_SPCLTY_TRNSMISTIME VARCHAR2(14) NULL ,
    NICE_SPCLTY_MANAGENO VARCHAR2(10) NULL ,
    NICE_SPCLTY_TRNSMISTIME VARCHAR2(14) NULL ,
    BLNK                 VARCHAR2(17) NULL ,
    SEARCH_PD_FROM       VARCHAR2(20) NULL ,
    SEARCH_PD_TO         VARCHAR2(20) NULL ,
    INDVDL_BSNM_CPR_SE   VARCHAR2(1) NULL ,
    IHIDNUM              VARCHAR2(28) NULL ,
    RESULT_SE            VARCHAR2(2) NULL ,
    SMS_SNDNG_REQUST_SE  VARCHAR2(1) NULL ,
    REQUST_CO            VARCHAR2(10) NULL ,
    ACCMLT_RECPTN_CO     VARCHAR2(10) NULL ,
    INDVDLZ_REQUST_BLNK  VARCHAR2(23) NULL ,
    CREAT_DT             DATE NULL ,
    CRTR                 VARCHAR2(50) NULL
);

CREATE UNIQUE INDEX TB_NICE_SMS_SNDNG_INQIRE_REQUS ON TB_NICE_SMS_SNDNG_INQIRE_REQUS
    (NICE_SMS_SNDNG_INQIRE_ID   ASC);

ALTER TABLE TB_NICE_SMS_SNDNG_INQIRE_REQUS
    ADD CONSTRAINT  TB_NICE_SMS_SNDNG_INQIRE_REQUS PRIMARY KEY (NICE_SMS_SNDNG_INQIRE_ID);

CREATE TABLE TB_NICE_SMS_SNDNG_INQIRE_RSPNS
(
    NICE_SMS_SNDNG_INQIRE_ID CHAR(10) NOT NULL ,
    TRNSC_ID             VARCHAR2(10) NULL ,
    SPCLTY_GROUPCODE     VARCHAR2(9) NULL ,
    DELNG_ASORTCODE      NUMBER(4) NULL ,
    DELNG_SECODE         NUMBER(5) NULL ,
    TRSMRCV_AT           VARCHAR2(1) NULL ,
    TRMNL_SE             VARCHAR2(3) NULL ,
    RSPNS_CODE           VARCHAR2(4) NULL ,
    PARTCPT_INSTT_ID     VARCHAR2(9) NULL ,
    INSTT_SPCLTY_MANAGENO VARCHAR2(10) NULL ,
    INSTT_SPCLTY_TRNSMISTIME VARCHAR2(14) NULL ,
    NICE_SPCLTY_MANAGENO VARCHAR2(10) NULL ,
    NICE_SPCLTY_TRNSMISTIME VARCHAR2(14) NULL ,
    BLNK                 VARCHAR2(17) NULL ,
    TOT_CO               VARCHAR2(10) NULL ,
    ACCMLT_CO            VARCHAR2(10) NULL ,
    RSPNS_CO             VARCHAR2(10) NULL ,
    CREAT_DT             DATE NULL ,
    CRTR                 VARCHAR2(50) NULL
);

CREATE UNIQUE INDEX TB_NICE_SMS_SNDNG_INQIRE_RSPNS ON TB_NICE_SMS_SNDNG_INQIRE_RSPNS
    (NICE_SMS_SNDNG_INQIRE_ID   ASC);

ALTER TABLE TB_NICE_SMS_SNDNG_INQIRE_RSPNS
    ADD CONSTRAINT  TB_NICE_SMS_SNDNG_INQIRE_RSPNS PRIMARY KEY (NICE_SMS_SNDNG_INQIRE_ID);

CREATE TABLE TB_NICE_SMS_SNDNG_REQUST
(
    NICE_SMS_SNDNG_REQUST_ID CHAR(10) NOT NULL ,
    DATA_ID              VARCHAR2(30) NULL ,
    TRNSC_ID             VARCHAR2(10) NULL ,
    SPCLTY_GROUPCODE     VARCHAR2(9) NULL ,
    DELNG_ASORTCODE      NUMBER(4) NULL ,
    DELNG_SECODE         NUMBER(5) NULL ,
    TRSMRCV_AT           VARCHAR2(1) NULL ,
    TRMNL_SE             VARCHAR2(3) NULL ,
    RSPNS_CODE           VARCHAR2(4) NULL ,
    PARTCPT_INSTT_ID     VARCHAR2(9) NULL ,
    INSTT_SPCLTY_MANAGENO VARCHAR2(10) NULL ,
    INSTT_SPCLTY_TRNSMISTIME VARCHAR2(14) NULL ,
    NICE_SPCLTY_MANAGENO VARCHAR2(10) NULL ,
    NICE_SPCLTY_TRNSMISTIME VARCHAR2(14) NULL ,
    BLNK                 VARCHAR2(16) NULL ,
    INQIRE_AGRE_RESN     VARCHAR2(1) NULL ,
    INQIRE_RESN          VARCHAR2(2) NULL ,
    INQIRE_REQUST_CO     NUMBER(2) NULL ,
    SMS_SNDNG_REQUST_SE  VARCHAR2(1) NULL ,
    SNDNG_MSSAGE         VARCHAR2(2000) NULL ,
    DSPTCH_NO            VARCHAR2(12) NULL ,
    CTTPC_INQIRE_SE      VARCHAR2(1) NULL ,
    NTCNTALK_SNDNG_REQUST_SE VARCHAR2(1) NULL ,
    NTCNTALK_TMPLAT_CODE VARCHAR2(100) NULL ,
    BTTON_REQUST_CO      NUMBER(1) NULL ,
    INDVDLZ_REQUST_BLNK  VARCHAR2(880) NULL ,
    INDVDL_BSNM_CPR_SE   VARCHAR2(1) NULL ,
    IHIDNUM              VARCHAR2(28) NULL ,
    INQIRE_REQUST_BLNK   VARCHAR2(36) NULL ,
    BTTON_TY             VARCHAR2(2) NULL ,
    BTTON_NM             VARCHAR2(56) NULL ,
    BTTON_URL_WEB_LINK_1 VARCHAR2(1000) NULL ,
    BTTON_URL_WEB_LINK_2 VARCHAR2(1000) NULL ,
    BTTON_REQUST_BLNK    VARCHAR2(942) NULL ,
    CREAT_DT             DATE NULL ,
    CRTR                 VARCHAR2(50) NULL
);

CREATE UNIQUE INDEX TB_NICE_SMS_SNDNG_REQUST_PK ON TB_NICE_SMS_SNDNG_REQUST
    (NICE_SMS_SNDNG_REQUST_ID   ASC);

ALTER TABLE TB_NICE_SMS_SNDNG_REQUST
    ADD CONSTRAINT  TB_NICE_SMS_SNDNG_REQUST_PK PRIMARY KEY (NICE_SMS_SNDNG_REQUST_ID);

CREATE TABLE TB_NICE_SMS_SNDNG_RSPNS
(
    NICE_SMS_SNDNG_REQUST_ID CHAR(10) NOT NULL ,
    TRNSC_ID             VARCHAR2(10) NULL ,
    SPCLTY_GROUPCODE     VARCHAR2(9) NULL ,
    DELNG_ASORTCODE      NUMBER(4) NULL ,
    DELNG_SECODE         NUMBER(5) NULL ,
    TRSMRCV_AT           VARCHAR2(1) NULL ,
    TRMNL_SE             VARCHAR2(3) NULL ,
    RSPNS_CODE           VARCHAR2(4) NULL ,
    PARTCPT_INSTT_ID     VARCHAR2(9) NULL ,
    INSTT_SPCLTY_MANAGENO VARCHAR2(10) NULL ,
    INSTT_SPCLTY_TRNSMISTIME VARCHAR2(14) NULL ,
    NICE_SPCLTY_MANAGENO VARCHAR2(10) NULL ,
    NICE_SPCLTY_TRNSMISTIME VARCHAR2(14) NULL ,
    BLNK                 VARCHAR2(17) NULL ,
    RSPNS_CO             NUMBER(2) NULL ,
    SMS_SNDNG_REQUST_SE  VARCHAR2(1) NULL ,
    SNDNG_MSSAGE         VARCHAR2(2000) NULL ,
    DSPTCH_NO            VARCHAR2(12) NULL ,
    CTTPC_INQIRE_SE      VARCHAR2(1) NULL ,
    INDVDLZ_RSPNS_BLNK   VARCHAR2(84) NULL ,
    INDVDL_BSNM_CPR_SE   VARCHAR2(1) NULL ,
    IHIDNUM              VARCHAR2(28) NULL ,
    NM                   VARCHAR2(20) NULL ,
    RANK_CTTPC_1         VARCHAR2(11) NULL ,
    RANK_CTTPC_2         VARCHAR2(11) NULL ,
    RANK_CTTPC_3         VARCHAR2(11) NULL ,
    RESULT_SE            VARCHAR2(2) NULL ,
    SMS_SNDNG_CTTPC_RANK VARCHAR2(1) NULL ,
    SMS_SNDNG_CTTPC_NO   VARCHAR2(11) NULL ,
    SMS_SNDNG_DT         VARCHAR2(14) NULL ,
    RSPNS_REPTIT_BLNK    VARCHAR2(15) NULL ,
    CREAT_DT             DATE NULL ,
    CRTR                 VARCHAR2(50) NULL
);

CREATE UNIQUE INDEX TB_NICE_SMS_SNDNG_RSPNS_PK ON TB_NICE_SMS_SNDNG_RSPNS
    (NICE_SMS_SNDNG_REQUST_ID   ASC);

ALTER TABLE TB_NICE_SMS_SNDNG_RSPNS
    ADD CONSTRAINT  TB_NICE_SMS_SNDNG_RSPNS_PK PRIMARY KEY (NICE_SMS_SNDNG_REQUST_ID);

COMMENT ON TABLE TB_NICE_SMS_SNDNG_INQIRE_REPTI IS 'NICE SMS 발송 조회 반복';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.NICE_SMS_SNDNG_INQIRE_ID IS 'NICE_SMS_발송_조회_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.SN IS '순번';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.INQIRE_DT IS '조회_일시';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.INDVDL_BSNM_CPR_SE IS '개인_사업자_법인_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.IHIDNUM IS '주민번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.NM IS '성명';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.RANK_CTTPC_1 IS '1_순위_연락처';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.RANK_CTTPC_2 IS '2_순위_연락처';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.RANK_CTTPC_3 IS '3_순위_연락처';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.RESULT_SE IS '결과_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.SMS_SNDNG_REQUST_SE IS 'SMS_발송_요청_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.SNDNG_MSSAGE IS '발송_메시지';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.DSPTCH_NO IS '발신_번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.SMS_SNDNG_CTTPC_RANK IS 'SMS_발송_연락처_순위';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.SMS_SNDNG_CTTPC_NO IS 'SMS_발송_연락처_번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.SMS_SNDNG_DT IS 'SMS_발송_일시';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.OPETR_ID IS '처리자_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.CTTPC_INQIRE_SE IS '연락처_조회_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.MSSAGE_SNDNG_RESULT_SE IS '메시지_발송_결과_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.RSPNS_REPTIT_BLNK IS '응답_반복_공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.CREAT_DT IS '생성_일시';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REPTI.CRTR IS '생성자';

COMMENT ON TABLE TB_NICE_SMS_SNDNG_INQIRE_REQUS IS 'NICE SMS 발송 조회 요청';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.NICE_SMS_SNDNG_INQIRE_ID IS 'NICE_SMS_발송_조회_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.TRNSC_ID IS '트랜잭션_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.SPCLTY_GROUPCODE IS '전문_그룹코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.DELNG_ASORTCODE IS '거래_종별코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.DELNG_SECODE IS '거래_구분코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.TRSMRCV_AT IS '송수신_플래그';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.TRMNL_SE IS '단말기_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.RSPNS_CODE IS '응답_코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.PARTCPT_INSTT_ID IS '참가_기관_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.INSTT_SPCLTY_MANAGENO IS '기관_전문_관리번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.INSTT_SPCLTY_TRNSMISTIME IS '기관_전문_전송시간';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.NICE_SPCLTY_MANAGENO IS 'NICE_전문_관리번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.NICE_SPCLTY_TRNSMISTIME IS 'NICE_전문_전송시간';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.BLNK IS '공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.SEARCH_PD_FROM IS '검색_기간_FROM';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.SEARCH_PD_TO IS '검색_기간_TO';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.INDVDL_BSNM_CPR_SE IS '개인_사업자_법인_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.IHIDNUM IS '주민번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.RESULT_SE IS '결과_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.SMS_SNDNG_REQUST_SE IS 'SMS_발송_요청_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.REQUST_CO IS '요청_건수';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.ACCMLT_RECPTN_CO IS '누적_수신_건수';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.INDVDLZ_REQUST_BLNK IS '개별_요청_공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.CREAT_DT IS '생성_일시';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_REQUS.CRTR IS '생성자';

COMMENT ON TABLE TB_NICE_SMS_SNDNG_INQIRE_RSPNS IS 'NICE SMS 발송 조회 응답';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.NICE_SMS_SNDNG_INQIRE_ID IS 'NICE_SMS_발송_조회_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.TRNSC_ID IS '트랜잭션_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.SPCLTY_GROUPCODE IS '전문_그룹코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.DELNG_ASORTCODE IS '거래_종별코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.DELNG_SECODE IS '거래_구분코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.TRSMRCV_AT IS '송수신_플래그';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.TRMNL_SE IS '단말기_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.RSPNS_CODE IS '응답_코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.PARTCPT_INSTT_ID IS '참가_기관_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.INSTT_SPCLTY_MANAGENO IS '기관_전문_관리번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.INSTT_SPCLTY_TRNSMISTIME IS '기관_전문_전송시간';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.NICE_SPCLTY_MANAGENO IS 'NICE_전문_관리번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.NICE_SPCLTY_TRNSMISTIME IS 'NICE_전문_전송시간';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.BLNK IS '공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.TOT_CO IS '총_건수';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.ACCMLT_CO IS '누적_건수';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.RSPNS_CO IS '응답_건수';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.CREAT_DT IS '생성_일시';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_INQIRE_RSPNS.CRTR IS '생성자';

COMMENT ON TABLE TB_NICE_SMS_SNDNG_REQUST IS 'NICE SMS 발송 요청';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.NICE_SMS_SNDNG_REQUST_ID IS 'NICE_SMS_발송_요청_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.DATA_ID IS 'DATA_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.TRNSC_ID IS '트랜잭션_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.SPCLTY_GROUPCODE IS '전문_그룹코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.DELNG_ASORTCODE IS '거래_종별코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.DELNG_SECODE IS '거래_구분코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.TRSMRCV_AT IS '송수신_플래그';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.TRMNL_SE IS '단말기_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.RSPNS_CODE IS '응답_코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.PARTCPT_INSTT_ID IS '참가_기관_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.INSTT_SPCLTY_MANAGENO IS '기관_전문_관리번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.INSTT_SPCLTY_TRNSMISTIME IS '기관_전문_전송시간';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.NICE_SPCLTY_MANAGENO IS 'NICE_전문_관리번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.NICE_SPCLTY_TRNSMISTIME IS 'NICE_전문_전송시간';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.BLNK IS '공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.INQIRE_AGRE_RESN IS '조회_동의_사유';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.INQIRE_RESN IS '조회_사유';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.INQIRE_REQUST_CO IS '조회_요청_건수';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.SMS_SNDNG_REQUST_SE IS 'SMS_발송_요청_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.SNDNG_MSSAGE IS '발송_메시지';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.DSPTCH_NO IS '발신_번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.CTTPC_INQIRE_SE IS '연락처_조회_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.NTCNTALK_SNDNG_REQUST_SE IS '알림톡_발송_요청_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.NTCNTALK_TMPLAT_CODE IS '알림톡_템플릿_코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.BTTON_REQUST_CO IS '버튼_요청_건수';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.INDVDLZ_REQUST_BLNK IS '개별_요청_공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.INDVDL_BSNM_CPR_SE IS '개인_사업자_법인_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.IHIDNUM IS '주민번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.INQIRE_REQUST_BLNK IS '조회_요청_공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.BTTON_TY IS '버튼_타입';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.BTTON_NM IS '버튼_이름';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.BTTON_URL_WEB_LINK_1 IS '버튼_URL_웹_링크_1';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.BTTON_URL_WEB_LINK_2 IS '버튼_URL_웹_링크_2';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.BTTON_REQUST_BLNK IS '버튼_요청_공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.CREAT_DT IS '생성_일시';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_REQUST.CRTR IS '생성자';

COMMENT ON TABLE TB_NICE_SMS_SNDNG_RSPNS IS 'NICE SMS 발송 응답';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.NICE_SMS_SNDNG_REQUST_ID IS 'NICE_SMS_발송_요청_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.TRNSC_ID IS '트랜잭션_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.SPCLTY_GROUPCODE IS '전문_그룹코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.DELNG_ASORTCODE IS '거래_종별코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.DELNG_SECODE IS '거래_구분코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.TRSMRCV_AT IS '송수신_플래그';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.TRMNL_SE IS '단말기_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.RSPNS_CODE IS '응답_코드';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.PARTCPT_INSTT_ID IS '참가_기관_ID';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.INSTT_SPCLTY_MANAGENO IS '기관_전문_관리번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.INSTT_SPCLTY_TRNSMISTIME IS '기관_전문_전송시간';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.NICE_SPCLTY_MANAGENO IS 'NICE_전문_관리번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.NICE_SPCLTY_TRNSMISTIME IS 'NICE_전문_전송시간';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.BLNK IS '공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.RSPNS_CO IS '응답_건수';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.SMS_SNDNG_REQUST_SE IS 'SMS_발송_요청_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.SNDNG_MSSAGE IS '발송_메시지';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.DSPTCH_NO IS '발신_번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.CTTPC_INQIRE_SE IS '연락처_조회_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.INDVDLZ_RSPNS_BLNK IS '개별_응답_공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.INDVDL_BSNM_CPR_SE IS '개인_사업자_법인_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.IHIDNUM IS '주민번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.NM IS '성명';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.RANK_CTTPC_1 IS '1_순위_연락처';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.RANK_CTTPC_2 IS '2_순위_연락처';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.RANK_CTTPC_3 IS '3_순위_연락처';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.RESULT_SE IS '결과_구분';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.SMS_SNDNG_CTTPC_RANK IS 'SMS_발송_연락처_순위';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.SMS_SNDNG_CTTPC_NO IS 'SMS_발송_연락처_번호';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.SMS_SNDNG_DT IS 'SMS_발송_일시';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.RSPNS_REPTIT_BLNK IS '응답_반복_공란';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.CREAT_DT IS '생성_일시';
 COMMENT ON COLUMN TB_NICE_SMS_SNDNG_RSPNS.CRTR IS '생성자';

CREATE SEQUENCE SEQ_NICE_SMS_SNDNG_REQUST_ID START WITH 1 INCREMENT BY 1 MAXVALUE 9999999999 MINVALUE 1 NOCYCLE;

CREATE SEQUENCE SEQ_NICE_SMS_SNDNG_INQIRE_ID START WITH 1 INCREMENT BY 1 MAXVALUE 9999999999 MINVALUE 1 NOCYCLE;


-- 나이스 알림톡 템플릿 코드 컬럼 추가
ALTER TABLE ENS_TMPLT_MNG ADD NTCNTALK_TMPLAT_CODE     VARCHAR2(100);
