473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

pg_query() and double quotes

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
4 4258
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to...
11
by: Jakanapes | last post by:
Hi all, I'm looking for a way to scan a block of text and replace all the double quotes (") with single quotes ('). I'm using PHP to pull text out of a mySQL table and then feed the text into...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
24
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double...
4
by: (PeteCresswell) | last post by:
Is his just a flat-out "No-No" or is there some workaround when it comes time for SQL searches and DAO.FindFirsts against fields containing same? I can see maybe wrapping the value searched for...
8
by: Ahmad A. Rahman | last post by:
Hi all, I have a problem constructing a regular expression using .net. I have a string, separated with comma, and I want to group the string together but, I failed to group a numeric character...
7
by: gar | last post by:
Hi, I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code text= Replace(text, """", "'" This works fine (for normal double quotes).The problem...
16
by: Charles Law | last post by:
I have a string similar to the following: " MyString 40 "Hello world" all " It contains white space that may be spaces or tabs, or a combination, and I want to produce an array...
4
by: Justin Fancy | last post by:
Hi everyone, I need to replace all instances of a double quote(") with two single quotes('') in a text file. I already have some replacements of strings going on, but I tried this one, but the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.