O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dropping general tablespace

You can use the DROP TABLESPACE command to drop the tablespace. However, all the tables inside that tablespace should be either dropped or moved:

mysql> DROP TABLESPACE ts2;ERROR 3120 (HY000): Tablespace `ts2` is not empty.

You have to move the partitions p2 and p3 of table table_gen_part_ts1 in the ts2 tablespace to other tablespace before dropping:

mysql> ALTER TABLE table_gen_part_ts1 REORGANIZE PARTITION p2 INTO (PARTITION p2 VALUES LESS THAN (3000000) TABLESPACE ts1);mysql> ALTER TABLE table_gen_part_ts1 REORGANIZE PARTITION p3 INTO (PARTITION p3 VALUES LESS THAN (3000000) TABLESPACE ts1);

Now you can drop the tablespace:

mysql> DROP TABLESPACE ts2;Query OK, 0 rows affected (0.01 sec)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required