我这里有一个以mssql为数据库的程序,现在想转用mysql或pgsql,但以下语句要修改才行:Create Table LeaveClass1(
  LeaveId INT Identity(999,1) not null primary key,
  LeaveName VARCHAR(20) not null,
  MinUnit float not null default 1,
  Unit smallint not null default 0,
  RemaindProc smallint not null default 2,
  RemaindCount smallint not null default 1,
  ReportSymbol varchar(4) not null default '_',
  Deduct float not null default 0,
  LeaveType SMALLINT not null default 0,             
  Color int not null default 0,
  Classify SMALLINT not null default 0,              
  Calc text null)                                    
;
CREATE TABLE DEPARTMENTS (                                 
DEPTID INT IDENTITY(1,1) NOT NULL ,      
DEPTNAME VARCHAR (30) NULL ,             
SUPDEPTID INT NOT NULL DEFAULT 1,                      
        CONSTRAINT DEPTID PRIMARY KEY (DEPTID)
)
;

解决方案 »

  1.   


    -- Tb1
    Create Table LeaveClass1( 
    LeaveId INT auto_increment not null primary key, 
    LeaveName VARCHAR(20) not null, 
    MinUnit float not null default 1, 
    Unit smallint not null default 0, 
    RemaindProc smallint not null default 2, 
    RemaindCount smallint not null default 1, 
    ReportSymbol varchar(4) not null default '_', 
    Deduct float not null default 0, 
    LeaveType SMALLINT not null default 0, 
    Color int not null default 0, 
    Classify SMALLINT not null default 0, 
    Calc text null
    ) AUTO_INCREMENT=999;-- Tb2
    CREATE TABLE DEPARTMENTS ( 
    DEPTID INT AUTO_INCREMENT NOT NULL , 
    DEPTNAME VARCHAR (30) NULL , 
    SUPDEPTID INT NOT NULL DEFAULT 1, 
    PRIMARY KEY (DEPTID)
    ) AUTO_INCREMENT=1;
      

  2.   

    PostgreSQL:
    CREATE SEQUENCE "Tb1_Inr_Seq" MINVALUE 1 MAXVALUE 999;
    -- Tb1
    Create Table LeaveClass1( 
    LeaveId INT not null primary key DEFAULT NEXTVAL('"Tb1_Inr_Seq"'),
    LeaveName VARCHAR(20) not null, 
    MinUnit float not null default 1, 
    Unit smallint not null default 0, 
    RemaindProc smallint not null default 2, 
    RemaindCount smallint not null default 1, 
    ReportSymbol varchar(4) not null default '_', 
    Deduct float not null default 0, 
    LeaveType SMALLINT not null default 0, 
    Color int not null default 0, 
    Classify SMALLINT not null default 0, 
    Calc text null
    );-- Tb2
    CREATE SEQUENCE "Tb2_Inr_Seq" MINVALUE 1 MAXVALUE 999;
    CREATE TABLE DEPARTMENTS ( 
    DEPTID INT  NOT NULL DEFAULT NEXTVAL('"Tb2_Inr_Seq"'), 
    DEPTNAME VARCHAR (30) NULL , 
    SUPDEPTID INT NOT NULL DEFAULT 1, 
    PRIMARY KEY (DEPTID)
    );