Postgresql – Postgres Error for table

postgresql-9.3

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

Best Answer

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.