/**Begin D:\PDM_UPGRADE\PDM1\EB_constraint.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_WHITELIST') 
CREATE TABLE T_EB_WHITELIST (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FBUSMODELID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FUSEEXTBIZ CHAR(1) DEFAULT '1' NOT NULL
);

EXEC P_ALTERPK 'PK_BGC_WHITELIST', 'T_EB_WHITELIST', 'FID', '1';


IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BGC_WHITELIST_MBS') 
CREATE INDEX IDX_BGC_WHITELIST_MBS ON T_EB_WHITELIST ( FMODELID, FBUSMODELID, FSTATUS);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_WHITELIST_L') 
CREATE TABLE T_EB_WHITELIST_L (
FPKID NVARCHAR(20) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_WHITEENTRY') 
CREATE TABLE T_EB_WHITEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBIZTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZID BIGINT DEFAULT 0 NOT NULL,
FEXTBIZTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXTBIZNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXTBIZNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXTBIZID BIGINT DEFAULT 0 NOT NULL,
FENTRYSTATUS CHAR(1) DEFAULT '1' NOT NULL
);

EXEC P_ALTERPK 'PK_BGC_WHITEENTRY', 'T_EB_WHITEENTRY', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BGC_WHITEENTRY') 
CREATE INDEX IDX_BGC_WHITEENTRY ON T_EB_WHITEENTRY ( FID);

 
/**End D:\PDM_UPGRADE\PDM1\EB_constraint.sql **/