Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate mysql queries

Tags:

Is there a way to test the mysql queries, without modifying my database?

For example, can I run a delete from my_table where id=101 without actual delete anything? What about insert and update?

TY

like image 857
dole doug Avatar asked Sep 28 '11 10:09

dole doug


People also ask

Where can I practice MySQL queries online?

You can test your MySQL skills with W3Schools' Exercises.

Where can I test MySQL query?

MySQL and SQL Online Test | TestDome.

What is MySQL slap?

mysqlslap is a diagnostic program designed to emulate client load for a MySQL server and to report the timing of each stage. It works as if multiple clients are accessing the server.

Can MySQL work online?

MySQL Online is online editor and compiler. C, C++, Java, Ruby, Python, PHP, Perl,... More than 20 languages are supported. You can use for learn programming, scrape web sites, write batch, etc...


2 Answers

You could start a transaction before running your queries and then rollback after running them. Note that to do this you'll require InnoDB or XtraDb tables (won't work on MyISAM).

To start a transaction send to MySQL the following statement:

START TRANSACTION; 

And at the end of your queries run the following statement:

ROLLBACK; 

Your database will never be modified from the point of view of other connections. Your current connection will see the changes until ROLLBACK, and after that the original state will be restored.

like image 171
stivlo Avatar answered Nov 07 '22 21:11

stivlo


If you just want to see how many rows would be deleted why not substitute 'delete' with 'select count(*)'?

like image 41
blankabout Avatar answered Nov 07 '22 20:11

blankabout