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?.
drop table if exists example;
create table example(
id int,
name text,
name_copy text);

create or replace function trigger_on_example()
returns trigger language plpgsql as $$
begin
new.name_copy := new.name;
return new;
end
$$;

create trigger trigger_on_example
before insert or update on example
for each row execute procedure trigger_on_example();

insert into example (id, name)
values (1, 'John');

select *
from example;

DROP TABLE
CREATE TABLE
CREATE FUNCTION
CREATE TRIGGER
INSERT 0 1
id name name_copy
1 John John
SELECT 1
drop table if exists example_2;
create table example_2(
id int,
name text,
name_copy text generated always as (name) stored);

insert into example_2 (id, name)
values (1, 'John');

select *
from example_2;

DROP TABLE
CREATE TABLE
INSERT 0 1
id name name_copy
1 John John
SELECT 1