1

I have weird issue when I do

`temp=# \d
                      List of relations
Schema |             Name              |   Type   |      Owner      
--------+-------------------------------+----------+-----------------
public | ORDER                         | table    | admin
public | ORDER_id_seq                  | sequence | admin `  

As the table list as shown above. The table name ORDER is coming but when I try to drop it, I get the syntax error as
temp=# drop table ORDER; ERROR: syntax error at or near "ORDER" LINE 1: drop table ORDER;

What is the issue and what is other way to drop ORDER table?

2 Answers 2

3

ORDER is a reserved keyword as mentioned in: http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html

So it needs to be enclosed in double quotes when used as an object name. Besides, as it's in uppercase, even if it wasn't a keyword these double quotes would be needed anyway.

Just do:

drop table "ORDER";
Sign up to request clarification or add additional context in comments.

Comments

1

Since ORDER is also a SQL "reserved word", you have to put the table name in double quotes. (Which you have to do anyway because it is capitalized)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.