postgresql delete cascade Code Answer

If you have a table that includes many rows, and you want to delete some of those rows, you can use the postgresql delete cascade command to do so. This command will first drop all of the rows in the table, then it will remove those rows from the index.

postgresql delete cascade

By VasteMondeVasteMonde on Apr 27, 2021
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';

Add Comment

1

The postgresql delete cascade is a special case of the drop cascade. It is used to delete a set of tables that are created by one statement, but not all at once. The syntax is given above.

SQL answers related to "postgresql delete cascade"

View All SQL queries

SQL queries related to "postgresql delete cascade"

postgresql delete cascade meaning of on delete cascade on delete cascade delete from select postgresql postgresql nodejs postgresql datetrunc too slow set username and password for postgresql database postgresql update sequence next value postgresql get year return insert results in POSTGRESQL Port 5432 is already in use Usually this means that there is already a PostgreSQL server running on your Mac. If you want to run multiple servers simultaneously, use different ports. postgresql where datetrunc month and year equal postgresql date = today select if then postgresql postgresql list columns createdb with postgresql on ubuntu postgresql limit data directory postgresql create and attach user to a postgresql database postgresql psycopg2 select single value mysql vs postgresql how to start postgresql laravel offset in postgresql example postgresql isnull with max install postgresql 10 centos 7 call rest api from postgresql postgresql where clause not working data types mysql vs postgresql how to backup postgresql database using pg_dump update database collation in postgresql how to show index type in postgresql open postgresql.conf in centos postgresql in vs any performance postgresql inline table postgresql array to rows sqlalchemy sequence postgresql postgresql gset postgresql print variable temp table in postgresql postgresql createdb one insert many values postgresql postgresql allow remote connections Exemplo prático de como criar tabela com chaves estrangeiras no PostgreSQL drop domain postgresql enlever les doubles espaces dans les tables postgresql install postgresql how to check if a sequence exists in postgresql update from select postgresql delete table sql pl sql trigger determine if insert or update or delete mysql delete row truncate delete and drop in sql delete row psql SQL DELETE sql delete column what is delete in sql sql delete duplicate rows but keep one how to delete table in mysql mysql trigger to delete old data DELETE in MySQL query using c++ what is delete clause sql query to delete row by id deny select insert update delete sql sql server delete records with specific date wordpress delete post revisions older than date "sql" delete row in sql server join uncheck constraints and delete from table stored procedure to delete data from table in mysql mysql delete rows delete all tables from database mysql how to create a delete stored procedure in sql how to delete python anywhere mysql database delete double on SQL with multiple primary keys postgres delete database delete all records from table delete db postgres delete all duplicate rows keep the latest except for one in mysql crud delete row

Browse Other Code Languages

CodeProZone