0

I want to create this table, but i can’t,

Look this error.

CREATE TABLE ATTR(

    window character varying(64) NOT NULL

);

ERROR: syntax error at or near "window"
LINE 2: window character varying(64) NOT NULL

1 Answer 1

2

window is a reserved word. You can create a column with that name if you enclose it in double quotes:

CREATE TABLE ATTR
(
  "window" character varying(64) NOT NULL
);

More details about identifiers, quoted identifiers and keywords can be found in the manual:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS


But I highly recommend you find a different name that does not need to be quoted. Using quoted identifiers is more trouble in the long run than they are worth it.

2
  • I found this handy reserved word checker which checks in most of the major DBMSes: petefreitag.com/tools/sql_reserved_words_checker/?word=window Jan 7, 2015 at 18:15
  • @Colin'tHart: the checker is quite outdated I'd say. window is a reserved word in SQL:2003 but the checker only checks the pretty old SQL:99 I'm also sure it's a reserved in Oracle. And SQL Server 2000 is also very much outdated. I would assume that since SQL Server also supports window functions it is a reserved word in any recent SQL Server version as well.
    – user1822
    Jan 7, 2015 at 19:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.