pasting a lot of commands to psql

Поиск
Список
Период
Сортировка
От Dmitry Shalashov
Тема pasting a lot of commands to psql
Дата
Msg-id CAKPeCUEaqhwyVDBySp_twrNWZ8OfqD2=9nqu7g-jM0CeTfBuwg@mail.gmail.com
обсуждение исходный текст
Ответы Re: pasting a lot of commands to psql  (Sameer Kumar <sameer.kumar@ashnik.com>)
Re: pasting a lot of commands to psql  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi everyone.

Let say that I have some sql file with like hundred of simple statements in it. I `cat` it, copy it to buffer, go to my beloved psql and insert it there.
But somewhere after first few lines it screws over: 

b2b=> BEGIN;
b2b=> INSERT INTO oko_topsites VALUES('russian_federation','ati.su',0,NULL,5);
INSERT INTO oko_topsites VALUES('russian_federation'b2b=> INSERT INTO oko_topsites VALUES('russian_federation','atn.ua',0,NULL,5);
b2b=> INSERT INTO oko_topsites VALUES('russian_federation','audit-it.ru',0,NULL,5);
b2b=> INSERT INTO oko_topsites VALUES('russian_federation','aup.ru',0,NULL,5);
'
b2b=> INSERT INTO oko_topsites VALUES('russian_federation','autocentre.ua',0,NULL,5);

b2b=> INSERT INTO oko_topsites VALUES('russian_federation','autodoc.ru',0,NULL,5);

b2b=> INSERT INTO oko_topsites VALUES('russian_federation','calend.ru'

b2b(> INSERT INTO oko_topsites VALUES('russian_federation','calorizator.ru',0,NULL,5)

Unclosed quotes, unclosed parenthesis - anyway it wont work.

How to safely insert big number of statements to psql at once?
I am aware about "execute this file" \i option of psql, that is not the answer I am looking for, thanks :-)

Dmitry Shalashov, surfingbird.ru & relap.io

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Fastest memmove in C
Следующее
От: Sameer Kumar
Дата:
Сообщение: Re: pasting a lot of commands to psql