0

I made a script to create a database with PostgreSQL. So I copy in my script, click "Analyze & Explain" in pgAdmin4 and I have no clue why it says I have a syntax error at or near 'INT' on idSituationFamiliale.

I really can't see what's wrong...

--Personnes
--
CREATE TABLE SITUATION_FAMILIALE (
    idSituationFamiliale INT NOT NULL,
    intituleSituationFamiliale VARCHAR(50) NOT NULL,
    PRIMARY KEY(idSituationFamiliale)
);
0

2 Answers 2

2

The query is fine if you RUN it. It is wrong if you EXPLAIN / ANALYZE it. The doc says that you can explain a CREATE TABLE AS, not a pure CREATE TABLE statement. While the former contains a SELECT statement that can be explained/analyzed, the later has nothing to be explained/analyzed and fails on the 1st field, regardless of its name or type.

Sign up to request clarification or add additional context in comments.

1 Comment

Okay, I will try to run the script as such asap ^^ Thank you :)
-1

You should be using integer as opposed to int.

e.g

--Personnes
--
CREATE TABLE SITUATION_FAMILIALE (
idSituationFamiliale INTEGER NOT NULL,
intituleSituationFamiliale VARCHAR(50) NOT NULL,
PRIMARY KEY(idSituationFamiliale)
);

6 Comments

Hello, thanks for the response ^^ Unfortunately it doesn't change anything :/
How about: --Personnes -- CREATE TABLE SITUATION_FAMILIALE ( idSituationFamiliale INTEGER PRIMARY KEY NOT NULL, intituleSituationFamiliale VARCHAR(50) NOT NULL );
int is a valid alias for integer in Postgres
Thanks! I hadn't realised.
Still the same problem :/
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.