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 if not exists line ( id bigint primary key generated by default as identity, name text ); create table if not exists project_line ( id bigint primary key generated by default as identity, name text ); create table if not exists project_subline ( id bigint primary key generated by default as identity, line bigint references project_line(id) on delete cascade ); insert into project_line(name) values('patata'),('pototo'); insert into line(id, name) select * from project_line; alter table project_line drop column name; alter table project_line alter column id drop identity; alter table project_line add constraint fk_line_id foreign key (id) references line(id); alter table line alter column id restart with 3; insert into line(name) values ('mandingo'),('mondongo'); insert into project_subline(line) values(1); alter table project_subline drop constraint project_subline_line_fkey; alter table project_subline add constraint fk_line foreign key(line) references line(id); alter table project_subline rename to subline; select * from subline;

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

Copy Clear