I'm new to Oracle and database administration in general.
As context, I want to create a Java class that will give me the information I would get using DESC SOME_TABLE.
I cannot find any specific way to do that in Java, however I found that ALL_TAB_COLUMNS could give me similar info. I tried it in SQL Developer to see how different the output was. It turns out the results are a lot more different that I was expecting.
I was hoping someone could walk me through how to interpret the following:
desc SOME_TABLE;
select
COLUMN_NAME
, DATA_TYPE
, DATA_LENGTH
, NULLABLE
from ALL_TAB_COLUMNS
where TABLE_NAME='SOME_TABLE'
order by column_id;
Gives the output:
Name Null Type
--------------- ------- ----------------------
UIDPK NUMBER(20)
NAME VARCHAR2(255)
2 rows selected
COLUMN_NAME DATA_TYPE DATA_LENGTH NULLABLE
--------------- -------------- -------------- --------
UIDPK NUMBER 22 N
UIDPK NUMBER 22 N
UIDPK NUMBER 22 Y
NAME VARCHAR2 255 N
NAME VARCHAR2 255 Y
NAME VARCHAR2 255 N
6 rows selected
Why is each column repeated 3 times? Why is the datatype and length different on UIDPK and why is NULLABLE not the same?

OWNER = 'FOOBAR'in your query to all_tab_columns (or use user_tab_columns). You can also include theOWNERcolumn in your select list to verify this. – a_horse_with_no_name Jul 20 '12 at 22:44