Hi,
i am begginer in db2 and i have limited access to database, only querys. I need to get the table structure through query, the names and types of the fields for a specific table.
Thanks in advance.
Hi, query for table structure?
Moderators: Kalicharan, Moderator Group
Hi Chechir,
Give this query a try.
Be sure to only use NAME or TBNAME, not both. You can probably remove TBCREATOR, but if you do you might want to ORDER by it also
Give this query a try.
Code: Select all
SELECT NAME
,COLNO
,COLTYPE || '('
|| CAST(LENGTH AS CHAR(5)) || ','
|| CAST(SCALE AS CHAR(5)) || ')'
,CASE WHEN NULLS = 'N'
THEN 'NOT NULL' ELSE ' ' END
,TBNAME
FROM SYSIBM.SYSCOLUMNS
WHERE TBCREATOR = 'TEST' -- < OR 'TEST'
-- AND (NAME = 'YOUR_COL_NAME' -- < COLUMN NAME \ ONLY USE ONE
AND (TBNAME = YOUR_TBL_NAME' -- < TABLE NAME /
)
ORDER BY TBNAME, COLNO
;
HI Again,
Here's a query for the indexes on the table
Here's a query for the indexes on the table
Code: Select all
SELECT KEYS.IXNAME
,IX.UNIQUERULE
,KEYS.COLNAME
,KEYS.COLNO
,KEYS.COLSEQ
,IX.TBNAME
FROM SYSIBM.SYSINDEXES IX,
SYSIBM.SYSKEYS KEYS
WHERE IX.TBNAME = 'YOUR_TBL_NAME'
AND KEYS.IXNAME = IX.NAME
ORDER BY IX.TBNAME,
KEYS.IXNAME,
KEYS.COLSEQ
Thanks a lot!!!
This is very useful for me, and i am seeing other tables like SYSIBM.SYSTABLES.
But i dont understand why the tables appear with a diferent name in the SQL and the aplication that i use for download the data (cwbtf.exe). For example the table BIBLIO.CLIENTES_DIRECCION in SYSIBM.SYSTABLES is "BIBLIO.DIRCLI" in cwbtf.exe.
Cheers!
This is very useful for me, and i am seeing other tables like SYSIBM.SYSTABLES.
But i dont understand why the tables appear with a diferent name in the SQL and the aplication that i use for download the data (cwbtf.exe). For example the table BIBLIO.CLIENTES_DIRECCION in SYSIBM.SYSTABLES is "BIBLIO.DIRCLI" in cwbtf.exe.
Cheers!
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page