开发者

Oracle 10G case insensitive columns

Oracle Newbie Here:开发者_StackOverflow社区

I just started out creating my first Oracle database table. I have downloaded the Oracle 10G Express Edition

CREATE TABLE  "EMPLOYEE_INFO" 
(   "ID" NUMBER(5,0) NOT NULL ENABLE, 
"FIRST_NAME" VARCHAR2(50), 
"LAST_NAME" VARCHAR2(50), 
"SEX" VARCHAR2(1), 
"BIRTHDAY" DATE, 
 CONSTRAINT "EMPLOYEE_INFO" PRIMARY KEY ("ID") ENABLE
)

Is there a way that I could make the table "case-insensitive"? I notice that when you insert data in the column SEX = 'm' and I perform a query such as

select * from
EMPLOYEE_INFO where
sex = 'M';

This does not return any data.

Sorry if my question is very elementary, its my first time to use Oracle DB. Thanks


You can try with upper (or lower):

Select *
from employee_info
where upper(sex)='M'

But be careful, if you have an index in sex, you will lose it! If your sex column is mixed case and you need a function, you can create a Function Based Index on either UPPER(SEX) or LOWER(SEX). If 'M' can be a lower case too, you need to add upper too:

Select *
from employee_info
 where upper(sex)=upper(:parameter)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜