Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to SQL Server's SET NOCOUNT in MySQL?

Does MySQL have an equivalent to SQL Server's SET NOCOUNT ON statement?

like image 349
narenderreddy Avatar asked Aug 02 '10 08:08

narenderreddy


People also ask

What is set Nocount on in mysql?

SET NOCOUNT ON prevents the sending of DONEINPROC messages to the client for each statement in a stored procedure.

Does set Nocount on improve performance?

Using SET NOCOUNT ON can improve performance because network traffic can be reduced. SET NOCOUNT ON prevents SQL Server from sending DONE_IN_PROC message for each statement in a stored procedure or batch of SQL statements.

Do I need to set Nocount off?

Now, is set nocount off necessary? No, as any new commands executed will be in a different scope, and by default set nocount off is always in effect. But as stated above in comments, it's considered a good practice, just to explicitly indicate that this setting will return to normal when the proc is finished executing.

What is set Nocount on in Oracle?

SET NOCOUNT ON/OFF statement controls the behavior in SQL Server to show the number of affected rows in the T-SQL query. SET NOCOUNT OFF – By default, SQL Server shows the number of affected rows in the messages pane. SET NOCOUNT ON – We can specify this set statement at the beginning of the statement.


2 Answers

The SET NOCOUNT ON stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results.

MySQL doesn't report the number of rows affected by a query, therefore there's no such function.

You can if you like find out about the number of affected rows using the ROW_COUNT() function, right after your query:

DELETE FROM mytable WHERE name="John";
SELECT ROW_COUNT();
like image 64
Anax Avatar answered Nov 16 '22 01:11

Anax


There is no equivalent as far as I am aware.

like image 30
spinon Avatar answered Nov 16 '22 03:11

spinon