/**Begin E:\PDM\PDM1\SYS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CTS_ADDRESSMOVECONFIG') 
 CREATE TABLE T_CTS_ADDRESSMOVECONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBILLKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FDETAILADDRESSKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FADMINDIVISIONKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FADDRESSKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FSYNCSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CTS_ADVANCEADDRESS') 
 CREATE TABLE T_CTS_ADVANCEADDRESS (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENABLEFEATURE CHAR(1) DEFAULT '0' NOT NULL,
FENABLEMAP CHAR(1) DEFAULT '0' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(1) DEFAULT 'C' NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME
);


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

/**End E:\PDM\PDM1\SYS_table.sql **/

 EXEC P_ALTERPK 'PK_T_CTS_ADDRESSMOVECONFIG', 'T_CTS_ADDRESSMOVECONFIG', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_CTS_ADVANCEADDRESS', 'T_CTS_ADVANCEADDRESS', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CTS_AA_FNUMBER') CREATE INDEX IDX_CTS_AA_FNUMBER ON T_CTS_ADVANCEADDRESS ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_CTS_ADVANCEADDRESS_L', 'T_CTS_ADVANCEADDRESS_L', 'FPKID', '1';

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

/**End E:\PDM\PDM1\SYS_constraint.sql **/

