/**Begin D:\PDM_UPGRADE\PDM1\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MAINSUBMODEL')
 CREATE TABLE T_EB_MAINSUBMODEL (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMAINMODEL BIGINT DEFAULT 0 NOT NULL,
FTEXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTARTFY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRESETYEAR INT DEFAULT 0 NOT NULL,
FBASEDATAFIELD BIGINT DEFAULT 0 NOT NULL,
FFOUNDWAY VARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FADMIN BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FPAGE NVARCHAR(50) DEFAULT ' ' NOT NULL
);

EXEC P_ALTERPK 'PK_T_EB_MAINSUBMODEL', 'T_EB_MAINSUBMODEL', 'FID', '1';


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MAINSUBMODEL_RELE')
 CREATE TABLE T_EB_MAINSUBMODEL_RELE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRELETYPE NVARCHAR(100) DEFAULT ' ' NOT NULL,
FRELEDATAID BIGINT DEFAULT 0 NOT NULL
);

EXEC P_ALTERPK 'PK_T_EB_MAINSUBMODEL_RELE', 'T_EB_MAINSUBMODEL_RELE', 'FENTRYID', '1';


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MAINSUBMODEL_L')
CREATE TABLE T_EB_MAINSUBMODEL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FTEXT NVARCHAR(255) DEFAULT ' ' NOT NULL
);

EXEC P_ALTERPK 'PK_T_EB_MAINSUBMODEL_L', 'T_EB_MAINSUBMODEL_L', 'FPKID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_MAINSUBMODEL_L')
CREATE INDEX IDX_EB_MAINSUBMODEL_L ON T_EB_MAINSUBMODEL_L ( FID, FLOCALEID );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MAINSUBMODEL_BIZMODE')
CREATE TABLE T_EB_MAINSUBMODEL_BIZMODE (
    FPKID BIGINT DEFAULT 0 NOT NULL,
    FID BIGINT DEFAULT 0 NOT NULL,
    FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
EXEC P_ALTERPK 'PK_T_EB_MAINSUBMODEL_BIZMODE', 'T_EB_MAINSUBMODEL_BIZMODE', 'FPKID', '1';

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