Reputation: 609
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.
Upvotes: 4
Views: 13257
Reputation: 793
You are using SQL reserved word as a variable name . For maximum portability of your application between data managers, you should not use any of the reserved words in this list as file class or variable names. you can even use _END ,END1... This is a list of the reserved words of SQL. http://www.tigerlogic.com/tigerlogic/omnis/download/manuals/SQLReservedWords.pdf
Upvotes: 0
Reputation: 41
Please select another name for your column as END is a keyword. And we cannot use column name same as keyword.
Upvotes: 0
Reputation: 2209
Problem comes when you use keyword as table name. Best way is use some other name.
Upvotes: 0
Reputation: 324475
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.
Upvotes: 8