1 / 3
Caption Text
2 / 3
Caption Two
3 / 3
Caption Three margin testing

Thursday, May 21, 2009

How to drop many tables with same prefix in MySQL

Put the following into a file called get_table_names.sql :
use db;
show tables where tables_in_db like 'myPrefix_%';
Replace "db" with your database name in both lines of the file.
Mysql names the output column "tables_in_[database_name]".

Then execute at the shell command prompt:
mysql -u dbuser -p < get_table_names.sql > table_list

Then edit the file table_list to make each line a drop table commandt:
drop table myPrefix_1;
drop table myPrefix_2;

Now execute the MySQL commands in file table_list:
mysql -u dbuser -p db <table_list

Featured Post

Windows和Ubuntu双系统完全独立的安装方法

http://www.ubuntuhome.com/windows-and-ubuntu-install.html  | Ubuntu Home Posted by Snow on 2012/06/25 安装Windows和Ubuntu双系统时,很多人喜欢先安装windows,然...