Re: Quote Question - Mailing list pgsql-novice

From John DeSoi
Subject Re: Quote Question
Date
Msg-id E41793A4-A137-11D9-A2E3-000A95B03262@pgedit.com
Whole thread Raw
In response to Quote Question  (Greg Lindstrom <greg.lindstrom@novasyshealth.com>)
Responses Re: Quote Question
List pgsql-novice
On Mar 30, 2005, at 10:31 AM, Greg Lindstrom wrote:

> INSERT INTO MYTABLE (VALUE_1, VALUE_2)
>     VALUES ("Hello", "")
>
> but I now get an error complaining about a "zero length delimited
> identifier".  Rats. So:
>
> 1.  What's going on above with single and double quotes?

In PostgreSQL, double quotes are only used to quote identifiers such as
tables and columns. You only need to do this if you want to include
non-standard characters in the identifier name (e.g. spaces) or need to
preserve case. For example,

INSERT INTO "My Table" ...

>
> 2.  How can I insert single (and double) ticks into my data fields?
>

You double the quote or use \

VALUES('Woman''s Health', '') or
VALUES('Woman\'s Health', '')

There should be a function in your pg Python interface to handle this
for you.


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


pgsql-novice by date:

Previous
From: Greg Lindstrom
Date:
Subject: Quote Question
Next
From: Michael Fuhr
Date:
Subject: Re: Quote Question