Search Postgresql Archives

Re: Insert data if it is not existing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday, May 23, 2018, tango ward <tangoward15@xxxxxxxxx> 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.

David J.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux