Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Update a column of INTs to be the primary key, whilst preserving existing values

adz1111's profile image adz1111 posted 3 months ago in General Permalink

Hi

I'm in the process of converting an old Access database into MySQL. I've successfully imported the various tables over (some quite large).

The Access versions of those tables all have an ID-type column that is a primary key (and auto-incremented). The issue I have is I'm trying to do the same for those equivalent table columns in MySQL.

The thing is, when I make that column a primary key it doesn't preserve the values in those columns (it renumbers them all). I need to make that column a primary key and auto-incrementable BUT without changing the values already there (which are unique integers).

Am I doing something wrong?

Many thanks, in advance.

Adam

adz1111's profile image adz1111 posted 3 months ago Permalink

Ok - please ignore this question.

Major "D'oh!" moment. After revisiting I realised that adding the key didn't renumber everything in that column, it simply sorted the table by that key.

All good, and my bad :-(

Please login to leave a reply, or register at first.




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.