It gives you the correct syntax to create an exact structural duplicate of the table with.
I've done a bit more looking, and it'll be easier to just use "DROP TABLE IF EXISTS `backup`.`table`" and "CREATE TABLE `backup`.`table` SELECT * FROM `main`.`table`", which will take care of making sure the structure and the data's the same in one command instead of three. See http://dev.mysql.com/doc/refman/5.1/en/create-table.html for more information on using SELECT with CREATE TABLE. On 22/07/2010, at 9:20 AM, Brendan Brink wrote: > thanks simon, what does the show create table accomplish? > > On Thu, Jul 22, 2010 at 9:10 AM, Simon J Welsh <[email protected]> wrote: >> If you can use exec, or similar: >> >> <?php >> >> `mysqldump -u user --password=<password> database | mysql -u user >> --password=<password> backup_database` >> >> Alternatively, connect, grab all tables, foreach table use 'SHOW CREATE >> TABLE `tablename`', drop the table from backup, if it exists, create the new >> one in backup, INSERT INTO `backup`.`table` SELECT * FROM `main`.`table` >> >> On 22/07/2010, at 8:55 AM, Brendan Brink wrote: >> >>> Hi there, >>> >>> Can someone please give a recommendation? >>> >>> I am wanting to write a php script that will automatically backup one >>> database to another database at regular intervals. >>> >>> Perhaps something someone has used in past and proved useful would be >>> much appreciated. >>> >>> Cheers >>> brendan. >>> >>> -- >>> NZ PHP Users Group: http://groups.google.com/group/nzphpug >>> To post, send email to [email protected] >>> To unsubscribe, send email to >>> [email protected] >> >> --- >> Simon Welsh >> Admin of http://simon.geek.nz/ >> >> Who said Microsoft never created a bug-free program? The blue screen never, >> ever crashes! >> >> http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e >> >> >> >> >> -- >> NZ PHP Users Group: http://groups.google.com/group/nzphpug >> To post, send email to [email protected] >> To unsubscribe, send email to >> [email protected] > > -- > Kind Regards, > > Brendan Brink > > SMS Marketing Consultant | Manager > Sell2Cell Ltd. > > 021 0246 1646 | [email protected] | www.sell2cell.co.nz > > > > > We provide customized, cost-effective SMS & Web Solutions > Need a website? Need to integrate text-messaging into your business > or website? Contact us today for a free no-obligation quote! > > VISIT OUR ASSOCIATED WEBSITES: textvouchers.com | textguru.co.nz > > WARNING This email contains information which is CONFIDENTIAL and may > be subject to LEGAL PRIVILEGE. If you are not the intended recipient, > you must not peruse, use, disseminate, distribute or copy the email or > attachments. If you have received this in error, please notify us > immediately by return email, facsimile, or telephone (call us > collect). > > -- > NZ PHP Users Group: http://groups.google.com/group/nzphpug > To post, send email to [email protected] > To unsubscribe, send email to > [email protected] --- Simon Welsh Admin of http://simon.geek.nz/ Who said Microsoft never created a bug-free program? The blue screen never, ever crashes! http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e -- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
