Java SQL 错误:ORA-02000:创建基于标识列的表时缺少 ALWAYS 关键字
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28806412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL Error: ORA-02000: missing ALWAYS keyword when create identity column based table
提问by aurelius
I try to create an auto incremented column on a table and as I see in this postthere are 2 ways, the second implementation with the Identity column is a more elegant solution, but when I try to implement it I get the following error:
我尝试在表上创建一个自动递增的列,正如我在这篇文章中看到的,有两种方法,使用 Identity 列的第二个实现是一个更优雅的解决方案,但是当我尝试实现它时,我收到以下错误:
Error at Command Line : 3 Column : 31
Error report -
SQL Error: ORA-02000: missing ALWAYS keyword
02000. 00000 - "missing %s keyword"
Actual table script implementation:
实际表脚本实现:
CREATE TABLE "PLATFORM"."AUTH_PERMISSION"
(
ID NUMBER(19,0) GENERATED BY DEFAULT ON NULL AS IDENTITY,
-- ID NUMBER(19,0) PRIMARY KEY NOT NULL,
NAME VARCHAR2(50) UNIQUE NOT NULL,
ACTION_ID NUMBER(19,0) NOT NULL,
RESOURCE_ID NUMBER(19,0) NOT NULL,
ENVIRONMENT_ID NUMBER(19,0) NOT NULL,
CONSTRAINT "ACTION_ID" FOREIGN KEY ("ACTION_ID")
REFERENCES "AUTH_ACTION" ("ID") ENABLE,
CONSTRAINT "ENVIRONMENT_ID" FOREIGN KEY ("ENVIRONMENT_ID")
REFERENCES "AUTH_ENVIRONMENT" ("ID") ENABLE,
CONSTRAINT "RESOURCE_ID" FOREIGN KEY ("RESOURCE_ID")
REFERENCES "AUTH_RESOURCE" ("ID") ENABLE,
UNIQUE (ACTION_ID, ENVIRONMENT_ID, RESOURCE_ID)
);
It can bee seen that the column that I try to auto-increment is the primary key of the table.
可以看出,我尝试自动递增的列是表的主键。
Thisis the reference from where I got the solution.
这是我得到解决方案的参考。
The problem was that I used an older version of Oracle, 11g.
问题是我使用了旧版本的 Oracle,11g。
采纳答案by Lalit Kumar B
Perhaps the Oracle database (server)you are trying to connect to is 12c, however the client (installed locally)you are using doesn't support the feature. Please check your Oracle client version, it could be 11g or lowerwhich doesn't support it. You need to download a higher client version.
也许您尝试连接的 Oracle 数据库(服务器)是12c,但是您使用的客户端(本地安装)不支持该功能。请检查您的Oracle 客户端版本,它可能是不支持它的11g 或更低版本。您需要下载更高的客户端版本。
Works perfectly on version 12.1.0.1.
在版本12.1.0.1上完美运行。
SQL> select banner from v$version where rownum = 1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
SQL> CREATE TABLE AUTH_PERMISSION
2 (
3 ID NUMBER(19,0) GENERATED BY DEFAULT ON NULL AS IDENTITY,
4 -- ID NUMBER(19,0) PRIMARY KEY NOT NULL,
5 NAME VARCHAR2(50) UNIQUE NOT NULL,
6 ACTION_ID NUMBER(19,0) NOT NULL,
7 RESOURCE_ID NUMBER(19,0) NOT NULL,
8 ENVIRONMENT_ID NUMBER(19,0) NOT NULL
9 );
Table created.