0

when i am executing query in dbeaver I am getting missing right code paranthesis error

CREATE TABLE PersonsNotNull
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL DEFAULT 'KHATTAR',
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
Matt
  • 14,906
  • 27
  • 99
  • 149
simba
  • 277
  • 4
  • 19

1 Answers1

2

You have the clauses the wrong way; the default value has to come before the null/not null indicator:

CREATE TABLE PersonsNotNull
(
P_Id int NOT NULL,
LastName varchar(255) DEFAULT 'KHATTAR' NOT NULL ,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);

Table PERSONSNOTNULL created.

You're creating a relation table so the relation properties and column properties syntax apply:

column properties

From that you can see that the optional DEFAULT expr clause comes before the constraints, which includes null/not null:

enter image description here

Alex Poole
  • 183,384
  • 11
  • 179
  • 318