Hello,I need some info, that is it possible to find or make query ,that if we know the data stored in a table but don't know the field name in which the required data is stored.ExampleTable having fields like columnA, columnB, columnC, columnD,..........columnN and all have the same dataType. and you dont know in which field your data exists.suppose some data like e.g. "BackMan" exists in any Field of the table but we don't know in which Field this information is store.Is it possible that we can make a query to search the dataUmair Tariq

Showing Answers 1 - 2 of 2 Answers

Culver_lake

  • Mar 21st, 2006
 

Every Relational Database Management System has a relational catalog, (also called the data dictionary or the systme tables). It contains meta data, that's data about data. The catalog is a relational database so you use SQL to retrieve the information just like you would do with any other table.

One of the catalog tables has a row for every column in the system and a foreign key that relates each column back to the single table that contains it. In DB2 the table is named SYSIBM.SYSCOLUMNS.  Knowing the table name the Query in DB2 would be:

Select    *

FROM     SYSIBM.SYSCOLUMNS

WHERE   TBNAME = 'table name'

    AND   TBCREATOR = 'schema name'

ORDER BY COLNO

  Was this answer useful?  Yes

Culver_lake

  • Mar 21st, 2006
 

By the way, they're called columns not fields and there's no reason to expect or even thing that they will be of the same datatype. Unless it's a very special type of table it's almost guaranteed that they will be of different datatypes. Lots of Character data in business programming, lots of numbers in scientific programming.

Remember rows, columns and tables, are relational database terms  records, fields, and files are file-handling terms.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions