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 table1
AS
SELECT *
FROM (VALUES
(1, 26),
(2, 56),
(3, 12),
(4, 67)) v (inventory_id, test_id);
SELECT 4
CREATE TABLE table2
AS
SELECT *
FROM (VALUES
(12, NULL),
(26, NULL),
(56, NULL),
(67, NULL)) v (test_id, inventory_id);
SELECT 4
SELECT *
FROM table1;
inventory_id test_id
1 26
2 56
3 12
4 67
SELECT 4
SELECT *
FROM table2;
test_id inventory_id
12 null
26 null
56 null
67 null
SELECT 4
UPDATE table2 t2
SET inventory_id = t1.inventory_id
FROM table1 t1
WHERE t1.test_id = t2.test_id;
UPDATE 4
SELECT *
FROM table2;
test_id inventory_id
12 3
26 1
56 2
67 4
SELECT 4