
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_LOG_BOTP_LK')
 CREATE TABLE T_LOG_BOTP_LK (
FID BIGINT NOT NULL,
FUSERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOPNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOPDESC NVARCHAR(200) DEFAULT ' ' NOT NULL,
FOPDATE DATETIME,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FOPTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSENTITYNUMBER NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSBILLNO NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL,
FTTABLEID BIGINT DEFAULT 0 NOT NULL,
FTENTITYNUMBER NVARCHAR(200) DEFAULT ' ' NOT NULL,
FTBILLNO NVARCHAR(200) DEFAULT ' ' NOT NULL,
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTID BIGINT DEFAULT 0 NOT NULL,
FLOGTYPE NVARCHAR(10) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_T_LOG_BOTP_LK', 'T_LOG_BOTP_LK', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_BOTP_LK_FSBILLNO') CREATE INDEX IDX_T_LOG_BOTP_LK_FSBILLNO ON T_LOG_BOTP_LK ( FSBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_BOTP_LK_FTBILLNO') CREATE INDEX IDX_T_LOG_BOTP_LK_FTBILLNO ON T_LOG_BOTP_LK ( FTBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_BOTP_LK_FSBILLID') CREATE INDEX IDX_T_LOG_BOTP_LK_FSBILLID ON T_LOG_BOTP_LK ( FSBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_BOTP_LK_FTBILLID') CREATE INDEX IDX_T_LOG_BOTP_LK_FTBILLID ON T_LOG_BOTP_LK ( FTBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_LOG_BOTP_LK_OPTTIME') CREATE INDEX IDX_T_LOG_BOTP_LK_OPTTIME ON T_LOG_BOTP_LK ( FOPDATE );
