Comparison
Values whose types are CHAR
are compared by trimming white spaces from their right side.
create table tq84_char (
id integer,
txt char(10) unique
);
Two records are inserted. Note the trailing spaces in the value of def
:
insert into tq84_char values (1, 'abc' );
insert into tq84_char values (2, 'def ');
The following statement throws ORA-00001: unique constraint (‥) violated:
insert into tq84_char values (3, 'abc ');
The following three select statements return one record each:
select id from tq84_char where txt = 'abc' ;
select id from tq84_char where txt = 'abc ';
select id from tq84_char where txt = 'def ' ;
This statemnt does not return a record:
select id from tq84_char where txt = ' def' ;
drop table tq84_char purge;