开发者

desc command through code

开发者_StackOverflow社区Can we get the table description through java code that we get by typing desc in Toad?


Use DatabaseMetaData to get the table information.

You can use the getTablexxx() and getColumnxx() methods to get the table information.

Connection conn = DriverManager.getConnection(.....);
DatabaseMetaData dbmd = conn.getMetaData();
dbmd.getxxxx(); 


If you want to just get column names,types, precision etc you can use ResultSetMetaData. Here is an example.

If you want to go beyond this and find out all the constraints, indexes etc defined on the table you can query the corresponding data dictionary views.


select dbms_metadata.get_ddl('TABLE','YOUR_TABLE_NAME') 
from dual;

It will show you column names,types as well as additional components for creating this table,such as TABLESPACE...;


DBMS_METADATA package or

Select * from all_tab_columns where owner=user and table_name='table_name' order by column_id
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜