Copyig a table from one database to another

Discussion in 'PHP' started by oo7ml, Sep 28, 2007.

  1. #1
    hi, i often find myself copying (exporting) tables from one site (database) to another. I export the table in phpMyAdmin using the export SQL. I then copy the code exported and paste it into the an SQL query on the other site in phpMyAdmin, however i was wondering is it necessary to copy and paste all of the code that is exported. Do i need to copy and paste the code below between the HERE and HERE tags. Thanks for your help

    HERE
    -- phpMyAdmin SQL Dump
    -- version 2.10.0.2
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost


    -- Generation Time: Sep 28, 2007 at 10:52 AM
    -- Server version: 5.0.27
    -- PHP Version: 4.4.4

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

    --
    -- Database: `database_database`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `accounts`
    --
    HERE


    CREATE TABLE `accounts` (
    `id` int(8) NOT NULL auto_increment,
    `firstname` char(20) NOT NULL,
    `lastname` char(20) NOT NULL,
    `username` varchar(20) NOT NULL,

    etc...
     
    oo7ml, Sep 28, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    All lines that begin with two dashes (-) are comments and are not necessary. However, what I do is just put the cursor in the text area and click CTRL + A to select all text and then CTRL + C to copy it. It's way faster than selecting and copying the text manually. :D
     
    nico_swd, Sep 28, 2007 IP
  3. oo7ml

    oo7ml Well-Known Member

    Messages:
    656
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #3
    Ok thanks... but there is one line without the two dashes (-). Is that important

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
     
    oo7ml, Sep 28, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    This is from dev.mysql.com:

    http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html

    So it's up to you and your table structure, whether you want to use it or not.
     
    nico_swd, Sep 28, 2007 IP