How to copy tables from one database to another?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
limonada
Forum Newbie
Posts: 11
Joined: Sat Oct 08, 2005 7:23 am

How to copy tables from one database to another?

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
limonada
Forum Newbie
Posts: 11
Joined: Sat Oct 08, 2005 7:23 am

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

DESCRIPT `tableName`
limonada
Forum Newbie
Posts: 11
Joined: Sat Oct 08, 2005 7:23 am

Post by limonada »

:? i found nothing about DESCRIPT 'tablename' in the mysql reference manual ...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

oops.. DESCRIBE. not sure how I wrote descript :?
limonada
Forum Newbie
Posts: 11
Joined: Sat Oct 08, 2005 7:23 am

Post by limonada »

:) i found it...thanks!
Post Reply