Home > Back-end >  Creating my first table- Syntax error at or near ();
Creating my first table- Syntax error at or near ();

Time:05-14

First day of postgreSQL- sorry if this is too basic, but couldn't find the answer on here.

So basically I'm following a video tutorial, and have written exactly the same lines as tutorial, yet I get above mentioned syntax error when trying to clear:

CREATE TABLE Actors(
    actor_id SERIAL PRIMARY KEY, 
    first_name VARCHAR(30),
    last_name VARCHAR(30)NOT NULL,
    gender CHAR(1),
    date_of_birth DATE,
);

I know there is probably a super simple solution but I cant seem to find out what after nearly 2 hours- help

CodePudding user response:

No need to apologize!

For clean queries, always recommended to put a [SPACE] after datatypes (for example: VARCHAR(30)[SPACE]NOT NULL ) and always be sure to remove your COMMAS right before your closing parenthesis.

CREATE TABLE Actors(
actor_id SERIAL PRIMARY KEY, 
first_name VARCHAR(30),
last_name VARCHAR(30) NOT NULL,
gender CHAR(1),
date_of_birth DATE
)

CodePudding user response:

Remove the , after date_of_birth and perhaps add a space before NOT NULL

CREATE TABLE Actors (
    actor_id SERIAL PRIMARY KEY, 
    first_name VARCHAR(30),
    last_name VARCHAR(30) NOT NULL,
    gender CHAR(1),
    date_of_birth DATE
);
  • Related