HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

Commands like CREATE, GRANT, DROP always return "0 rows affected"

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
rowscreatecommandsreturnalwaysgrantlikedropaffected

Problem

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.

Solution

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.

Context

StackExchange Database Administrators Q#44812, answer score: 10

Revisions (0)

No revisions yet.