Home > Enterprise >  How to make sure SQL query is valid
How to make sure SQL query is valid

Time:11-03

I'm fairly new to SQL and I don't really understand what constitues a valid query:

CREATE TABLE table_name (
  user_id UUID PRIMARY KEY NOT NULL,
  additional_info JSONB,
);

Why is the above invalid?

CodePudding user response:

Can't add a comment as I don't have enough points

CREATE TABLE table_name (
  user_id UUID PRIMARY KEY NOT NULL,
  additional_info JSONB
);

Should work as tested on db-fiddle.com for postgresql. As WoundedStevenJones pointed out there's a trailing comma

CodePudding user response:

CREATE TABLE table_name (
  user_id UUID PRIMARY KEY NOT NULL,
  additional_info JSONB
);

It's probably due to the trailing comma , after JSONB.

  • Related