Reputation: 321
I'm trying to create a Users table:
CREATE TABLE users
( user_id int(5) PRIMARY KEY,
username varchar(25) NOT NULL,
password varchar(30) NOT NULL
);
But I keep getting this error:
Error starting at line 1 in command:
CREATE TABLE users ( user_id int(5) PRIMARY KEY, username varchar(25) NOT NULL, password varchar(30) NOT NULL )
Error at Command Line:2 Column:13 Error report:
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
Any ideas?
Upvotes: 2
Views: 27702
Reputation: 21
The following works, but note that the PRIMARY KEY
constraint is added at the end of the command
CREATE TABLE users(
user_id int NOT NULL,
username varchar(25) NOT NULL,
password varchar(30) NOT NULL,
PRIMARY KEY(user_id)
);
Upvotes: 2
Reputation: 1
To create a table:
CREATE TABLE users
( user_id int(5) NOT NULL,
username varchar(25) NOT NULL,
password varchar(30) NOT NULL,
PRIMARY KEY(user_id)
);
Upvotes: -1
Reputation: 1437
Looks like it's related to your int(5)
data type specification. See Oracle numerica data types.
Try something like:
CREATE TABLE users
( user_id NUMBER PRIMARY KEY,
username varchar(25) NOT NULL,
password varchar(30) NOT NULL
);
Upvotes: 2
Reputation: 2303
don't try to put precision for integer type:
CREATE TABLE users
( user_id int PRIMARY KEY,
username varchar(25) NOT NULL,
password varchar(30) NOT NULL
);
Upvotes: 3
Reputation: 6446
try
CREATE TABLE users
( user_id int PRIMARY KEY,
username varchar(25) NOT NULL,
password varchar(30) NOT NULL
);
Upvotes: 1