SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Sep 2006
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Export DB tables with and without data

    I have a database with approx 100 tables. I want to write a process that exports this database as a .sql file.

    Easy enough right? Well... maybe not. I want some of the tables to export the data inside them, and other tables to export as empty with keys set to 0.

    I'm using php but a ssh command would work fine as well.

    Thanks in advance for any guidance or suggestions you may be able to provide.

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might be worth having a look at the mysqldump utility. This allows you to dump structure and data and allows a wealth of options. Although to get the flexibility you want you might need to execute it a number of times.

  3. #3
    SitePoint Evangelist
    Join Date
    Sep 2006
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What if a different approach was used?

    What if I just copied (and renamed) the entire database and ran 'EMPTY' on all the tables I wanted emptied?


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
  •