I have table called "users" 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 ?
我有一个名为“用户”的表,我想制作一个精确的副本作为“users_2”,只考虑结构而不是内容。我想用PHP做这个,因为我没有访问phpMyadmin或mysql控制台。你知道怎么做吗?
2 个解决方案
#1
13
After connecting to your database appropriately in php (mysql_connect):
在php(mysql_connect)中正确连接到数据库之后:
mysql_query("create TABLE tablename like SRCTABLE");
mysql_query(“创建TABLE表名,如SRCTABLE”);
#2
2
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.
您可以使用SQL SHOW CREATE TABLE users命令,其结果是一个CREATE TABLE语句,您可以在其中用user_2替换用户并执行。
#1
13
After connecting to your database appropriately in php (mysql_connect):
在php(mysql_connect)中正确连接到数据库之后:
mysql_query("create TABLE tablename like SRCTABLE");
mysql_query(“创建TABLE表名,如SRCTABLE”);
#2
2
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.
您可以使用SQL SHOW CREATE TABLE users命令,其结果是一个CREATE TABLE语句,您可以在其中用user_2替换用户并执行。