1

I am newbie with MySQL. I have created a tablespace with a datafile, and I have tried to drop this tablespace without drop any object in that tablespace by using that SQL query:

DROP TABESPACE TBS_TEST;

ERROR 1529 (HY000): Failed to drop TABLESPACE

DROP TABESPACE TBS_TEST CASCADE ; ---also got ERROR

So, is it possible to drop tablespace CASCADE in MySQL?

2

According to the documentation it is not possible:

https://dev.mysql.com/doc/refman/5.6/en/drop-tablespace.html

Important
The tablespace to be dropped must not contain any data files; in other   
words, before you can drop a tablespace, you must first drop each of its 
data files using ALTER TABLESPACE ... DROP DATAFILE (see Section 13.1.8, 
“ALTER TABLESPACE Syntax”).

You can however locate the files that has to be dropped first, via INFORMATION_SCHEMA.FILES:

select ... 
from INFORMATION_SCHEMA.FILES 
where TABLESPACE_NAME = ?

I'm not able to test this since I don't use any of the engines that support tablespaces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.