add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
CREATE TABLE IF NOT EXISTS graph( idgraph SERIAL PRIMARY KEY, from_table varchar(128) );
CREATE TABLE
SELECT 'tag' AS from_table
from_table
tag
SELECT 1
/*
The WHEN clause may specify WHEN MATCHED, WHEN NOT MATCHED BY SOURCE, or WHEN NOT MATCHED [BY TARGET]. Note that the SQL standard only defines WHEN MATCHED and WHEN NOT MATCHED (which is defined to mean no matching target row). WHEN NOT MATCHED BY SOURCE is an extension to the SQL standard, as is the option to append BY TARGET to WHEN NOT MATCHED, to make its meaning more explicit.
*/
/*
https://www.postgresql.org/docs/current/sql-merge.html
*/
WITH cte2 AS
( SELECT 'tag' AS from_table )
MERGE INTO graph g
USING cte2 ON(g.from_table = cte2.from_table)
WHEN NOT MATCHED THEN
INSERT(from_table) VALUES(cte2.from_table)
MERGE 1
Select * From graph
idgraph from_table
1 tag
SELECT 1
Select * From graph
idgraph from_table
1 tag
SELECT 1