Please give me the query.. How to findout the structure of a table?
Question asked by visitor Mahesh.Mk
Please give me the query.. How to findout the structure of a table?
Question asked by visitor Mahesh.Mk
desc tablename
DESC TABLE_NAME;
eg:
DESC EMP;
EMP is name of table.
yes Desc Table_name is the query.
Desc stands for describe.
Regards,
Brijesh Jain
---------------------------------------------------------
Connect with me on Skype: jainbrijesh
Google Plus : jainbrijeshji
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-
hi,
agree with sutnarcha
Thanks
Sushma
Good one from sutnarcha !!!
Yes !!! its not a query - Which retrieves some data from the databse :-)
SQL> desc table_name
eg
SQL> desc emp
or
SQL> describe table_name
desc
desc object_name.
Desc tablename i think its also a query anything getting information is query i quess!!!
select COLUMN_NAME, DATA_TYPE
from USER_TAB_COLUMNS
where TABLE _NAME = 'your table name'; .....(Like 'emp')
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'name of the 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
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 !!
i work on putty and here we use the following for getting the structure of the table
describe output select * from table_name
sp_help table_name
DESC
EX : DESC EMPDETAILS
04-10-2012 #20Junior Member
- Join Date
- Mar 2012
- Answers
- 2
Re: Query to find structure of a table
Desc command not working in sql 2008..