问题
I set the table
CREATE TABLE author (
id serial NOT NULL,
name character varying(255) NOT NULL,
orcid character varying(128) NOT NULL,
"position" integer NOT NULL,
CONSTRAINT author_pkey PRIMARY KEY (id )
);
Why does the "position"
name contain ""
?
How can I remove ""
from position
?
回答1:
Actually, position
is
non-reserved (cannot be function or type)
I am referring to the list of reserved words in the manual. What you see is most probably the output of pgAdmin
(which you should have mentioned). pgAdmin also quotes identifiers that are reserved words according to any SQL standard - which is true for position
.
This statement is therefore syntactically correct:
SELECT position FROM author LIMIT 1;
Of course, you can always double-quote identifiers, this would work, too:
SELECT "position" FROM author LIMIT 1;
But with statements like these you would need the double quotes:
SELECT "where" FROM author LIMIT 1;
SELECT "CaMeL" FROM author LIMIT 1;
SELECT "a-b-c" FROM author LIMIT 1;
来源:https://stackoverflow.com/questions/13004537/why-is-one-identifier-in-a-create-table-double-quoted-but-not-the-others