/**Begin D:\PDM_UPGRADE\PDM1\HAOS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINORG' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_ADMINORG ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINORG' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_ADMINORG ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINORG' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_ADMINORG ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINORG' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_ADMINORG ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINORG' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_ADMINORG ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_DEPARTMENT' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_DEPARTMENT ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_DEPARTMENT' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_DEPARTMENT ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_DEPARTMENT' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_DEPARTMENT ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_DEPARTMENT' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_DEPARTMENT ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_DEPARTMENT' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_DEPARTMENT ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_GROUP' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_GROUP ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_GROUP' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_GROUP ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_GROUP' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_GROUP ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_GROUP' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_GROUP ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_GROUP' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_GROUP ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_COMPANY' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_COMPANY ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_COMPANY' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_COMPANY ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_COMPANY' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_COMPANY ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_COMPANY' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_COMPANY ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_COMPANY' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_COMPANY ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINSTRUCT' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_ADMINSTRUCT ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINSTRUCT' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_ADMINSTRUCT ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINSTRUCT' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_ADMINSTRUCT ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINSTRUCT' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_ADMINSTRUCT ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINSTRUCT' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_ADMINSTRUCT ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGSORTCODE' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_ORGSORTCODE ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGSORTCODE' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_ORGSORTCODE ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGSORTCODE' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_ORGSORTCODE ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGSORTCODE' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_ORGSORTCODE ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGSORTCODE' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_ORGSORTCODE ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGBUSINESSFILE' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_ORGBUSINESSFILE ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGBUSINESSFILE' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_ORGBUSINESSFILE ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGBUSINESSFILE' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_ORGBUSINESSFILE ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGBUSINESSFILE' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_ORGBUSINESSFILE ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGBUSINESSFILE' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_ORGBUSINESSFILE ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_PROJTEAMSTRUCT' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_PROJTEAMSTRUCT ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_PROJTEAMSTRUCT' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_PROJTEAMSTRUCT ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_PROJTEAMBASE' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_PROJTEAMBASE ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_PROJTEAMBASE' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_PROJTEAMBASE ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_PROJSORTCODE' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_PROJSORTCODE ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_PROJSORTCODE' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_PROJSORTCODE ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAM' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_ORGTEAM ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAM' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_ORGTEAM ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAM' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_ORGTEAM ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAM' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_ORGTEAM ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAM' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_ORGTEAM ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAMSTRUCT' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_ORGTEAMSTRUCT ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAMSTRUCT' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_ORGTEAMSTRUCT ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAMSTRUCT' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_ORGTEAMSTRUCT ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAMSTRUCT' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_ORGTEAMSTRUCT ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAMSTRUCT' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_ORGTEAMSTRUCT ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_TEAMCOOPREL' AND KSQL_COL_NAME IN ('FINITSTATUS')) 
 ALTER TABLE T_HAOS_TEAMCOOPREL ADD (FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_TEAMCOOPREL' AND KSQL_COL_NAME IN ('FINITDATASOURCE')) 
 ALTER TABLE T_HAOS_TEAMCOOPREL ADD (FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_TEAMCOOPREL' AND KSQL_COL_NAME IN ('FINITBATCH')) 
 ALTER TABLE T_HAOS_TEAMCOOPREL ADD (FINITBATCH BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_TEAMCOOPREL' AND KSQL_COL_NAME IN ('FHISVERSION')) 
 ALTER TABLE T_HAOS_TEAMCOOPREL ADD (FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_TEAMCOOPREL' AND KSQL_COL_NAME IN ('FCHANGEDESCRIPTION')) 
 ALTER TABLE T_HAOS_TEAMCOOPREL ADD (FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_CHANGESCENE') 
 CREATE TABLE T_HAOS_CHANGESCENE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOTCLASSIFYID BIGINT DEFAULT 0 NOT NULL,
FORGCHANGETYPEID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_CHANGEOPERAT') 
 CREATE TABLE T_HAOS_CHANGEOPERAT (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOTCLASSIFYID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_CHANGESCENESUB') 
 CREATE TABLE T_HAOS_CHANGESCENESUB (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOTCLASSIFYID BIGINT DEFAULT 0 NOT NULL
);


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


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_CHANGETRANSUM') 
 CREATE TABLE T_HAOS_CHANGETRANSUM (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FEVENTID BIGINT DEFAULT 0 NOT NULL,
FORGCHANGETYPEID BIGINT DEFAULT 0 NOT NULL,
FCHANGEDATE DATETIME,
FORGCHANGEREASONID BIGINT DEFAULT 0 NOT NULL,
FDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL,
FTARGETORGID BIGINT DEFAULT 0 NOT NULL,
FBEFOREORGID BIGINT DEFAULT 0 NOT NULL,
FAFTERORGID BIGINT DEFAULT 0 NOT NULL,
FOTCLASSIFYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_CHANGEOPERDETAIL') 
 CREATE TABLE T_HAOS_CHANGEOPERDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FEVENTID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCHANGEOPERATID BIGINT DEFAULT 0 NOT NULL,
FCHANGEDATE DATETIME,
FISTRUCTCHANGE CHAR(1) DEFAULT ' ' NOT NULL,
FISINFOCHANGE CHAR(1) DEFAULT ' ' NOT NULL,
FDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL,
FBEFOREORGID BIGINT DEFAULT 0 NOT NULL,
FAFTERORGID BIGINT DEFAULT 0 NOT NULL,
FOTCLASSIFYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_CHANGETRANDETAIL') 
 CREATE TABLE T_HAOS_CHANGETRANDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FEVENTID BIGINT DEFAULT 0 NOT NULL,
FSOURCEORGID BIGINT DEFAULT 0 NOT NULL,
FTARGETORGID BIGINT DEFAULT 0 NOT NULL,
FORGCHANGETYPEID BIGINT DEFAULT 0 NOT NULL,
FCHANGEDATE DATETIME,
FORGCHANGEREASONID BIGINT DEFAULT 0 NOT NULL,
FDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL,
FBEFOREORGID BIGINT DEFAULT 0 NOT NULL,
FAFTERORGID BIGINT DEFAULT 0 NOT NULL,
FOTCLASSIFYID BIGINT DEFAULT 0 NOT NULL
);


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


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


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



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