Duplicate mysql structure table using only PHP

I have a table called "users" and I want to make an exact copy as "users_2" with respect to the structure of just not the content.
I want to do this with PHP only because I do not have access to the phpMyadmin or mysql console.
Do you have an idea how to do this?

+7
php mysql
source share
2 answers

After connecting to database correctly in php ( mysql_connect ):

mysql_query("create TABLE tablename like SRCTABLE");

+13
source share

You can use the SQL SHOW CREATE TABLE users command, its result is the CREATE TABLE statement, in which you can simply replace users with users_2 and execute.

+2
source share

All Articles