0

I'm using postgresql database, in a table, I have a column named date. The problem occurs when I try making some operations with this column (date).

For example:

create index tg_index ON table_replay using btree(date);

here is my error:

ERROR: column "date" does not exist

****** Error ******

ERROR: column "date" does not exist SQL state: 42703

PS: I cannot change this column name because this is a big database so i need many years to perform any change. Thanks for understanding.

2
  • 4
    date is a reserved word (type name) in SQL. Use double quotes if you insist on using at as a column name : USING BTREE("date" ) (and tell the person who designed the DB that date is a bad name) BTW: if you can create an index, you can probably rename the column, too Commented May 23, 2014 at 10:37
  • This database is not mine, but cause of latency, I have to migrate it on postres database (It's actually on MySql). There are many reasons that I cannot change this column name. This may cause a "Big Bug" on our system (witch is designed by another person). That's way I try to find solution without change the column name. Commented May 23, 2014 at 16:22

2 Answers 2

1

Change your column name from date to another such as date because date is a reserved word. You can easily achieve this by using alter commmand. Using alter command dosen't take too much time because alter command only affects the table structure reather than the data of the table. alter command have no concern with the data of the table.

Sign up to request clarification or add additional context in comments.

Comments

1

http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html says date is a reserved keyword. You can try quoting it. That may not work.

I agree witht he above comment - use of plain keywords that have a generic sense is generally a bad practice - column names should help to describe the purpose of the column.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.