Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Difference between DESC & user_tab_columns
"Ed Prochak" <ed.prochak_at_magicinterface.com> a écrit dans le message de
news:0jFfd.202$Qy.188_at_fe39.usenetserver.com...
> Praveen wrote:
>
> >
> > ------------------------------------------------------------------------
> >
> > Subject:
> > Difference between DESC & user_tab_columns
> > From:
> > Praveen <nospam_at_nospam.com>
> > Date:
> > Fri, 22 Oct 2004 12:46:40 -0700
> >
> >
> > Hi..All,
> >
> > When I do a DESC on a table , one of the columns shows the
> > datatype(lenght) as Number(38). But when I look at the details of the
> > column it shows something else. How does it come up with a different
> > lenght Or where does desc pick it from when you do a DESC? Is there any
> > other logic involved?
> >
> > Column Details :
> >
> >
> > TABLE_NAME COLUMN_NAME
> > ------------------------------ ------------------------------
> > DATA_TYPE DAT
>
> --------------------------------------------------------------------------------------------------
For NUMBER you have to check data_precision column and not data_length. Here's a script equivalent to desc (with extra comments) but only for standard datatypes (parameter 1 is owner, 2 is table_name):
Set echo OFF
Set feedback OFF
Set heading OFF
Set linesize 2000
Set long 32760
Set longchunksize 120
Set newpage 0
Set pagesize 0
Set recsep OFF
Set space 0
Set trimout ON
Set trimspool ON
BTitle OFF
TTitle OFF
Prompt
Select decode(col.column_id, 1, col.table_name||decode(com.comments, NULL, '','
-- '||com.comments)||'
', '')||col.column_name||' '||col.data_type||
decode(col.data_type,
'NUMBER', decode(col.data_precision, NULL, decode(col.data_scale, NULL, '', '(38)'), '('||col.data_precision|| decode(col.data_scale, NULL, ')', ','||col.data_scale||')')), 'CHAR', '('||col.data_length||')', 'VARCHAR2', '('||col.data_length||')', 'NCHAR', '('||col.data_length||')', 'NVARCHAR2', '('||col.data_length||')', 'RAW', '('||col.data_length||')' )||
where ccom.owner = upper('&1') and ccom.table_name = upper('&2') and ccom.column_name = col.column_name and com.owner = upper('&1') and com.table_name = upper('&2')
-- Regards Michel CadotReceived on Wed Oct 27 2004 - 12:21:02 CDT
![]() |
![]() |