


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BOS_REPORT_RECORD')
 CREATE TABLE T_BOS_REPORT_RECORD (
 FID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE() NOT NULL,
FMODIFYTIME DATETIME,
FMOUDLEKEY VARCHAR(100) DEFAULT ' ' NOT NULL,
FUNIQUEKEY VARCHAR(200) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(36) DEFAULT ' ' NOT NULL,
FURL VARCHAR(500),
FURLTEMP VARCHAR(500)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BOS_REPORT_REGISTCENTER')
 CREATE TABLE T_BOS_REPORT_REGISTCENTER (
 FID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE() NOT NULL,
FMODIFYTIME DATETIME,
FMOUDLENAME VARCHAR(200) DEFAULT ' ' NOT NULL,
FCALLBACKPLUGIN VARCHAR(200),
FOVERTIME BIGINT DEFAULT 0 NOT NULL,
FMOUDLEKEY VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BOTP_CONVERT_WATCH')
 CREATE TABLE T_BOTP_CONVERT_WATCH (
 FID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE() NOT NULL,
FMODIFYTIME DATETIME,
FMOUDLEKEY VARCHAR(100) DEFAULT ' ' NOT NULL,
FUNIQUEKEY VARCHAR(200) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(36) DEFAULT ' ' NOT NULL,
FURL VARCHAR(500),
FSENTITYNUMBER VARCHAR(150) DEFAULT ' ' NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSBILLNO VARCHAR(500) DEFAULT ' ' NOT NULL,
FTENTITYNUMBER VARCHAR(150),
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTBILLNO VARCHAR(500) DEFAULT ' ' NOT NULL,
FTASKID BIGINT DEFAULT 0 NOT NULL,
FCONVERTRULEID BIGINT DEFAULT 0 NOT NULL,
FTRACEID VARCHAR(150) DEFAULT ' ' NOT NULL,
FDESC VARCHAR(500)
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BOTP_WRITEBACK_WATCH')
 CREATE TABLE T_BOTP_WRITEBACK_WATCH (
 FID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE() NOT NULL,
FMODIFYTIME DATETIME,
FMOUDLEKEY VARCHAR(100) DEFAULT ' ' NOT NULL,
FUNIQUEKEY VARCHAR(200) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(36) DEFAULT ' ' NOT NULL,
FURL VARCHAR(500),
FSENTITYNUMBER VARCHAR(150) DEFAULT ' ' NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSBILLNO VARCHAR(500) DEFAULT ' ' NOT NULL,
FTENTITYNUMBER VARCHAR(150),
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTBILLNO VARCHAR(500) DEFAULT ' ' NOT NULL,
FTASKID BIGINT DEFAULT 0 NOT NULL,
FTRACEID VARCHAR(150) DEFAULT ' ' NOT NULL,
FDESC VARCHAR(500)
);

 EXEC P_ALTERPK 'PK_T_BOS_REPORT_RECORD', 'T_BOS_REPORT_RECORD', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BOS_REPORT_RECORD_MU') CREATE UNIQUE INDEX IDX_BOS_REPORT_RECORD_MU ON T_BOS_REPORT_RECORD ( FMOUDLEKEY ,FUNIQUEKEY );


 EXEC P_ALTERPK 'PK_T_BOS_REPORT_REGISTCENTER', 'T_BOS_REPORT_REGISTCENTER', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BOS_REPORT_REGISTCENTER_M') CREATE INDEX IDX_BOS_REPORT_REGISTCENTER_M ON T_BOS_REPORT_REGISTCENTER ( FMOUDLEKEY );


 EXEC P_ALTERPK 'PK_T_BOTP_CONVERT_WATCH', 'T_BOTP_CONVERT_WATCH', 'FID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BOTP_CONVERT_WATCH_TRACEID') CREATE INDEX IDX_BOTP_CONVERT_WATCH_TRACEID ON T_BOTP_CONVERT_WATCH ( FTRACEID );

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

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

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

EXEC P_ALTERPK 'PK_T_BOTP_WRITEBACK_WATCH', 'T_BOTP_WRITEBACK_WATCH', 'FID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BOTP_BF_WATCH_TRACEID') CREATE INDEX IDX_BOTP_BF_WATCH_TRACEID ON T_BOTP_WRITEBACK_WATCH ( FTRACEID );

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

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

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

