SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table statuses (id serial primary key, title varchar); insert into statuses (title) values ('Active'), ('Not active'), ('Else'); create table accounts ( id serial, name varchar, status_id int default 2, constraint accounts_status_id_fkey foreign key(status_id) references statuses(id) ); insert into accounts (name, status_id) values ('Test account', 3); select * from accounts; delete from statuses where id = 3; alter table accounts add constraint accounts_status_id_def_fkey foreign key(status_id) references statuses(id) on delete set default, drop constraint accounts_status_id_fkey; delete from statuses where id = 3; select * from accounts;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear