views:

62

answers:

5

How to find what are all tables has binary data and display the table name ?

+1  A: 

That depends a lot on what database you are using. Many databases (at least MySQL and PostgreSQL, maybe all) has a database called information_schema (or something similar). This is a database describing the structure of your databases along with all tables, their fields and what types of data the fields hold. So this would be a good starting point.

Mikael Auno
+1  A: 

Can you ask the DBA or the DB-developper?

if no, what DB (Oracle, MySql, Microsoft, other?) are you using ..

EDITED for MySQL DB

Use

select table_schema
     , table_name
     , column_name
     , data_type 
from information_schema 
where data_type like '%blob%' 
   or data_type in ('binary','varbinary')
lexu
mysql version 4.0
joe
+1  A: 

I'd need to know which database, but this (or something very similar) should work on Oracle:

select *
  from all_tab_columns
 where data_type in ('BLOB', 'RAW')
;
l0b0
its hows the all_tab_columns is not available
joe
+1  A: 

you need to select the system tables (in msssql 2000 - syscolumns) or system management views (in mssql 2005 or 2008 - sys.columns) to find the columns with system_type_id you need to find, and then find the corresponding table joining sys.columns and sys.objects by object_id field.

Alex_L
+1  A: 

For MySql you want the INFORMATION_SCHEMA COLUMNS table:

http://dev.mysql.com/doc/refman/5.1/en/columns-table.html

If you need to find all of the tables which have binary columns, then you can create a query joining with the INFORMATION_SCHEMA TABLES table:

http://dev.mysql.com/doc/refman/5.1/en/tables-table.html

casperOne
need to find all tables
joe
INFORMATION_SCHEMA COLUMNS does contain all tables ..
lexu