MySQL Auto-Increment – Risk of Importing Data with Higher IDs

auto-incrementMySQL

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 ;

Best Answer

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.