I frequently need to find a table in a particular SCHEMA, or even just anywhere in the database, that stores data of a specific datatype. This generally happens when a customer asks me, ‘Hey, does Toad support the ANYDATA|LONG RAW|CLOB|BLOB datatype?’
So I decide to find said table and just show them what the application can do with a real example. Unfortunately I usually need to go to the editor and run a query to find a table ‘manually.’ I do have a Named Query to help me do this:
select distinct owner, table_name from dba_tab_cols x where X.DATA_TYPE = :Type order by 1, 2;
So case closed, right?
Not quite darling! I am your prototypical developer in at least one area: I am very, very, very lazy. So what’s a Toadie to do?
Customize the Schema Browser
Instead of just running a query in the editor, I’m going to code a custom filter in the browser for the ‘Tables’ page that allows me to just see tables that contain the type of data I want to play with. Then I can just immediately start clicking into the table right there in the browser. To do this I need to use the ‘Custom Filter’ feature.
Here’s a list of steps:- Click on the filter dialog – the little funnel button
- Click the ‘Custom Filter (Use View/Edit Query to adjust) checkbox
- Click the ‘View/Edit Query Before Executing’ checkbox
- Add an additional WHERE clause
- Save the filter
- Reopen the ‘View/Edit Query’ dialog whenever you need to change the datatype
After checking the ‘View/Edit Query’ and clicking on ‘OK’, we get the following dialog. The selected text is what I’ve added to help me with my search.
Once you click ‘OK’, Toad will re-query the data dictionary and bring back the list of tables that have ‘CLOB’ datatypes. To make this re-usable, we now need to check re-click the filter dialog and Save the filter. Next time I’m looking for tables with TIMESTAMPS, I’ll just re-open the filter and change the query to probably something similar to … LIKE ‘TIMESTAMP%’
Confession
It took me about an hour to figure this out. It was the ‘Custom Filter’ check that was eluding me. Only after getting some help from the developer was I able to figure it out. Even after supporting Toad for 10 years, I don’t know everything there is to know about Toad – and I never will. Just remember, if there’s something you want to do in Oracle, there’s probably a way to achieve it in your favorite IDE! Don’t be afraid to ask for help. That’s what we’re here for.





Twitter
RSS
GooglePlus
Facebook
Aug 30, 2011 @ 20:41:25
exists ( select ‘x’ …
What is that? Why not NULL? Why ‘x’? Weird.
Aug 31, 2011 @ 09:11:36
‘x’ is just a placeholder. We could have selected ‘oraclenerd_is_annoying’ with the same effect.
The subquery WHERE clause is doing most of the work here. If the table_name match happens from the first query, then it will return a row. The row present means include this row in the resulset. If we had said NOT EXISTS we could return tables not having a CLOB column.
The developer tells me that EXISTS can be faster than doing a ‘where x in (subquery)’ — which I have seen stated many times but have never researched or verified.
Aug 31, 2011 @ 12:02:10
I know how EXISTS works silly.
Just wondering why ‘x’ and not, say, NULL. I’ve seen it before…always wondered.
Aug 31, 2011 @ 13:18:53
Sorry dude. I’m guessing the developer did it for readability? Or just personal programming style?
Aug 31, 2011 @ 13:28:44
Programming style…most likely. Just wonder if they know they could use NULL as well. Yes, it annoys me.
Aug 31, 2011 @ 13:46:35
Well you’re in luck. In Toad you can change the SQL if you don’t like it – at least where the filters are involved.