[MDEV-29818] Add ability to handle Oracle Identity columns in ORACLE Mode Created: 2022-10-18  Updated: 2023-11-13

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Major
Reporter: Kyle Hutchinson Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: Compatibility, Oracle


 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.


Generated at Thu Feb 08 10:11:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.