Which statement is true about TRUNCATE and DELETE?
Which statement is true about TRUNCATE and DELETE?
TRUNCATE cannot be performed on a table if it violates foreign key constraints, unless those constraints are disabled. This restriction ensures that referential integrity is maintained in the database. While there are certain exceptions, such as self-referential constraints, the general rule holds that TRUNCATE cannot be used when it would violate active foreign key constraints.
C. A and D: False --> Truncate is better and has better performance than delete and Drop except for very small tables. B False --> You can truncate a table with a FK on Cascade. You can disable FK and then Truncate (except if FK is self-refential).
i think C is correct if the referential integrity constraint has the ON DELETE CASCADE option
C is correct since you can delete using cascade option B is incorrect since it says never but you can by disable the constraint
B is correct
C is correct, We can trucate table contains referential integrity, one by drop the constraint/ while adding constraint we can include on delete cascade . Truncate table colors cascade; this statement will run successfully. Reference https://www.examtopics.com/discussions/oracle/view/15064-exam-1z0-071-topic-1-question-268-discussion/
D is wrong . B is correct https://docs.oracle.com/database/121/SQLRF/statements_10007.htm#SQLRF01707
Answer is B ORA-02266: unique/primary keys in table referenced by enabled foreign keys
So answer should be B
The answer is B Here is explanation : In this option it does not mean you can never truncate a table it says if foreign key activated and would be violated you can NEVER. The keyword is IF <<<<
C CAN work if we have CASCADE, B is wrong cuz it says NEVER, the documentation states: 'You cannot truncate the parent table of an enabled foreign key constraint. You must disable the constraint before truncating the table. An exception is that you can truncate the table if the integrity constraint is self-referential.'
there's also this: CASCADE If you specify CASCADE, then Oracle Database truncates all child tables that reference table with an enabled ON DELETE CASCADE referential constraint. This is a recursive operation that will truncate all child tables, grandchild tables, and so on, using the specified options.
B is correct. Truncate is faster than delete
Very confusing. It seems truncate is always faster than delete. And for B and C, B is false if you use cascade in the command and constraint was created with on delete cascade. Similarly with C, if constraint was created with on delete cascade then you can delete those rows.
The problem with B is that there is an exception for self referential constraint and B uses the word 'never'. I think it's C because of the 'on delete cascade option'.
You cannot truncate the parent table of an enabled foreign key constraint. You must disable the constraint before truncating the table. https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/TRUNCATE-TABLE.html
From the link: You cannot truncate the parent table of an enabled foreign key constraint. You must disable the constraint before truncating the table. An exception is that you can truncate the table if the integrity constraint is self-referential.
This needs to be updated!
Option B is true. When using the TRUNCATE statement, if there are foreign key constraints referencing the table to be truncated, you will not be able to truncate the table. Truncating a table removes all the data in the table, and if there are dependent foreign key constraints, truncating the table would violate those constraints. In such cases, you would need to either disable or drop the foreign key constraints before truncating the table.
It says "NEVER", but is possible for self referenced tables.
B -You cannot truncate the parent table of an enabled foreign key constraint. You must disable the constraint before truncating the table. An exception is that you can truncate the table if the integrity constraint is self-referential.
I think B is correct (but not sure 100%)