'Creating my first table- Syntax error at or near ();
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
Solution 1:[1]
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
)
Solution 2:[2]
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
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Touch |
Solution 2 | SFournier |