/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\CAD_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_COSTTYPE') 
create table T_CAD_COSTTYPE
( FID               BIGINT DEFAULT 0 NOT NULL,
  FNUMBER           NVARCHAR(60) DEFAULT ' ' NOT NULL,
  FSTATUS           NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FCREATORID        BIGINT DEFAULT 0 NOT NULL,
  FMODIFIERID       BIGINT DEFAULT 0 NOT NULL,
  FENABLE           NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FCREATETIME       DATETIME,
  FMODIFYTIME       DATETIME,
  FMASTERID         BIGINT DEFAULT 0 NOT NULL,
  FCREATEORGID      BIGINT DEFAULT 0 NOT NULL,
  FORGID            BIGINT DEFAULT 0 NOT NULL,
  FUORG             BIGINT DEFAULT 0 NOT NULL,
  FCTRLSTRATEGY     NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FTYPE             NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FRADIOGROUPFIELD  NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FRADIOGROUPFIELD1 NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FRADIOGROUPFIELD2 NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FISUPDATE        CHAR(1) DEFAULT '0' NOT NULL,
  FSUPATTR          CHAR(1) DEFAULT '0' NOT NULL,
  FISSYSTEM         CHAR(1) DEFAULT '0' NOT NULL,
  FCURRENCYID       BIGINT DEFAULT 0 NOT NULL,
  FELEMENTTYPEID    BIGINT DEFAULT 0 NOT NULL,
  FEXPIRATIONDATETIME   DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_COSTTYPE_L') 
 create table T_CAD_COSTTYPE_L
(
  FPKID     NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FID       BIGINT DEFAULT 0 NOT NULL,
  FLOCALEID NVARCHAR(10) NOT NULL,
  FNAME     NVARCHAR(100) DEFAULT ' ' NOT NULL,
  FREMARK   NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_ELEMENT') 
 create table T_CAD_ELEMENT
(
  FID            BIGINT DEFAULT 0 NOT NULL,
  FNUMBER        NVARCHAR(60) DEFAULT ' ' NOT NULL,
  FSTATUS        NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FCREATORID     BIGINT DEFAULT 0 NOT NULL,
  FMODIFIERID    BIGINT DEFAULT 0 NOT NULL,
  FENABLE        NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FCREATETIME    DATETIME,
  FMODIFYTIME    DATETIME,
  FMASTERID      BIGINT DEFAULT 0 NOT NULL,
  FTYPE          NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FISSYSTEM      CHAR(1) DEFAULT '0' NOT NULL,
  FELEMENTTYPEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_ELEMENTDETAIL') 
 create table T_CAD_ELEMENTDETAIL
(
  FID            BIGINT DEFAULT 0 NOT NULL,
  FELEMENTID     BIGINT DEFAULT 0 NOT NULL,
  FSUBELEMENTID  BIGINT DEFAULT 0 NOT NULL,
  FELEMENTTYPEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_ELEMENTTYPE') 
 create table T_CAD_ELEMENTTYPE
(
  FID            BIGINT DEFAULT 0 NOT NULL,
  FNUMBER        NVARCHAR(60) DEFAULT ' ' NOT NULL,
  FSTATUS        NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FCREATORID     BIGINT DEFAULT 0 NOT NULL,
  FMODIFIERID    BIGINT DEFAULT 0 NOT NULL,
  FENABLE        NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FCREATETIME    DATETIME,
  FMODIFYTIME    DATETIME,
  FMASTERID      BIGINT DEFAULT 0 NOT NULL,
  FMATERIELFIELD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_ELEMENTTYPE_L') 
 create table T_CAD_ELEMENTTYPE_L
(
  FPKID        NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FID          BIGINT DEFAULT 0 NOT NULL,
  FLOCALEID    NVARCHAR(100) DEFAULT ' ' NOT NULL,
  FNAME        NVARCHAR(100) DEFAULT ' ' NOT NULL,
  FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_ELEMENT_L') 
 create table T_CAD_ELEMENT_L
(
  FPKID     NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FID       BIGINT DEFAULT 0 NOT NULL,
  FLOCALEID NVARCHAR(100) DEFAULT ' ' NOT NULL,
  FNAME     NVARCHAR(100) DEFAULT ' ' NOT NULL,
  FREMARKS  NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_SUBELEMENT') 
 create table T_CAD_SUBELEMENT
(
  FID            BIGINT DEFAULT 0 NOT NULL,
  FNUMBER        NVARCHAR(60) DEFAULT ' ' NOT NULL,
  FSTATUS        NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FCREATORID     BIGINT DEFAULT 0 NOT NULL,
  FMODIFIERID    BIGINT DEFAULT 0 NOT NULL,
  FENABLE        NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FCREATETIME    DATETIME,
  FMODIFYTIME    DATETIME,
  FMASTERID      BIGINT DEFAULT 0 NOT NULL,
  FTYPE          NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FISSYSTEM       CHAR(1) DEFAULT '0' NOT NULL,
  FDEFAULTVALUE  CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAD_SUBELEMENT_L') 
 create table T_CAD_SUBELEMENT_L
(
  FPKID     NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FID       BIGINT DEFAULT 0 NOT NULL,
  FLOCALEID NVARCHAR(100) DEFAULT ' ' NOT NULL,
  FNAME     NVARCHAR(100) DEFAULT ' ' NOT NULL,
  FREMARKS  NVARCHAR(255) DEFAULT ' ' NOT NULL
);

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_table.sql **/
