Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement the concept of auto-increment in Oracle?

I would like to add AUTO_INCREMENT to my field called as the id. But when I apply the following logic to write a query as follows:

CREATE Table address_book (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name varchar(40),
phoneNumber varchar2(11),
houseNumber varchar2(11),
roadName varchar2(40),
cityTown varchar2(40),
postcode varchar2(10));

I get the following error:

ORA-00907: missing right parenthesis creating table

Please guide me to effectively launch the query to implement the concept of auto-increment in Oracle.

like image 862
Airglow Avatar asked Jan 24 '26 05:01

Airglow


1 Answers

The key word auto_increment is not a valid Oracle command. You would want to use a SEQUENCE

like image 194
MikeTWebb Avatar answered Jan 26 '26 19:01

MikeTWebb