Suppose you want to add a table to a MySQL database that looks exactly like a MySQL table that already exists. Maybe you just need to adjust some fields or add a few columns . Just type in the following MySQL query:
SHOW CREATE TABLE registrations
and if a table called registrations exists in the database you previously selected, you might get something like this as the result:
CREATE TABLE `registrations` (`user` varchar(10) default NULL,`activationcode` varchar(30) default NULL,`TIMESTAMP` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,`registered` tinyint(1) default NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8
This comes in handy, if you need to need to clone an existing PHP application very fast.
Slightly related note: If you don’t want other users on your system to clone your MySQL tables and hijack your MySQL account to use it with their web application, don’t put your MySQL passwords in PHP files that are readable system-wide. Additional bonus points, if you put the files that contain the password in a file beyond the document root of your webserver. Also note: In some cases you just need to give access to everyone due to the setup of your webserver. This is of course save, if you trust every user on your system ;).
Shameless plug: If this post was useful to you, please consider buying yourself something from one of my Amazon stores: US store, UK store, FR store, DE store, CA store. If you're not into Amazon, why not donate something to GNOME, Mozilla or Wikipedia? Thank you!


