/**BEGIN E:\NEXTERP_PDM\PDM_UPGRADE\PDMS\BRANCH_LASTEST\PDM\EB_TABLE.SQL **/

-- 维度成员引用关系表
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MEMBERQUOTE') 
CREATE TABLE T_EB_MEMBERQUOTE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FMEMBERID BIGINT DEFAULT 0 NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FSTATUS CHAR(1) DEFAULT '1' NOT NULL
);


-- 引用关系分录表
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MEMBERQUOTEENTRY') 
CREATE TABLE T_EB_MEMBERQUOTEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FQUOTEID BIGINT DEFAULT 0 NOT NULL,
FSOURCEID BIGINT DEFAULT 0 NOT NULL,
FSOURCETYPE INT NOT NULL DEFAULT 0
);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_MEMBERQUOTEENTRY' AND KSQL_COL_NAME ='FSOURCETYPE') 
ALTER TABLE T_EB_MEMBERQUOTEENTRY ADD (FSOURCETYPE INT NOT NULL DEFAULT 0);


-- 主键索引
EXEC P_ALTERPK 'PK_T_EB_MEMBERQUOTE', 'T_EB_MEMBERQUOTE', 'FID', '1';
EXEC P_ALTERPK 'PK_T_EB_MEMBERQUOTEENTRY', 'T_EB_MEMBERQUOTEENTRY', 'FID', '1';


/**END E:\NEXTERP_PDM\PDM_UPGRADE\PDMS\BRANCH_LASTEST\PDM\EB_TABLE.SQL **/