generate id oracle code example
Example 1: oracle create auto increment column
CREATE TABLE animals (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO animals (name) VALUES
('dog'),('cat'),('penguin'),
('lax'),('whale'),('ostrich');
SELECT * FROM animals;
+
| id | name |
+
| 1 | dog |
| 2 | cat |
| 3 | penguin |
| 4 | lax |
| 5 | whale |
| 6 | ostrich |
+
Example 2: pl sql create table identity column
Copy
sql-> CREATE Table sg_atts (
id INTEGER GENERATED ALWAYS AS IDENTITY
(START WITH 2
INCREMENT BY 2
MAXVALUE 200
NO CYCLE),
name STRING,
PRIMARY KEY (id));
Statement completed successfully
sql->