Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
In Oracle 12c Oracle added the ability to create a numeric identity column that adds incrementing numbers automatically. In other words they added the AUTO_INCREMENT functionality without having to explicitly create a sequence first.
Example syntax:
CREATE TABLE regions |
(
|
region_id NUMBER GENERATED BY DEFAULT AS IDENTITY |
START WITH 5 PRIMARY KEY, |
region_name VARCHAR2( 50 ) NOT NULL |
);
|
However, if that code is executed as is in MariaDB with Oracle mode on you get the following error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BY DEFAULT AS IDENTITY
|
START WITH 5 PRIMARY KEY,
|
region_name VARCHAR2( ...' at line 3
|
For now to maintain the same functionality as the Oracle syntax above, the create table would need to be modified to the below code snippet:
CREATE TABLE regions |
(
|
region_id NUMBER PRIMARY KEY AUTO_INCREMENT, |
region_name VARCHAR2( 50 ) NOT NULL |
) AUTO_INCREMENT = 5;
|
Let's add the identity column syntax to Oracle mode to so we can minimize schema code rewrites.
It appears that behind the scenes Oracle is still making a sequence, but doesn't require explicitly creating it ahead of time. For more details view https://oracle-base.com/articles/12c/identity-columns-in-oracle-12cr1.