1

I have to import data into a new database. That new database already has a small set of data. I have two large tables I need to import in there.

Is there any risk of a higher id getting over written or causing problems later as new data comes in?

This is the current setup of the database tables.

-- phpMyAdmin SQL Dump
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

Table websites

    CREATE TABLE IF NOT EXISTS `url` (
      `id` int(20) NOT NULL AUTO_INCREMENT,
      `userid` int(16) NOT NULL DEFAULT '0',
      `alias` varchar(10) NOT NULL,
      `special` varchar(160) NOT NULL,
      `website` text NOT NULL,
      `city` text NOT NULL,
      `story` text NOT NULL,
      `date` datetime NOT NULL,
      `pass` varchar(255) NOT NULL,
      `click` bigint(20) NOT NULL DEFAULT '0',
      `meta_title` varchar(255) NOT NULL,
      `meta_description` varchar(255) NOT NULL,
      `ads` int(1) NOT NULL DEFAULT '1',
      `bundle` mediumint(9) NOT NULL,
      `public` int(1) NOT NULL DEFAULT '0',
      `archived` int(1) NOT NULL DEFAULT '0',
      `type` varchar(64) NOT NULL DEFAULT '',
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=127878 ;

Table statistics

    CREATE TABLE IF NOT EXISTS `scores` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `shorr` varchar(255) NOT NULL,
      `curlid` bigint(20) NOT NULL,
      `curluserid` bigint(20) NOT NULL DEFAULT '0',
      `date` datetime NOT NULL,
      `ip` varchar(255) NOT NULL,
      `country` varchar(255) NOT NULL,
      `website` varchar(50) NOT NULL,
      `referal` text NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1807671 ;
  • your old table also has the same structure? – Masoud Jun 19 '15 at 4:00
  • They have the same structures. – JediTricks007 Jun 19 '15 at 4:06
  • and the ids on the old table does not overlap the ids in new table? – Masoud Jun 19 '15 at 4:07
  • None of the ids overlap. – JediTricks007 Jun 19 '15 at 4:08
1

As soon as you insert the data in new table, your next auto_increment value will be Max(id) + 1. Which means if you insert new row, the id given will be highest number in the id column. This post may be relevant to your question.

2
  1. LOAD the new data into a separate table (staging), without including the AUTO_INCREMENT field.
  2. Decide whether there are any duplicates that need to be avoided.
  3. INSERT ... SELECT (without id) to copy the "new" data into the real table.
  4. DROP TABLE staging;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.