Mysql – Commands like CREATE, GRANT, DROP always return “0 rows affected”

MySQL

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.

Best Answer

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.