Dylan Dylan - 1 year ago 110
SQL Question

MySQL - Can aborting a query with Ctrl-C harm the table?

Some of my queries were taking way too long, including some

alter table
queries, so I pressed Ctrl-c to abort them and continue with other matters.

One that I aborted was
alter table labs modify ID int(11) first

Now quite simple queries like
alter table labs drop column ID
are taking forever. I've been waiting for over 25 minutes. There are millions of records, but I've run similar
alter table
queries on the same table that only take a few seconds.

Can aborting queries harm the column that the query was operating on? If so, how can I recover from the problem?

Update: I am nuking a primary-key column. Could that have something to do with the insanely long running time?

Answer Source

If the transaction wasn't completed, no. MySQL does ALTER TABLE by creating a new table and then updates the reference to the old table. You shouldn't have altered your original table if you interrupted the original ALTER TABLE query.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download