【问题标题】:I got error on column with identity(1,1)?我在标识列上出现错误(1,1)?
【发布时间】:2019-06-27 05:06:10
【问题描述】:

Sql 开发者报错:

ORA-00907:缺少右括号,用于下一个表:

create table customer (
    CUSTOMER_ID number identity (1,1) not null,
    CUSTOMER_PHONE char(13) not null
);

还有'身份是红色下划线的,不知道为什么

【问题讨论】:

    标签: sql oracle


    【解决方案1】:

    Oracle 12c 及更高版本的正确语法:

    create table customer ( 
      CUSTOMER_ID NUMBER GENERATED ALWAYS AS IDENTITY,
      CUSTOMER_PHONE char(13) not null 
    );
    
    -- explicit start and increment
    create table customer ( 
      CUSTOMER_ID  NUMBER GENERATED ALWAYS AS IDENTITY(START WITH 1 INCREMENT BY 1),
      CUSTOMER_PHONE char(13) not null 
    );
    

    db<>fiddle demo

    【讨论】:

    • 这很奇怪,我在谷歌上寻找答案,而大部分回复来自我的代码。谢谢你,卢卡斯
    • @don'tknownthing 您发布的语法适用于 Microsoft SQL Server 或 Sybase。
    • 哦,我的.. 这就是为什么我是 SQL 新手 :)))
    • @don'tknownthing 不用担心 :) 大家都是从零开始
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多