adspace
Is it possible to remove child records without removing master table records...the two having pk,fk relationship?
Answer Posted / Devendra Pratap Singh
In SQL and PL/SQL, it is possible to delete child records while keeping the master table records intact by using a technique called 'Cascading Delete'. However, this operation needs to be explicitly defined in the foreign key constraint. If cascading delete is not defined, you can use a DELETE statement with a JOIN to remove only the child records. Here's an example of how it might look like for a SQL DELETE operation:
```sql
DELETE c
FROM ChildTable c
JOIN MasterTable m ON c.FK_MasterId = m.PK_MasterId
WHERE condition;
```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what are the advantages of sql ? : Sql dba
How do I remove duplicates in two columns?
what is collation? : Sql dba
what are all the common sql function? : Sql dba
what is schema? : Sql dba
what is bcp? When does it used? : Sql dba
how to use regular expression in pattern match conditions? : Sql dba
how to escape special characters in sql statements? : Sql dba
Can we use distinct and group by together?
If a cursor is open, how can we find in a pl/sql block?
What is your daily office routine?
what is dbms? : Sql dba
Does group by remove duplicates?
what is sql server agent? : Sql dba
Can we rollback truncate?