Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Query to find structure of a table

This is a discussion on Query to find structure of a table within the SQL forums, part of the Databases category; Please give me the query.. How to findout the structure of a table? Question asked by visitor Mahesh.Mk...

Go Back   Geeks Talk > Databases > SQL
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 04-24-2007
Expert Member
 
Join Date: Feb 2007
Posts: 1,279
Thanks: 0
Thanked 192 Times in 154 Posts
Geek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura about
Query to find structure of a table

Please give me the query.. How to findout the structure of a table?

Question asked by visitor Mahesh.Mk
Reply With Quote
The Following 2 Users Say Thank You to Geek_Guest For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 04-24-2007
Junior Member
 
Join Date: Apr 2007
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
yuvarajan2000 is on a distinguished road
Thumbs up Re: Query to find structure of a table

desc tablename
Reply With Quote
  #3 (permalink)  
Old 04-24-2007
Junior Member
 
Join Date: Apr 2007
Location: India
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
prabhukalai is on a distinguished road
Re: Query to find structure of a table

DESC TABLE_NAME;

eg:

DESC EMP;

EMP is name of table.
Reply With Quote
  #4 (permalink)  
Old 04-24-2007
Moderator
 
Join Date: Sep 2006
Location: Delhi (India)
Posts: 910
Thanks: 12
Thanked 108 Times in 76 Posts
jainbrijesh will become famous soon enoughjainbrijesh will become famous soon enough
Re: Query to find structure of a table

yes Desc Table_name is the query.

Desc stands for describe.
__________________
--
Brijesh Jain
Reply With Quote
  #5 (permalink)  
Old 04-25-2007
Expert Member
 
Join Date: Nov 2006
Location: Hyd-IND
Posts: 528
Thanks: 1
Thanked 63 Times in 50 Posts
sutnarcha is on a distinguished road
Re: Query to find structure of a table

All the answers given above are correct. But, as far as I know,

DESC /tablename/

is not a query. It is an SQL-Plus command.

Because only SELECT statements can be called as a query.
__________________
Lack of WILL POWER has caused more failure than
lack of INTELLIGENCE or ABILITY.

-sutnarcha-
Reply With Quote
  #6 (permalink)  
Old 04-25-2007
Contributing Member
 
Join Date: Mar 2007
Posts: 43
Thanks: 1
Thanked 2 Times in 2 Posts
varmakub is on a distinguished road
Re: Query to find structure of a table

Good one from sutnarcha !!!
Yes !!! its not a query - Which retrieves some data from the databse :-)
Reply With Quote
  #7 (permalink)  
Old 06-01-2007
Junior Member
 
Join Date: Apr 2007
Location: Chennai
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Cguna is on a distinguished road
Re: Query to find structure of a table

Quote:
Originally Posted by Geek_Guest View Post
Please give me the query.. How to findout the structure of a table?

Question asked by visitor Mahesh.Mk
desc Table Name;
Reply With Quote
  #8 (permalink)  
Old 06-05-2007
Junior Member
 
Join Date: Dec 2006
Location: salem
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kaarthi_bala is on a distinguished road
Re: Query to find structure of a table

SQL> desc table_name
eg
SQL> desc emp

or
SQL> describe table_name
Reply With Quote
  #9 (permalink)  
Old 09-04-2007
Junior Member
 
Join Date: Feb 2007
Location: pulivendula,kadapa(district),a.p,india
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
yagnam ramesh babu is on a distinguished road
Thumbs up Re: Query to find structure of a table

desc
Reply With Quote
  #10 (permalink)  
Old 10-23-2007
Junior Member
 
Join Date: Oct 2007
Location: delhi
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
arunendra kumar is on a distinguished road
Re: Query to find structure of a table

desc object_name.
Reply With Quote
  #11 (permalink)  
Old 10-23-2007
Contributing Member
 
Join Date: Aug 2007
Posts: 70
Thanks: 12
Thanked 10 Times in 8 Posts
raj1402 is on a distinguished road
Re: Query to find structure of a table

Desc tablename i think its also a query anything getting information is query i quess!!!
Reply With Quote
  #12 (permalink)  
Old 09-01-2008
Junior Member
 
Join Date: Sep 2008
Location: Bangladesh
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
tarikuzzaman is on a distinguished road
Re: Query to find structure of a table

select COLUMN_NAME, DATA_TYPE
from USER_TAB_COLUMNS
where TABLE _NAME = 'your table name'; .....(Like 'emp')
Reply With Quote
  #13 (permalink)  
Old 09-01-2008
Expert Member
 
Join Date: Jun 2007
Location: Australia
Posts: 260
Thanks: 7
Thanked 15 Times in 15 Posts
Sushma Mosali is on a distinguished road
Re: Query to find structure of a table

hi,

agree with sutnarcha

Thanks
Sushma
Reply With Quote
  #14 (permalink)  
Old 01-17-2009
Junior Member
 
Join Date: Jan 2009
Location: Bhubaneswar,Orissa,India
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
pankajdhal is on a distinguished road
Re: Query to find structure of a table

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'name of the table';
Reply With Quote
  #15 (permalink)  
Old 01-17-2009
Expert Member
 
Join Date: Nov 2008
Location: Chennai
Posts: 303
Thanks: 1
Thanked 37 Times in 32 Posts
amitpatel66 is on a distinguished road
Re: Query to find structure of a table

You can either describe the table using DESC command or you can use data dictionary views "ALL TABLE and ALL TABLE COLUMNS" to look at the list of columns of the table and its structure. If you are using TOAD, then just type the table name in the sql editor of TOAD and click on F4, that will open up a window to show the constraints, table struvture, indexes etc of that particular table
Reply With Quote
  #16 (permalink)  
Old 01-17-2009
Junior Member
 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
nwinkumar is on a distinguished road
Re: Query to find structure of a table

Query 1:

select column_name, data_type, data_length,
2 data_precision, data_scale from ALL_TAB_COLUMNS
3 where table_name = 'EMP';

Query 2:

SQL> set long 100000
SQL> set pages 0
SQL> select dbms_metadata.get_ddl('TABLE','EMP') from dual;

i think this should work out !!!

These queries would answer your query !!
Reply With Quote
  #17 (permalink)  
Old 07-07-2009
Junior Member
 
Join Date: Apr 2009
Location: Mumbai
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
davindersingh29 is on a distinguished road
Re: Query to find structure of a table

i work on putty and here we use the following for getting the structure of the table

describe output select * from table_name
Reply With Quote
Reply

  Geeks Talk > Databases > SQL

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Structure of Salary nehalshah Companies 3 04-27-2009 04:51 PM
Creating a table by copying another table's structure Allan Paul Oracle 19 04-17-2009 06:03 AM
How to find Table Size timmy Oracle 2 09-23-2008 04:52 AM
How a java table be brought to data table? dhandhan QTP 0 04-15-2007 06:14 AM
How to find Defined key fields in a table? sharifhere SQL 2 02-22-2007 01:01 AM


All times are GMT -4. The time now is 05:47 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved