SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Copy to a new table

    Hi,

    This is very similar to what copy table in phpMyAdmin. I need to copy the schema of one table and create a new one with that schema, only with another name, automatically. How would I go about doing it?

    Thanks
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  2. #2
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think this can be done using the CREATE TABLE ... SELECT syntax... i'm not a SQL guru but i've read about this before...

    maybe an advisor could move this into the Files, Databases, XML forum... we've some SQL experts there

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Moved

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you want the data in the copy or just the schema? you can do what redemption said to copy the table:

    Code:
    CREATE TABLE table2 SELECT * FROM table1
    if you just want the schema, i dunno. just delete the data out of the copy:

    Code:
    DELETE FROM table2
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  5. #5
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haha
    Smart solution!!!
    I'll try that.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •