/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest(平台_业务)\pdm\TPO_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_ASSIST_L' AND KSQL_COL_NAME IN ('FNAME')) 
 ALTER TABLE T_TPO_TCVAT_ASSIST_L ADD (FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_TPO_TCVAT_ASSIST_L', 'FNANE', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_BIZDEF_L' AND KSQL_COL_NAME IN ('FNAME')) 
 ALTER TABLE T_TPO_TCVAT_BIZDEF_L ADD (FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_TPO_TCVAT_BIZDEF_L', 'FNANE', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_ASSIST_TREE_L' AND KSQL_COL_NAME IN ('FNAME')) 
 ALTER TABLE T_TPO_TCVAT_ASSIST_TREE_L ADD (FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_TPO_TCVAT_ASSIST_TREE_L', 'FNANE', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_BIZDEF_TREE_L' AND KSQL_COL_NAME IN ('FNAME')) 
 ALTER TABLE T_TPO_TCVAT_BIZDEF_TREE_L ADD (FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_TPO_TCVAT_BIZDEF_TREE_L', 'FNANE', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_ASSIST' AND KSQL_COL_NAME IN ('FSTATUS')) 
 ALTER TABLE T_TPO_TCVAT_ASSIST ADD (FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_ASSIST' AND KSQL_COL_NAME IN ('FCREATORID')) 
 ALTER TABLE T_TPO_TCVAT_ASSIST ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_ASSIST' AND KSQL_COL_NAME IN ('FENABLE')) 
 ALTER TABLE T_TPO_TCVAT_ASSIST ADD (FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_ASSIST' AND KSQL_COL_NAME IN ('FCREATETIME')) 
 ALTER TABLE T_TPO_TCVAT_ASSIST ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_ASSIST' AND KSQL_COL_NAME IN ('FMASTERID')) 
 ALTER TABLE T_TPO_TCVAT_ASSIST ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_BIZDEF' AND KSQL_COL_NAME IN ('FSTATUS')) 
 ALTER TABLE T_TPO_TCVAT_BIZDEF ADD (FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_BIZDEF' AND KSQL_COL_NAME IN ('FCREATORID')) 
 ALTER TABLE T_TPO_TCVAT_BIZDEF ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_BIZDEF' AND KSQL_COL_NAME IN ('FENABLE')) 
 ALTER TABLE T_TPO_TCVAT_BIZDEF ADD (FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_BIZDEF' AND KSQL_COL_NAME IN ('FCREATETIME')) 
 ALTER TABLE T_TPO_TCVAT_BIZDEF ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TCVAT_BIZDEF' AND KSQL_COL_NAME IN ('FMASTERID')) 
 ALTER TABLE T_TPO_TCVAT_BIZDEF ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME IN ('FSTATUS')) 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME IN ('FCREATORID')) 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME IN ('FMODIFIERID')) 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME IN ('FENABLE')) 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME IN ('FCREATETIME')) 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME IN ('FMODIFYTIME')) 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME IN ('FMASTERID')) 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATEENTRY' AND KSQL_COL_NAME IN ('FMERGECODE')) 
 ALTER TABLE T_TPO_TAXITEMRATEENTRY ADD (FMERGECODE VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATEENTRY' AND KSQL_COL_NAME IN ('FSTATUS')) 
 ALTER TABLE T_TPO_TAXITEMRATEENTRY ADD (FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATEENTRY' AND KSQL_COL_NAME IN ('FLONGNUMBER')) 
 ALTER TABLE T_TPO_TAXITEMRATEENTRY ADD (FLONGNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATEENTRY' AND KSQL_COL_NAME IN ('FPARENTID')) 
 ALTER TABLE T_TPO_TAXITEMRATEENTRY ADD (FPARENTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE_L' AND KSQL_COL_NAME IN ('FNAME')) 
 ALTER TABLE T_TPO_TAXITEMRATE_L ADD (FNAME VARCHAR(100) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_TPO_TAXITEMRATE_L', 'FNANE', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATEENTRY_L' AND KSQL_COL_NAME IN ('FNAME')) 
 ALTER TABLE T_TPO_TAXITEMRATEENTRY_L ADD (FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATEENTRY_L' AND KSQL_COL_NAME IN ('FFULLNAME')) 
 ALTER TABLE T_TPO_TAXITEMRATEENTRY_L ADD (FFULLNAME VARCHAR(100) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_TPO_TAXITEMRATEENTRY_L', 'FNANE', 'NULL', 'NULL', '1001', 'NULL';

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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TPO_TCVAT_DATATYPE') 
 CREATE TABLE T_TPO_TCVAT_DATATYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FTABLETYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TPO_TCVAT_CODE_TREE') 
 CREATE TABLE T_TPO_TCVAT_CODE_TREE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FLONGNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
FLEVEL BIGINT DEFAULT 0 NOT NULL,
FISLEAF CHAR(1) DEFAULT ' ' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL
);



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest(平台_业务)\pdm\TPO_table.sql **/
