简体   繁体   中英

How to get DB2 Table details using C#

How I can connect and use DB2 in the C# application? How I can get the table names of a DB2 database? How I can see the each column name, its datatype, size, etc of a table using C#?

This assumes you're using DB2 for Linux/Unix/Windows. If you're using another platform, it will likely have a different catalog table.

Once you have connected to the database, you can query the information from the system catalog, specifically SYSCAT.COLUMNS .

For example, if you have a table called SCHEMA.TABLE , you could get the list of all the columns using a query like this:

SELECT *
FROM SYSCAT.COLUMNS
WHERE TABSCHEMA='SCHEMA'
  AND TABNAME  ='TABLE'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM