From: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz> |
---|---|
To: | Alban Hertroys <haramrae(at)gmail(dot)com>, abdullatheef <latheefvkpadi(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: new line in psotgres |
Date: | 2013-11-09 20:18:24 |
Message-ID: | 527E9890.8080706@archidevsys.co.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 10/11/13 02:38, Alban Hertroys wrote:
> On Nov 9, 2013, at 12:08, abdullatheef<latheefvkpadi(at)gmail(dot)com> wrote:
>
>> >you can include newline in postgre using literal E
>> >
>> >create table table (text varchar(50));
>> >insert into Table (text) values (E'This is the first part \\n And this is
>> >the second');
> Or like this:
> development=> begin;
> BEGIN
> development=> create table t1 (text text);
> CREATE TABLE
> development=> insert into t1 values ('This is line 1.
> development'> This is line 2.');
> INSERT 0 1
> development=> select * from t1;
> text
> -----------------
> This is line 1.+
> This is line 2.
> (1 row)
>
>
> Alban Hertroys
> --
> If you can't see the forest for the trees,
> cut the trees and you'll find there is no forest.
>
>
>
> -- Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
The second methods have different characteristics...
-- test.sql
CREATE TABLE t1
(
id SERIAL PRIMARY KEY,
payload text
);
-- method 1
INSERT INTO t1
(payload)
VALUES
(E'This is the first part \\n And this is the second');
-- method 2
INSERT INTO t1
(payload)
VALUES
('This is line 1.
This is line 2.');
TABLE t1;
######## results:
gavin=> \i test.sql
DROP TABLE
psql:SQL.sql:8: NOTICE: CREATE TABLE will create implicit sequence
"t1_id_seq" for serial column "t1.id"
psql:SQL.sql:8: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit
index "t1_pkey" for table "t1"
CREATE TABLE
INSERT 0 1
INSERT 0 1
id | payload
----+--------------------------------------------------
1 | This is the first part \n And this is the second
2 | This is line 1. +
| This is line 2.
(2 rows)
Cheers,
Gavin
From | Date | Subject | |
---|---|---|---|
Next Message | Andrus | 2013-11-09 20:21:30 | Re: Query runs forever after upgrading to 9.3 |
Previous Message | Sandeep Gupta | 2013-11-09 19:33:30 | Re: what could cause postgres to crash? |