Anyone got any simple code that will back up a SQL database. I could do it myself. First I would need to know how to get all the TABLES from the database with all of there fields. I can then grab all the contents from the table by myself with a select statement.
So how can I grab all the tables from a database and there fields?
backing up SQL database
Moderator: General Moderators
-
psychotomus
- Forum Contributor
- Posts: 487
- Joined: Fri Jul 11, 2003 1:59 am
Do you have access to the command line? If so you can use mysqldump to get a dump file.
If not, do you have phpmyadmin? That can make a dump file too.
If you have none of that, you will, of course, have to do it manually. The first step would be to call a query "show tables". Then, loop through each table calling a query "SHOW CREATE TABLE [table name]" That will output the query needed to recreate [table name]. You can then go through and read in each row into a CSV.
Do try to find a way to make/get a mysqldump file - it's much much much easier.
If not, do you have phpmyadmin? That can make a dump file too.
If you have none of that, you will, of course, have to do it manually. The first step would be to call a query "show tables". Then, loop through each table calling a query "SHOW CREATE TABLE [table name]" That will output the query needed to recreate [table name]. You can then go through and read in each row into a CSV.
Do try to find a way to make/get a mysqldump file - it's much much much easier.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.