# Databases > SQL Query to find structure of a table

## Geek_Guest

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

*Question asked by visitor Mahesh.Mk*

----------


## yuvarajan2000

desc tablename

----------


## prabhukalai

DESC TABLE_NAME;

eg:

DESC EMP;

EMP is name of table.

----------


## jainbrijesh

yes Desc Table_name is the query.

Desc stands for describe.

----------


## sutnarcha

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

DESC /tablename/

is not a query. :EEK!:   It is an SQL-Plus command. :Confused:  

Because only SELECT statements can be called as a query. :Big Grin:

----------


## varmakub

Good one from sutnarcha !!!
Yes !!! its not a query - Which retrieves some data from the databse :-)

----------


## Cguna

> Please give me the query.. How to findout the structure of a table?
> 
> *Question asked by visitor Mahesh.Mk*


desc Table Name;

----------


## kaarthi_bala

SQL> desc table_name
eg
SQL> desc emp

or
SQL> describe table_name

----------


## yagnam ramesh babu

desc

----------


## arunendra kumar

desc object_name.

----------


## raj1402

Desc tablename i think its also a query anything getting information is query i quess!!!

----------


## tarikuzzaman

select COLUMN_NAME, DATA_TYPE
from USER_TAB_COLUMNS
where TABLE _NAME = 'your table name';  .....(Like 'emp')

----------


## Sushma Mosali

hi,

agree with  sutnarcha

Thanks
Sushma

----------


## pankajdhal

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'name of the table';

----------


## amitpatel66

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

----------


## nwinkumar

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 !! :Smile:

----------


## davindersingh29

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

describe output select * from table_name

----------


## anis motha

sp_help  table_name

----------


## nehrumosuru

DESC 

EX : DESC  EMPDETAILS






  Reply With Quote













04-10-2012


#20






anis motha



				View Profile
			



				View Forum Posts
			



				Private Message
			






				Junior Member
			





Join Date Mar 2012
Answers 2







					Re: Query to find structure of a table
				



							Desc command not working in sql 2008..












  Reply With Quote


















Page 1 of 2
12

Last

Jump to page:  






«
Previous Thread
			|
			Next Thread
»







				Posting Permissions
			



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
[VIDEO] code is On
HTML code is On


Forum Rules












About us
		Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
				

GeekInterview

GeekInterview
Learning Center
Online Quiz
Interview Questions
Interview Coaching
Interview eBook





Interact














Contact Us  |  
Geeks Discussions  |  
Archive  |  
Privacy Statement  |  
Top





All times are GMT -4. The time now is 01:36 PM.


	Powered by vBulletin™






	Search Engine Optimisation provided by 
			DragonByte SEO v2.0.37 (Lite) - 
			vBulletin Mods & Addons Copyright © 2023 DragonByte Technologies Ltd.Copyright © 2014 GeekInterview.com. All Rights Reserved

----------


## anis motha

Desc command not working in sql 2008..

----------


## amycompton

DESC BOOk_NAME;

eg:

DESC BOOK;

BOOK is name of table.

----------


## Ashish1485

Sp_help  is for SQL server
DESC is for ORACLE DB

----------


## ashee1

you can try it by Double click on the data element(data type) of this field and click where
used list icon on the toolbar to find the table which used this data
element. 
I hope it will help you

----------


## rayavarapu

Select column_name, data_type, data_length, data_precision, data_scale from ALL_TAB_COLUMNS
 where table_name = 'EMP';
or 
desc emp;

----------

