By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

pg_query() and double quotes

P: n/a
I'm discovering that my pg_query isn't working because PostgreSQL is
wanting double quotes around my column names and table names. Is there
a way to turn quoted identifiers off?
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
go********@hotpop.com (Google Mike) writes:
I'm discovering that my pg_query isn't working because PostgreSQL is
wanting double quotes around my column names and table names. Is there
a way to turn quoted identifiers off?


PostgreSQL should require quotes around identifiers only when they're
identical to reserved key words[1] or if they contain characters
that aren't usually allowed in identifier names[2]. If your
identifiers use such names then you'll have to quote them. If
that's not the problem, then could you give an example of what
you're doing and what error(s) you're getting?

[1] http://www.postgresql.org/docs/curre...-appendix.html
[2] http://www.postgresql.org/docs/curre...AX-IDENTIFIERS

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #2

P: n/a
ljb
mf***@fuhr.org wrote:
go********@hotpop.com (Google Mike) writes:
I'm discovering that my pg_query isn't working because PostgreSQL is
wanting double quotes around my column names and table names. Is there
a way to turn quoted identifiers off?


PostgreSQL should require quotes around identifiers only when they're
identical to reserved key words[1] or if they contain characters
that aren't usually allowed in identifier names[2]. If your
identifiers use such names then you'll have to quote them. If
that's not the problem, then could you give an example of what
you're doing and what error(s) you're getting?


Add one more reason: case sensitivity. If you created your tables with
double-quoted names (table or column), then they become case sensitive, and
can generally only be accessed with double-quoted names which match the
original names in case.
Jul 17 '05 #3

P: n/a
ljb <lj****@mindspring.nospam.com> writes:
mf***@fuhr.org wrote:
go********@hotpop.com (Google Mike) writes:
I'm discovering that my pg_query isn't working because PostgreSQL is
wanting double quotes around my column names and table names. Is there
a way to turn quoted identifiers off?


PostgreSQL should require quotes around identifiers only when they're
identical to reserved key words[1] or if they contain characters
that aren't usually allowed in identifier names[2]. If your
identifiers use such names then you'll have to quote them. If
that's not the problem, then could you give an example of what
you're doing and what error(s) you're getting?


Add one more reason: case sensitivity. If you created your tables with
double-quoted names (table or column), then they become case sensitive, and
can generally only be accessed with double-quoted names which match the
original names in case.


Ah yes, I forgot about that situation, and it might be more likely
than the cases I cited. Thanks for pointing it out.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #4

P: n/a
Thanks. That's what I did, Michael. I was using the pgAdminIII tool to
define the tables, and it defaults to quoting table and column names,
forcing case-sensitivity. Since I like that tool, I decided that the
solution for me was to just lower-case everything when I created it.
Then, from PHP, I call everything in lowercase. It's still
case-sensitive, but it's more user-friendly to me. For other people,
however, I'll recommend that they create their tables and columns
without quoting them so that they are no longer case-sensitive.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.