How to Get DB2 Table Column Names

In DB2 database, you can use the following SQL statement to query the field names of a table:

SELECT COLUMN_NAME
FROM SYSIBM.SQLCOLUMNS
WHERE TABLE_NAME = 'your_table_name' AND TABLE_SCHEMA = 'your_schema_name';
  1. Replace your_table_name with the name of the table you want to query.
  2. Replace your_schema_name with the schema name that the table belongs to. If the table is located in the default schema, you can remove the TABLE_SCHEMA condition.

After executing the SQL statement above, you will receive a list of all field names of the specified table. This can help you understand the table structure and carry out further data operations.

bannerAds