开发者

Oracle 10G case insensitive columns

开发者 https://www.devze.com 2023-03-25 11:10 出处:网络
Oracle Newbie Here:开发者_StackOverflow社区 I just started out creating my first Oracle database table.

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

精彩评论

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

关注公众号