Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Syntax error at or near END" with column name END

Tags:

postgresql

I have a table in MYSQL and have to convert it in postgresql.

I am using the below command to create the table.

create table emp(COMPLETE BOOLEAN NOT NULL, END BOOLEAN NOT NULL);

the error, I am getting is

Error at Command Line : 27 Column : 1 Error report - SQL Error: ERROR: syntax error at or near "END" Position: 45

But if I change the column name END to END1, then it works fine.

create table emp(COMPLETE BOOLEAN NOT NULL, END1 BOOLEAN NOT NULL);

Please suggest a way through which I can create the name of columnwith END.

like image 523
Sumit Avatar asked Mar 20 '23 01:03

Sumit


1 Answers

END is a keyword. (Among other things, it's used in CASE ... WHEN ... END). You must quote it to use it as an identifier.

create table emp(complete BOOLEAN NOT NULL, "end" BOOLEAN NOT NULL);

Note that "quoted" identifiers are case sensitive, they aren't case folded like unquoted identifiers. That's per the SQL standard. For more information, see the PostgreSQL documentation on lexical structure.

There's a list of reserved words in the documentation.

like image 54
Craig Ringer Avatar answered Apr 28 '23 13:04

Craig Ringer