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 Answers1

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.

  • I found this handy reserved word checker which checks in most of the major DBMSes: http://www.petefreitag.com/tools/sql_reserved_words_checker/?word=window – Colin 't Hart Jan 07 '15 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. –  Jan 07 '15 at 19:13