Prepare for your Next Interview
This is a discussion on Query to get table structure within the DB2 forums, part of the Databases category; 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 describe table table_name i ...
|
|||
|
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 describe table table_name 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.
|
| Sponsored Links |
|
|||
|
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 |
|
|||
|
Quote:
Thanks Beena. Is there any query describing the primary keys of the table?? |
|
|||
|
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 dbashubhrojyoti@gmail.com Last edited by dbadb2udb : 05-26-2008 at 04:02 PM. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Query to find structure of a table | Geek_Guest | SQL | 12 | 09-01-2008 10:12 PM |
| Table structure copying | krishnaindia2007 | Oracle | 1 | 11-28-2007 02:13 AM |
| How to view the structure of the table | Subashini.Ramasamy | SQL Server | 14 | 11-26-2007 06:58 AM |
| copy the Table Structure | vcyogi | SQL Server | 3 | 08-04-2007 01:43 AM |
| Creating a table by copying another table's structure | Allan Paul | Oracle | 12 | 07-12-2007 06:53 AM |