Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgresql delete cascade

CREATE TABLE employee(emp_id SERIAL PRIMARY  KEY, name VARCHAR(30),
	sector_fk INT NOT NULL);

CREATE TABLE process(emp_id SERIAL PRIMARY KEY, sector VARCHAR(20));

ALTER TABLE employee ADD FOREIGN KEY (sector_fk)
REFERENCES company(emp_id) ON DELETE CASCADE;

-- Deletes cascade employees referencing deleted companies
DELETE FROM company WHERE sector='industry';
Comment

how to add on delete cascade to existing table column postgres

alter table public.scores
drop constraint scores_gid_fkey,
add constraint scores_gid_fkey
   foreign key (gid)
   references games(gid)
   on delete cascade;
Comment

PREVIOUS NEXT
Code Example
Sql :: else if sql 
Sql :: oracle job class 
Sql :: sql comments 
Sql :: mysql count 
Sql :: sql server delete records with specific date 
Sql :: oracle sql developer 
Sql :: SQL INNER JOIN With Three Tables 
Sql :: first mysql 
Sql :: SQL/update 
Sql :: where clause for clob in oracle 
Sql :: connect to mysql server mac terminal 
Sql :: how to check which table has data in mysql 
Sql :: fetlife 
Sql :: create a plsql object 
Sql :: postgres insert into table 
Sql :: many to many flask-sqlalchemy 
Sql :: postgres drop all tables 
Sql :: postgresql get difference in hours between two dates 
Sql :: sql with as 
Sql :: mysql inner join 
Sql :: SQL COMO ALTERA NOME DE TABELA 
Sql :: sql where multiple values 
Sql :: mysql create view 
Sql :: query to get all primary keys and foreign key 
Sql :: cte in sql server 
Sql :: oracle drop program 
Sql :: ubuntu install mysql 5.7 
Sql :: advantages of stored procedures sql 
Sql :: Write an SQL query to determine the 5th highest salary without using TOP or limit method. 
Sql :: how to find 2nd highest salary in mysql 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =