Search code examples
sqldatabasecreate-table

What is the syntax error in Create table statement?


I'm sorry if this is too easy, but I'm tired and cannot seem to solve this on my own. Can anyone see what is wrong with this command?

create table Users (
   user_id NUMBER(4) PRIMARY KEY ,
   username VARCHAR2(16) NOT NULL,
   password VARCHAR2(16) NOT NULL,
   first_name VARCHAR2(20) NOT NULL,
   last_name VARCHAR2(20) NUT NULL,
);

Edit: Thanks all. Problem solved. It was the last comma and the NUT :P


Solution

  • Do this

    create table Users (
        user_id numeric(4) PRIMARY KEY ,
        username VARCHAR(16) NOT NULL,
        password VARCHAR(16) NOT NULL,
        first_name VARCHAR(20) NOT NULL,
        last_name VARCHAR(20) NOT NULL
    );
    

    I Changed:

    • number to numeric
    • removed last comma
    • varchar2 to varchar
    • NUT to NOT