Query to get table structure
Hi friends, i want a query to know the table structure in db2 listing all its columns, primary keys and all. I tried using the query [b]describe table table_name[/b] i get the following o/p --------------------- column type type name schema name length scale nulls ------------------------------ --------- ------------------ -------- ---- 0 record(s) selected. Sql0100w no row was found for fetch, update or delete; or the result of a query is an empty table. Sqlstate=02000 please help me.
Re: Query to get table structure
The following example shows how to describe a SELECT statement:
db2 "describe output select * from staff" SQLDA Information
sqldaid :SQLDA sqldabc:896 sqln:20 sqld:7
Column Information
sqltype sqllen sqlname.data sqlname.length
-------------------- ------ ------------------------------ --------------
500 SMALLINT 2 ID 2
449 VARCHAR 9 NAME 4
501 SMALLINT 2 DEPT 4
453 CHARACTER 5 JOB 3
501 SMALLINT 2 YEARS 5
485 DECIMAL 7,2 SALARY 6
485 DECIMAL 7,2 COMM 4
Re: Query to get table structure
[QUOTE=Beena;28995]The following example shows how to describe a SELECT statement:
db2 "describe output select * from staff" SQLDA Information
sqldaid :SQLDA sqldabc:896 sqln:20 sqld:7
Column Information
sqltype sqllen sqlname.data sqlname.length
-------------------- ------ ------------------------------ --------------
500 SMALLINT 2 ID 2
449 VARCHAR 9 NAME 4
501 SMALLINT 2 DEPT 4
453 CHARACTER 5 JOB 3
501 SMALLINT 2 YEARS 5
485 DECIMAL 7,2 SALARY 6
485 DECIMAL 7,2 COMM 4[/QUOTE]
Thanks Beena. Is there any query describing the primary keys of the table??
Re: Query to get table structure
You can use describe indexes for table <<< table name>>> show detail thank you
Re: Query to get table structure
Hi,
As per my knowledge you have searched for the table which is not available.
If you use the bellow mentioned query then it will definitely work.
$ db2 "describe table schema-name.table-name"
Please check the table is cataloged or not...
Regards,
Shubhrojyoti
[email]dbashubhrojyoti@gmail.com[/email]