The Oracle Database Order by syntax is case sensitive

We just came across a issue that took one of our developers a longer time to figure out and is regarding the "order by" syntax in use with a Oracle Database 10g R2.

When using a:

SELECT myname FROM mydb ORDER BY myname

and you have different cases in the "myname" field (Example: Oracle, oranges, adventure, Business) then the above query would give you a result that would look like this:

Business

Oracle
adventure
oranges

As you can see the word "adventure" is at the "end" of all the values that are writing in upper case. The reason for this is because as by default the Oracle Database is case sensitive.

To get the correct order you will have to wrap the "Order By" with the lower() function, like:

SELECT myname FROM mydb ORDER BY lower(myname)

 

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags:

About Razuna

This is the official blog of the Open Source Digital Asset Management System - Razuna. Razuna is the incredible easy way to manage all your Digital Assets. As the Open Source Alternative to Digital Asset Management (DAM) System you can save up to 90% with Razuna compared to any proprietary System. By using Razuna you get the benefit of it being free and open source and supported by a professional company. There are many options to try out Razuna today! Either, download your own version, create a free account on our Razuna Hosted Platform or get your own Razuna Cloud Server.

No comments yet.

Leave a Reply

You must be logged in to post a comment.