在iSQL*PLUS中输入如下内容建表,该表参照的表都已经建好create table tb_fault_info
(
fid int identity(1,1) primary key,
fsim char(40) not null,
fdet char(600) not null,
company char(40) not null,
ftime datetime not null,
gid int foreign key references tb_group(gid), 
fsid int foreign key references tb_fault_state(fsid),
addf char(600),
fnum char(10) not null,
fc int not null
);出现如下问题:
fid int identity(1,1) primary key,
        *第 3 行出现错误: 
ORA-00907: 缺失右括号都改了一天了,希望各位朋友帮帮忙,我很着急   

解决方案 »

  1.   

    oracle有identity(1,1)这个概念吗?
    oracle中是用sequence实现的吧
      

  2.   

    Oracle使用序列,由于它更灵活机动
      

  3.   

    fid int identity(1,1) primary key
    ===================================
    sql server 的 identity 语法在 oracle 中不能用。
      

  4.   

    楼主的语法出错,identity函数是SQLSERVER中的
      

  5.   

    2个错误一在SQLSERVER中是可以用那实现自赠在ORACLE中序列加触发器实现一个自增字段
    还有约束问题外键
    不能在创建语句中建立
    建后
    ALTER TABLE 表名 ADD CONSTRAINT 外名 FOREIGN KEY(字段) REFERENCES tb_fault_state(fsid);就行了
      

  6.   

    除了identity 和 FOREIGN KEY
    oracle里时间类型应该是date不是datetime
      

  7.   

    oracle 是可以在建表时创建外键的
    不过需要注意:如果要在B表上引用A表的字段ID来创建一个外键,那么A表的ID上必须有主键(也就是说Id必须是A表的主码)
    还有就是LZ创建外键的写法也不对,ORACLE的语法和SQL大不相同的下面举个例子先创建两个备用表:
    create table tb_group(gid int,PRIMARY KEY(GID));--GID是主键 
    create table tb_fault_state(fsid int,PRIMARY KEY(fsid));--FSID是主键接下来创建LZ要创建的这张表:
    create table tb_fault_info

    GID INT not null,
    FSID INT not null,
    fsim char(40) not null, 
    fdet char(600) not null, 
    company char(40) not null, 
    ftime date not null, 
    addf char(600), 
    fnum char(10) not null, 
    fc int not null ,
    foreign key(GID)  references tb_group(gid), 
    foreign key (fsid) references tb_fault_state(fsid)
    ); 至于LZ要求的自增列,ORACLE是不能用IDENTITY的,可以用SEQUENCE
    由于oracle是序列型的,所以不是在建表的时候递增的,可以用以下方法:1、先创建一个SEQUENCE
       create sequence SEQ_D
       minvalue 1
       maxvalue 99999
       start with 21
       increment by 1
       cache 20;
    2、在向表插数据时插入自增列
       insert into tb_fault_info values(SEQ_D,'字段值',...)