Re: Insert data if it is not existing

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Insert data if it is not existing
Дата
Msg-id 0a76f762-88d8-75a7-de3c-d76094638fdd@aklaver.com
обсуждение исходный текст
Ответ на Re: Insert data if it is not existing  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Insert data if it is not existing  (tango ward <tangoward15@gmail.com>)
Список pgsql-general
On 05/23/2018 10:00 AM, David G. Johnston wrote:
> On Wednesday, May 23, 2018, tango ward <tangoward15@gmail.com 
> <mailto:tangoward15@gmail.com>> wrote:
> 
>     I just want to ask if it's possible to insert data if it's not
>     existing yet.
> 
> 
> This seems more like a philosophical question than a technical one...
> ​but the answer is yes:
> 
> CREATE TABLE test_t (a varchar, b varchar, c integer);
> INSERT INTO test_t
> SELECT '1', '2', 3 WHERE false;​ --where false causes the data to 
> effectively "not exist"
> 
> As for ON CONFLICT: conflicts can only happen between things that exist.

Well that made my day:)

> 
> David J.
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Error on vacuum: xmin before relfrozenxid
Следующее
От: Paolo Crosato
Дата:
Сообщение: Re: Error on vacuum: xmin before relfrozenxid