Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accent and case insensitive COLLATE equivalent in Oracle

Tags:

oracle

In Microsoft SQL Server, if I want to search case insensitively in a case-sensitive database, I can run the following SQL:

SELECT * FROM MyTable
WHERE MyField = 'BobDillon' COLLATE Latin1_General_CI_AI

And that will find all "bobdillon" entries.

If I want to do the same in Oracle, I know I can do this:

SELECT * FROM MyTable
WHERE UPPER(MyField) = 'BOBDILLON'

But I want to know if there is a direct equivalent to the collate keyword, so I can search for case sensitivity and accent sensitivity as I see fit.

like image 616
Jonathan Avatar asked Feb 03 '09 15:02

Jonathan


People also ask

Which collation is case-insensitive?

SQL Server is, by default case insensitive; however, it is possible to create a case sensitive SQL Server database and even to make specific table columns case sensitive.

How do you do case-insensitive comparison in Oracle?

Starting with Oracle Database 10g Release 2 you can use the initialization parameters NLS_COMP and NLS_SORT to render all string comparisons case insensitive. We need to set the NLS_COMP parameter to LINGUISTIC, which will tell the database to use NLS_SORT for string comparisons.

Is Oracle schema case-sensitive?

Oracle names aren't case sensitive. PostgreSQL names are case sensitive. By default, AWS SCT uses object name in lower-case for PostgreSQL. In most cases, you'll want to use AWS DMS transformations to change schema, table, and column names to lower case.

How do you match case-insensitive in SQL?

To do a case-insensitive comparison, use the ILIKE keyword; e.g., column ILIKE 'aBc' and column ILIKE 'ABC' both return TRUE for 'abc' . In contrast, MySQL and MS SQL Server have case-insensitive behaviors by default. This means WHERE column = 'abc' returns TRUE for e.g., 'abc' , 'ABC' , or 'aBc' .


1 Answers

SELECT *
FROM MyTable
WHERE NLSSORT(MyField, 'NLS_SORT = Latin_AI') = NLSSORT('BobDillon', 'NLS_SORT = Latin_AI')
like image 134
Quassnoi Avatar answered Nov 15 '22 06:11

Quassnoi