Hello,
I have to get the output for mysql show create table and write it to one file for each table that I have. How would I do this? Im guessing  stored procedures would help in some way?
Getting mysql show create table on more then one table?
Hello Richard,
As I understand you want to write the output of each create table statement in a separate file.
There are several ways of doing it –
-
You can use a stored procedure or any programming language like PHP, Java and execute some commands.
-
SHOW TABLES IN <YOUR-DATABASE-NAME>.
-
Loop on the output of above command, extract table name in each iteration and execute SHOW CREATE TABLE <TABLE-NAME>, write each statement in a separate file.
-
Execute from command line mysqldump command (For each dumped table, a tbl_name.sql file be created.)
-
mysqldump -u [username] -p -T[/path/to/directory] [database] –no-create-db –no-data
-
Replace [username] with the MySQL username
-
[/path/to/directory] with the path to the directory where data will exported to.
-
[database] the name of the database from which all tables will be exported.
I would suggest trying second option as its quicker and easier.
Regards,
Mclean