Character Replace in Oracle SQL

In my sql query I am pulling all the email address from my company; example
We are changing our domain to

Want to know if there is a way for me to search for the string and replace it with in my query?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

johnsoneSenior Oracle DBACommented:
The REPLACE function should do what you need.
slightwv (䄆 Netminder) Commented:
First:  You should ask Oracle questions in the Oracle Database Topic Area.  Some of us don't monitor other areas and can easily miss questions.  I've changed the Topic Areas for you.

You really don't provide enough information.

Do you have stored procedures/functions/packages that have that email address in them that you want to replace?
Do you have a folder in some OS that has a lot of scripts that you wish to replace?

If in Oracle code, you can use a query against user_source to find the code that has the domain:
select name, type from user_source where lower(text) like '';

Then you can use dbms_metadata.get_ddl to extract the actual DDL, to a simple replace with your favorite editor and re-execute the DDL.
Doug WaltonDatabase AdministratorCommented:
Just to add to what was said already, it would end up looking something like this:

select <email column>, REPLACE(<email column>,'','') from <table name> where <email column> like '';
update <table name> set <email column> = REPLACE(<email column>,'','') where <email column> like '';

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
slightwv (䄆 Netminder) Commented:
>>it would end up looking something like this:

The assumption is they are using a single email address column in a table or series of tables.  The problem is more involved if there is the possibility of more than one column in a table that might contain the email address.

It also assumes is the entire end of the field.  If you are updating a column where the email address can exist in blocks of text, the above statements won't work.  You will need to double-ended wildcard in my example.
slightwv (䄆 Netminder) Commented:
I used it in my example but thought I should make sure I mention it:  The REPLACE commands mentioned don't account for the case of the email addresses.  You might need to use the UPPER or LOWER functions to make sure you find everything and again with the replace to make sure you replace everything.

So, Doug's update statement will be:
update <table name> set <email column> = REPLACE(lower(<email column>),'','') where lower(<email column>) like '';

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.