0

Probably a very easy question for most of you, but I'm having some problems running this code:

CREATE TABLE Users(
 userId INT SERIAL PRIMARY KEY,
 userName VARCHAR(50),
 userPassword VARCHAR(50),
);

I usually use MySQL but encountered PostgreSQL in a school work. Why is this code not working for me? The database just gives me a syntax error, nothing else is provided for me. The only thing I changed compared to the MySQL code is auto_increment to SERIAL. Thanks in advice!

2
  • 3
    It's either INT or SERIAL but can't be both Commented Apr 6, 2022 at 14:52
  • 2
    It should be userid int generated always as identity primary key Commented Apr 6, 2022 at 14:55

1 Answer 1

2

If you want auto generated sequential IDs , use bigserial, and the query looks something like this :-

CREATE TABLE Users(
 userId bigserial,
 userName VARCHAR(50),
 userPassword VARCHAR(50),
    Primary Key(userId)
);
Sign up to request clarification or add additional context in comments.

Comments

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.