CREATE TABLE Deparment(
[id] [int] IDENTITY(1,1) NOT NULL,
[businessid] [int] NULL,
[communicateid] [int] NULL,
[time] [datetime] NULL,
         [title] [varchar](300),
         [contents] [text],
CONSTRAINT [PK_Deparment] PRIMARY KEY CLUSTERED 
(
[id] ASC
)就是id为主键,自动增长;
text,varchar(300),varchar(max),datetime等在oracale对应为什么?多谢!

解决方案 »

  1.   

    text -> long or clobvarchar(300) -> varchar2(300)varchar(max)-> varchar2(4000)datetime -> date
      

  2.   

    create table department(
    id number(10) primary key not null,businessid number(10),datetime date,time varchar2(300),contents varchar2(10000))
    create sequence dep_seq increment by 1 start with 1
      

  3.   

    就是id为主键,自动增长;
    用SEQUENCE实现,或者用表触发器,
    表触发器可以参考我的BLOG
    http://blog.csdn.net/java3344520/archive/2009/11/30/4907591.aspx
      

  4.   


    学习了,原来text还可以用long,我一直用clob,奢侈了呀
      

  5.   

    long不推荐使用了,使用clob吧,oracle保留只为了兼容。
    oracle自动增长比较麻烦一点,需要建一个序列,并在插入数据中引用此序列(也可在触发器中引用)1、创建表
    CREATE TABLE Deparment
    (
       id              number primary key,
       businessid      number,
       communicateid   number,
       time            date,
       title           varchar2 (300),
       contents        varchar2 (4000)
    );
    --contents如果不超过4000,最好用varchar2吧,如果超过,可用clob
    2、创建序列
    create sequence seq_id start with 1 increment by 1;
    3、插入数据
    INSERT INTO Deparment
      (id, businessid, communicateid, TIME, title, contents)
    VALUES
      (seq_id.nextval, 1, 1, SYSDATE, 'test', 'hello world!');