Page 1 of 1

How to copy tables from one database to another?

Posted: Sat Oct 08, 2005 7:43 am
by limonada
Hello! I have a problem: i need to make a php function: function copy_tables($database,$tables) which allows you to copy the $tables from a certain database to the $database passed as parameter.My problem is that i don't know how to copy the tables and the table structure from one database to another.I don't need to copy the data in the tables,just the tables and the table structure (field names).Can you help me with this? If it's not clear what i want,please say and i'll try to explain it again.I really need your help! Thanks!

Posted: Sat Oct 08, 2005 7:52 am
by feyd
here's a push in the right direction:

Code: Select all

SHOW CREATE TABLE `tableName`
http://dev.mysql.com/doc/mysql/en/show- ... table.html

Posted: Sat Oct 08, 2005 8:09 am
by limonada
thanks but...this doesn't help me ...I know how to create a table..... how do i know the field names in the original table?

Posted: Sat Oct 08, 2005 8:26 am
by feyd

Code: Select all

DESCRIPT `tableName`

Posted: Sat Oct 08, 2005 9:35 am
by limonada
:? i found nothing about DESCRIPT 'tablename' in the mysql reference manual ...

Posted: Sat Oct 08, 2005 9:39 am
by feyd
oops.. DESCRIBE. not sure how I wrote descript :?

Posted: Sat Oct 08, 2005 9:47 am
by limonada
:) i found it...thanks!