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

asked Jan 7, 2015 at 18:03

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.

answered Jan 7, 2015 at 18:14
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 Commented 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. Commented Jan 7, 2015 at 19:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.