Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
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, 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 add constraint accounts_status_id_def_fkey FOREIGN KEY(status_id) REFERENCES statuses(id) on delete set default;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear