Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Postgres Trigger
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
drop table if exists table1; drop table if exists table2; create table table1( id integer NOT NULL,name character varying); create table table2(id integer NOT NULL,name character varying); create or replace function function_copy() returns trigger language plpgsql as $$ begin insert into table2(id,name) values(new.id,new.name); return new; end $$; create trigger trig_copy before insert or update on table1 for each row execute procedure function_copy(); insert into table1 (id, name) values (1, 'John'); insert into table1 (id, name) values (2, 'John2'); select * from table1; select * from table2; delete from table1 where id=1; select * from table1; select * from table2;
absolute service time: 0,45 sec
edit mode
|
history
|
discussion
id
name
1
1
John
2
2
John2
id
name
1
1
John
2
2
John2
id
name
1
2
John2
id
name
1
1
John
2
2
John2