Please give me the query.. How to findout the structure of a table?
[B]Question asked by visitor Mahesh.Mk[/b]
Printable View
Please give me the query.. How to findout the structure of a table?
[B]Question asked by visitor Mahesh.Mk[/b]
desc tablename
DESC TABLE_NAME;
eg:
DESC EMP;
EMP is name of table.
yes Desc Table_name is the query.
Desc stands for describe.
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.:D
Good one from sutnarcha !!!
Yes !!! its not a query - Which retrieves some data from the databse :-)
[QUOTE=Geek_Guest;10918]Please give me the query.. How to findout the structure of a table?
[B]Question asked by visitor Mahesh.Mk[/b][/QUOTE]
desc Table Name;
SQL> desc table_name
eg
SQL> desc emp
or
SQL> describe table_name
desc <table_name>
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')
hi,
agree with sutnarcha
Thanks
Sushma
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 <TABLE NAME>
EX : DESC EMPDETAILS
Desc command not working in sql 2008..
DESC BOOk_NAME;
eg:
DESC BOOK;
BOOK is name of table.
Sp_help is for SQL server
DESC is for ORACLE DB[TABLE]
[/TABLE]
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
Select column_name, data_type, data_length, data_precision, data_scale from ALL_TAB_COLUMNS
where table_name = 'EMP';
or
desc emp;