I have looked around and can't find an answer to this.
I was wondering if there is a way in MY SQL Workbench where you can add a default ORDER BY to every query?
I am looking to ORDER BY id DESC
For example when I 'Right Click' on my table schema and say 'Select Rows' the resulting query is:
SELECT * FROM payments
I would like it to be:
SELECT * FROM payments ORDER BY id DESC
is there a way in MY SQL Workbench where you can add a default ORDER BY to every query?
No.
What's more, result sets from SQL queries present their rows in a formally unpredictable order in the absence of ORDER BY clauses sufficient to determine the order. A lot of people get tripped up by this: they assume that because a result set appeared in a certain order yesterday, it will appear in the same order today. It does until it doesn't. If a program relies on ordering when it isn't specified in an ORDER BY clause, well, see Murphy's Law.
Ditto for software versions. People sometimes mistakenly believe it's a defect in a new version of a RDMS server like MySQL when it presents results in a different order from the preceding version. It isn't.
This can help performance. Ordering can be a time- and space- hog of an operation. When the query planner knows it doesn't have to order rows in a result set, it can just present them in whatever order it finds them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With