czuroski
czuroski

Reputation: 4332

trouble deleting from mysql

I am fairly new to using mysql. I have an application that performs some basic querying. I am also trying to run a simple delete statement -

delete from mydb.mytable

This table is a simple 2 column table with not keys or triggers or anything defined. For some reason, the delete is not being performed. If I run the statement from MySql Workbench in the query window, it works fine. From the code, it does nothing. I am not seeing any error messages. I created a user with select, insert, update and delete rights to the schema. I am able to do the insert fine, but the delete does not seem to be working.

Is there a setting for mysql that I am missing that will not allow me to perform the delete? Thanks for any thoughts.

Upvotes: 1

Views: 295

Answers (3)

a1ex07
a1ex07

Reputation: 37354

Fist of all, check if

  • you are connected to the right database ;
  • you are using transaction and forgetting 'commit' ;
  • the user you use have enough permissions to delete from the table .

As a side notice, if you want to delete all records, you should use truncate instead of delete

Upvotes: 1

Intercepted
Intercepted

Reputation: 1

We would have to see some of your code to answer the question.

My guess is that you are not calling commit from your code. You can configure MySQL to auto-commit your queries, but this is usually not what you want.

Upvotes: 0

netcoder
netcoder

Reputation: 67695

Are you using transactions? My first guess is that your code might be issuing a BEGIN TRANSACTION without a COMMIT.

Upvotes: 0

Related Questions