Re: Disruptive corruption of data during an update

Поиск
Список
Период
Сортировка
От Binand Sethumadhavan
Тема Re: Disruptive corruption of data during an update
Дата
Msg-id CAFBJCCa9e0XJhcJG3u7WK5thS4XMejTSBEq52CCgAuSOLcJ2uQ@mail.gmail.com
обсуждение исходный текст
Ответ на Disruptive corruption of data during an update  (Ennio-Sr <nasr.laili@tin.it>)
Ответы Re: Disruptive corruption of data during an update  (ennio <eiannucci@tin.it>)
Re: Disruptive corruption of data during an update  (Alan Hodgson <ahodgson@simkin.ca>)
Список pgsql-novice
On 29 March 2012 16:47, Ennio-Sr <nasr.laili@tin.it> wrote:
> --------
> mydb=> update bibl set argomento='curatori', autore='DELLA VOLPE Galvano \
>       (con due capitoli aggiunti e note di)  where n_prog=3285;
> mydb'> ';
>
> UPDATE 12845
> mydb=>
> --------
>
> Having an adequate back-up I think I'll be able to recover the data, but
> can someone explain what the hell happened?

Because of the single quote being at the wrong place, your query was
processed as though not having a where clause at all, and the ENTIRE
table got updated with the text:

DELLA VOLPE Galvano \
       (con due capitoli aggiunti e note di)  where n_prog=3285;

in the autore field (and similarly in the argomento field).

What I typically do is to attach "where 1 = 0" to inhibit a query from
making any changes, if I find an error in a multiline query and do not
want to Control-C out of psql.

Binand

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

Предыдущее
От: Ennio-Sr
Дата:
Сообщение: Disruptive corruption of data during an update
Следующее
От: Ennio-Sr
Дата:
Сообщение: Disruptive corruption of data during an update