/**Begin E:\PDM_UPGRADE\PDM1\SYS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CTS_ADDRCONFIGCOUNTRY') 
 CREATE TABLE T_CTS_ADDRCONFIGCOUNTRY (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CTS_ADDRCONFIGFORMAT') 
 CREATE TABLE T_CTS_ADDRCONFIGFORMAT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FPRECONFIGID BIGINT DEFAULT 0 NOT NULL,
FISINCLUDE CHAR(1) DEFAULT ' ' NOT NULL,
FISNEWLINE CHAR(1) DEFAULT ' ' NOT NULL,
FREPLACEATTR BIGINT DEFAULT 0 NOT NULL,
FPREFIX NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUFFIX NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CTS_ADDRCONFIGSTRUCT') 
 CREATE TABLE T_CTS_ADDRCONFIGSTRUCT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FPRECONFIGID BIGINT DEFAULT 0 NOT NULL,
FISSHOW CHAR(1) DEFAULT ' ' NOT NULL,
FISNEWLINE CHAR(1) DEFAULT ' ' NOT NULL,
FUSERDEFINETAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
FLENGTHSPEC VARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CTS_ADDRPRECONFIG') 
 CREATE TABLE T_CTS_ADDRPRECONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
FBASETYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FADMINLEVEL SMALLINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CTS_ADDRPROPALIAS') 
 CREATE TABLE T_CTS_ADDRPROPALIAS (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FTYPE VARCHAR(50) DEFAULT ' ' NOT NULL
);

 


 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CTS_ADDRCONFIGFORMAT' AND KSQL_COL_NAME ='FSEQ') 
 ALTER TABLE T_CTS_ADDRCONFIGFORMAT ADD (FSEQ SMALLINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CTS_ADDRCONFIGSTRUCT' AND KSQL_COL_NAME ='FSEQ') 
 ALTER TABLE T_CTS_ADDRCONFIGSTRUCT ADD (FSEQ SMALLINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CTS_ADDRCONFIGSTRUCT' AND KSQL_COL_NAME ='FISREQUIRED') 
 ALTER TABLE T_CTS_ADDRCONFIGSTRUCT ADD (FISREQUIRED CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CTS_ADDRPRECONFIG' AND KSQL_COL_NAME ='FSEQ') 
 ALTER TABLE T_CTS_ADDRPRECONFIG ADD (FSEQ SMALLINT DEFAULT 0 NOT NULL );

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