user2297666
user2297666

Reputation: 321

Creating a users table in SQL

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

Answers (5)

Nicole
Nicole

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

Joseph
Joseph

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

bcm360
bcm360

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

cosmos
cosmos

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

Ian Kenney
Ian Kenney

Reputation: 6446

try

CREATE TABLE users
( user_id int PRIMARY KEY,
  username varchar(25) NOT NULL,
  password varchar(30) NOT NULL
);

Upvotes: 1

Related Questions