Double quotes column names in postgres




There are two reasons to use double quotes around column names in PostgreSQL
  1.  If the reserved words are used as the column names.
  2. PostgreSQL is case sensitive and all objects are regarded as lowercase unless double quotes are provided. Double quotes tells PostgreSQL to use the case given.
If you create a table

CREATE TABLE tt1 (
    id integer,
    "Order" integer
);

The above statement tell PostgreSQL that the "Order" column must be saved in that case.

The following INSERT statements will not work :-

INSERT INTO tt1 (id, Order) VALUES (1, 1)
INSERT INTO tt1 (id, "order") VALUES (2, 2)
INSERT INTO tt1 (id, "OrDer") VALUES (3, 3)
You will have to get the case correct :-

INSERT INTO tt1 (id, "Order") VALUES (1, 1)
INSERT INTO tt1 (id, "Order") VALUES (2, 2)
INSERT INTO tt1 (id, "Order") VALUES (3, 3)

This post is to be used as future reference myself and my other friends those whoever encountered this question.
Full credits to original questions and answers @ http://stackoverflow.com/a/6730803/4148663

Popular posts from this blog

npm refusing to install as a dependency of itself

How to call javascript functions from VB.NET and using WebBrowser Control