Silly typing error create database I cannot remove

[expired user #10322]'s profile image [expired user #10322] posted 8 years ago in General Permalink

Hi, I accidentally created a database named "test_db'". Please note the ' character in the name of the database. (My fingers are always all over the keyboard..)

But now I cannot remove the database again! When i right-click on the database i HeidiSql and select Drop database, it says it does not exist.

Nothing serious as you can see, but irritating to have it in the list of databases.

Oh, a bit serious it might be, since I then created a second database named "test_db", and when I tried to delete the old "test_db'" (the one with a ' in the name) HeidiSql instead deleted "test_db" !

kalvaro's profile image kalvaro posted 8 years ago Permalink

Nice catch! Apparently, HeidiSQL discards the quote after creating the database:

[Window Title]
~root: Confirm

[Main Instruction]
Drop Database "test_db"?

[Content]
WARNING: You will lose all objects in database test_db!

[OK] [Cancel]

... and then attempts to run:

DROP DATABASE `test_db`;

You are lucky if you didn't have an existing database with that other name...

As a workaround, you can run the correct query yourself, i.e.:

DROP DATABASE `test_db'`;
Code modification/commit 50d74d9 from ansgarbecker, 8 years ago, revision 9.4.0.5136
Fix sloppy regular expression in TDBConnection.DetectUSEQuery which removes too much of trailing quotes in a database name. See http://www.heidisql.com/forum.php?t=22743
ansgar's profile image ansgar posted 8 years ago Permalink

Fixed in r5136

ansgar's profile image ansgar posted 8 years ago Permalink

... the fix was not to remove trailing quotes from the database name in a regular expression. So, you should be able to have quotes in a database name as you want or as the server allows that.

[expired user #10322]'s profile image [expired user #10322] posted 8 years ago Permalink

Thanks! No, nothing serious happened, I have a local copy of everything on which all work are done.

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