how to insert a auto_increment value in oracle code example
Example 1: oracle auto_increment
CREATE SEQUENCE id_seq START WITH 1;
INSERT INTO my_table (ID, VALUE) VALUES (id_seq.NEXTVAL, 'My value');
Example 2: 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 |
+