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
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: petefreitag.com/tools/sql_reserved_words_checker/?word=windowColin 't Hart– Colin 't Hart2015年01月07日 18:15:36 +00:00Commented 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– user18222015年01月07日 19:13:38 +00:00Commented Jan 7, 2015 at 19:13