Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I was considering why some special commands in mysql like create user, grant privileges, drop user when correct passed return "0 rows affected", which is not true! (rows in mysql db are affected indeed)

I know there are not standard queries, but if we do delete from user where ... on mysql database, we will see N rows affected.

so it's countable in rather easy way.
otherwise response "Query OK (0.00 sec)" will be much accurate.

or am I missing sth? I verify above with a few mysql version 5.1-5.5.

share|improve this question

migrated from stackoverflow.com Jun 19 '13 at 2:39

This question came from our site for professional and enthusiast programmers.

2 Answers 2

The way mysql works is this ...

Performing INSERTs, UPDATEs, DELETEs explicitly names tables

SQL Commands that do not explicitly name tables have 0 row(s) affected

Such commands that echo 0 row(s) affected include

  • CREATE USER
  • GRANT/REVOKE
  • CHANGE MASTER TO (to Setup MySQL Replication)

I suppose this has always been the case.

share|improve this answer
    
Link to support answer : bugs.mysql.com/bug.php?id=64313 & dev.mysql.com/doc/refman/5.5/en/grant.html –  Abdul Manaf Jun 19 '13 at 6:34

You're right it's a little bit confusing but it's not a bug. See MySQL Documentation for the TRUNCATE command:

Truncation operations do not return a meaningful value for the number of deleted rows. The usual result is “0 rows affected,” which should be interpreted as "no information".

Max.

share|improve this answer
    
This is actually a problem of the SQL client rather than "MySQL" itself. Not all clients behave this way. –  a_horse_with_no_name Jun 19 '13 at 6:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.