I am converting a product built on SQL Server to Oracle 9i, and looking at differences between the two. One difference...
that will have a big impact is case sensitivity. The SQL Server database is set up as case insensitive, so we can group and combine output based on character data spelled the same but not necessarily with the same case. In other words WHERE FIRSTNAME = 'JOHN' returns JOHN, john, John, etc. I don't want to use SOUNDEX because I don't want Jon returned. Can Oracle be setup as case insensitive? If so, how?
You can use functions in your WHERE clause to compare:
WHERE UPPER(firstname) = 'JOHN'There is also a LOWER() function and a INITCAP() function. Take your pick. That way no matter what the case of the value stored in the table, you'd always be comparing like case.
Using these functions however will cause indexes not to be used properly. So, you'd have to look into function-based indexes to maintain performance.
You could also force all data stored in the database to be stored in one case (for instance, all UPPER case). When you migrate your data you'd have to clean it all up to be all UPPER case and then after that you could simply write a BEFORE trigger to change the case the user enters to the case you wish to store.
CREATE OR REPLACE TRIGGER emptable_chg_case BEFORE INSERT OR UPDATE ON emp FOR EACH ROW BEGIN :new.ename := UPPER(:new.ename) ; :new.job := UPPER(:new.job) ; END ; /You'd simply include each text column for which you wish to control text into the trigger body code and when the user inserts or updates data in those columns the values they enter will automatically be changed to UPPER case.
For More Information
- Dozens more answers to tough Oracle questions from Karen Morton are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.