IDENTITY column property allows you to automatically generate sequential integer numbers (IDs) for a column. IDENTITY columns are available since Oracle 12c.
In MariaDB you can use AUTO_INCREMENT column property. Note that you can use the AUTO_INCREMENT table property to define the start value, but you cannot specify the increment step, it is always 1.
Oracle - Quick Example:
-- Define a table with an IDENTITY column (id starts at 10) CREATE TABLE cities ( id INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 10), name VARCHAR(30) );
MariaDB - Quick Example:
-- Define a table with an IDENTITY column (id starts at 10) CREATE TABLE cities ( id INTEGER AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) ) AUTO_INCREMENT = 10;
Oracle - Syntax:
-- Simplified syntax GENERATED [ALWAYS | BY DEFAULT [ON NULL]] AS IDENTITY [(START WITH start INCREMENT BY inc ...)]
Conversion Overview:
Consider the following sample data:
Oracle:
CREATE TABLE cities ( id INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 10), name VARCHAR(30) ); -- Some test data INSERT INTO cities(name) VALUES ('Malaga'); INSERT INTO cities(name) VALUES ('Seville'); INSERT INTO cities(name) VALUES ('Madrid'); -- See the inserted data SELECT * FROM cities;
Result:
id | name |
10 | Malaga |
11 | Seville |
12 | Madrid |
For more information, see Oracle to MariaDB Migration.