Toad World® Forums

Drop Primary Key in Alter Script for MySQL


#1

(TDM 3.4.10.2)

Hi

I’ve created an Alter script on MySQL 5.1 database. When the script tries to drop the tables, it first drops the indexes, then the Primary key and then the table.

I get an error when it tries to drop the Primary Key, because the AutoIncrement value is still set to True.

Am I doing something wrong with the alter script creation or should the alter table statement for the AutoIncrement value to be removed rather be added.

Currently I have to drop ALL the AutoIncrement values in my diagram and then add them again after creating the script. Dropping them is easy by using JScript, but adding them must take place manually (busy building a bigger script) because not all my primary keys are autoincrement fields.

Best Regard
Rudi


#2

Hi Rudi,

You don’t do anything wrong. It is how it works now.
We will see what we can do about it. CR # 65 987.

Unfortunately, there’s no workaround at the moment either. However, we will try to make one for you. I need to ask you for patience. Thanks!

Regards,

Vladka + TDM Team


#3

Hi Vladka

Thank you for letting me know. No problem, I’ll be patient with this one.

Best Regards
Rudi


#4

Hello Rudi,

Please find attached a new script that might help you a little.
The script executes function DisableAutoincrements that drops autoincrements and writes to a file the ID of entities and attributes where there was the autoincrement.
If you comment execution of the function and enable execution of function EnableAutoincrements, the script will do the opposite - it will go through the file and set up the autoincrements back.

If you have any questions, please write us back. Thanks!

Regards,

Vladka + Mario
EnabledDisableAutoincrement_MySQL.js (1.62 KB)