Truncate tables with cascade

2

I have a table hotel and table reservation.

In the reservation table I have the primary key of the hotel table as the foreign key.

I can not truncate because there are relationships between braces. How can I do it?

I already did:

truncate table hospede on delete cascade;

But I can not.

Just remember that fk is with on delete cascade . And I use the 11g express edition.

    
asked by anonymous 26.11.2016 / 20:01

1 answer

2

on delete cascade should only be used in some DDL statements and not in DML statements > data manipulation language ). That is, it is only to use where there is a change in the structure of the tables, not the data. But in your case, you just want to erase the data without changing the structure of the tables.

So, I would do the following:

TRUNCATE TABLE hospede;
TRUNCATE TABLE reserva;
TRUNCATE TABLE hotel;

The order of the instructions is important.

    
27.11.2016 / 00:33