- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- In oracle how to query an underscore _ as a litera...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-08-2006 09:37 PM
тАО11-08-2006 09:37 PM
In oracle how to query an underscore _ as a literal underscore
As you probably know in oracle there
are two wildcards % (compared to unix *)
and _ (compared to unix ?)
Now if you have a number of tables which
contain in the name an underscore example:
B1_data
B2_data
...
Bn_data
Then my query to retrieve all the table name
would normally be:
select * from user_tables where table_name like 'B_%'
However this in Oracle retrieves all tables
starting with B and not B_ , as the _ underscore is seen a single character wildcard.
So I get not only
B1_data
B2_data
...
Bn_data
but also the tables
Books_data
Building
Besijit etc..
How to get around this ?
Can I somehow quote the underscore , so it
is seen as a litteral and not as wildcard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-08-2006 09:43 PM
тАО11-08-2006 09:43 PM
Re: In oracle how to query an underscore _ as a literal underscore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-08-2006 11:27 PM
тАО11-08-2006 11:27 PM
Re: In oracle how to query an underscore _ as a literal underscore
the 2nd link didn't even work.
However you inspired me to have a go at google
and I found this
http://www.oraxcel.com/cgi-bin/yabb2/YaBB.pl?num=1159530743/0
tested it and it works.
So thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-08-2006 11:36 PM
тАО11-08-2006 11:36 PM
Re: In oracle how to query an underscore _ as a literal underscore
sorry my answer didn't really help with your problem!
I thought you would understand link syntax of the second link.
You have to remove the
part before the .htm to get the proper page.
Solution on the page:
"SELECT last_name
FROM employees
WHERE last_name LIKE '%A\_B%' ESCAPE '\';
"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-08-2006 11:53 PM
тАО11-08-2006 11:53 PM
Re: In oracle how to query an underscore _ as a literal underscore
"Use of underscore in table and column names.
The underscore is a special SQL pattern match to a single character and should be escaped if you are in fact looking for an underscore character in the LIKE clause of a query.
Just add the following after a LIKE statement:
ESCAPE _
And then each literal underscore should be a double underscore: __ "
The other solution used ! as escape. Same thing.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-09-2006 01:11 AM
тАО11-09-2006 01:11 AM
Re: In oracle how to query an underscore _ as a literal underscore
PS: see my reply to the dbua thread...
Best Regards,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2006 05:43 PM
тАО11-12-2006 05:43 PM
Re: In oracle how to query an underscore _ as a literal underscore
Hein, I did read the Escape _ from Wikipedia,
but that didn't mean anything to me at the time.
Or I was just tool lazy and sought out a lazy hands-on solution,
not a test to crunch my grey cells over,
without knowing what I was doing.
With hindsight having seen a concrete example
it makes sense :)
Thanks all the same