iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-24-2006, 02:40 PM
WebProWorld Pro
 
Join Date: Jul 2004
Location: Irvine, CA
Posts: 125
spenland RepRank 0
Default Complete Newbie SQL Question. How to copy an existing table?

Ok let me begin by saying I am a complete newbie when it comes to databases. They scare me :| Well not really but they just confuse me more than anything. I need to duplicate an existing table in PHPmyAdmin into another new table.

Now this new table will be exactly the same except for the fact that one field (the product ID) will be different but all else would be the same.

Would it be easier to copy the existing table and enter the changes manually, or create a new table from scratch and upload new data into the table.

Again I apoligize for my ignorance, I am a web designer just starting to get into databases :)

Thanks!
Reply With Quote
  #2 (permalink)  
Old 01-25-2006, 10:58 AM
WebProWorld 1,000+ Club
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 1,782
cyanide RepRank 0
Default

Hi,
It would be best and easiest to just make a copy of the table.
Export the table using phpMyAdmin, then copy the output into text file.

Then in order to make it unique, you just have to change the table name.
The first line might be something like
Code:
CREATE TABLE `table_name` (
so, change it to
Code:
CREATE TABLE `new_table` (
But also don't forget to change the INSERT statements, if there is data, so they reflect the new table name
example, from
Code:
INSERT INTO `table_name`
to
Code:
INSERT INTO `new_table`
Then copy all the text in this file and import it into the database. Make sure you backup your enire database before proceeding with all of this
Reply With Quote
  #3 (permalink)  
Old 01-25-2006, 01:43 PM
WebProWorld Pro
 
Join Date: Jul 2004
Location: Irvine, CA
Posts: 125
spenland RepRank 0
Default

Thanks cyanide. Write before your post I figured out another way to do it.

If you select the database you want to copy, then click the "Operations" tab there is a choice to copy the existing database into a new one with either the same structure, same data, or both! And best of all I don't have to code anything! Yeaaaaaaaaah
Reply With Quote
  #4 (permalink)  
Old 01-26-2006, 08:00 PM
WebProWorld 1,000+ Club
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 1,782
cyanide RepRank 0
Default

Nice, glad you figured out a way to get it done -
__________________
|
Web Hosting Guru
| Need Help For Your Forum?
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:26 AM.



Search Engine Optimization by vBSEO 3.3.0