开发者

Duplicate mysql table "structure" using PHP only

开发者 https://www.devze.com 2022-12-19 22:04 出处:网络
I have table called \"use开发者_JS百科rs\" and I want to make an exact copy as \"users_2\" as regard the structure only not the content.

I have table called "use开发者_JS百科rs" and I want to make an exact copy as "users_2" as regard the structure only not the content.

I wanna do this using PHP only as I don't have an access to phpMyadmin or mysql console.

Do you have an idea how to do that ?


After connecting to your database appropriately in php (mysql_connect):

mysql_query("create TABLE tablename like SRCTABLE");


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

0

精彩评论

暂无评论...
验证码 换一张
取 消