Nothing ground breaking, but hey, simplicity and basics are the most important.

Reader Rules

Don’t run select * queries without filters

You might not know how big the table you are querying is. Therefore, in order not to negatively impact the performance of the whole system, limit the amount of the query.

Instead of

1
select * from myTable;

use

1
select * from myTable limit 10;

Writer Rules

Use transactions

Even simple & tested queries might have unintentional side-effects.

Any unintended change might lead to a complicated rollback and a lot more complications.

Instead of running single queries, create SQL blocks which are part of a transaction.

1
2
start transaction;
UPDATE myTable SET name = 'New Name' WHERE id in (3, 50, 857);

These changes won’t yet be commited. You will see the output, number of affected rows as well as preview the changes.

If everything went okay and no error was thrown, you can commit these changes:

1
commit transaction;

If, on the other hand, you want to rollback the action:

1
rollback transaction;

Transactions come with many benefits, but one thing to look out for is not to leave a transaction open for too long (such as starting a transaction and going on a break). The longer the transaction is open, the more negative impact it may have.

Owner Rules

Back-up

Back-up, Back-up, Back-up.

Oh, and Back-up.