Re: [SQL] newline in text field

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: "Sergei M(dot) Suntsov" <serge(at)uic(dot)nsu(dot)ru>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] newline in text field
Date: 1998-11-08 12:12:28
Message-ID: l0311070ab26b39b4e509@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

At 13:50 +0200 on 8/11/98, Sergei M. Suntsov wrote:

> Hello
> I would like to insert into text field strings separated by newline
> character ('\n') using psql. How should I quote newline characters if it
> is possible ?
> Thanx in advance.
> Sergei

It depends on the context. If you want to put it in an insert string, you
don't have to quote it. You do something like:

INSERT INTO my_table ( text_field )
VALUES (
'...And yet by heaven I swear my love as rare
As any she belied with false compare!' );

If you are doing it within COPY, where newline has significance as a
delimiter, you should put a backslash before it:

COPY my_table FROM stdin;
...And yet by heaven I swear my love as rare\
As any she belied with false compare!
\.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Mather (Powered By Linux) 1998-11-08 15:41:49 (Fwd) Hi and some advice on Dates
Previous Message Sergei M. Suntsov 1998-11-08 11:50:51 newline in text field