Re: The LIKE operator and charsets/collations
Posted by: Alexander Barkov
Date: December 01, 2006 04:50AM

Yes, LIKE operator works according to collations of its arguments.
This behaviour is conformant to the SQL standard.
IF the collation is case insensitive, then LIKE is done
case insensitively.


latin1_spanish_ci is case and accent insensitive.
You can see its chart here:

http://myoffice.izhnet.ru/bar/~bar/charts/latin1_spanish_ci.html

If you need different accents to be non-equal for LIKE,
you need to use a case and accent sensitive collation.
For example, latin1_bin.

There are two possibilities:

1. Use latin1_bin in CREATE TABLE:
CREATE TABLE t1 (c1 VARCHAR(128) CHARACTER SET latin1 COLLATE latin1_bin;

However, "SELECT c1 FROM t1" will return data in binary order,
which is not very good.


2. An alternative better way is to use latin1_spanish_ci in CREATE TABLE:
CREATE TABLE t1 (c1 VARCHAR(128) CHARACTER SET latin1 COLLATE latin1_spanish_ci;
which will provide good sorting order.

Then, you can use COLLATE clause in your queries with LIKE expression:

SELECT c1 FROM t1 WHERE c1 LIKE 'string' COLLATE latin_bin;

Options: ReplyQuote


Subject
Views
Written By
Posted
2632
m p
November 29, 2006 05:11AM
Re: The LIKE operator and charsets/collations
1729
December 01, 2006 04:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.