From: Rich on

I am using 10g.

I want to do a select statement that will give me the name of the
fields in a table. And I also want to know the field type and field
size.

Can this be done?

Regards
From: Maxim Demenko on
On 05.05.2010 20:05, Rich wrote:
>
> I am using 10g.
>
> I want to do a select statement that will give me the name of the
> fields in a table. And I also want to know the field type and field
> size.
>
> Can this be done?
>
> Regards

Look up in the docs dba/all/user_tab_columns data dictionary view

Best regards

Maxim
From: Mark D Powell on
On May 5, 2:08 pm, Maxim Demenko <mdeme...(a)gmail.com> wrote:
> On 05.05.2010 20:05, Rich wrote:
>
>
>
> > I am using 10g.
>
> > I want to do a select statement that will give me the name of the
> > fields in a table. And I also want to know the field type and field
> > size.
>
> > Can this be done?
>
> > Regards
>
> Look up in the docs dba/all/user_tab_columns data dictionary view
>
> Best regards
>
> Maxim

Besides the dba_tab_columns view that Maxim pointed out there are
other language specific features available such as the OCI interface
call OCIDescribeAny and the dbms_describe package. Depending on your
front-end tool set a direct query may or may not be the method you
want to use.

HTH -- Mark D Powell --
From: sandeep pande on
On May 5, 11:05 pm, Rich <richma...(a)earthlink.net> wrote:
> I am using 10g.
>
> I want to do a select statement that will give me the name of the
> fields in a table. And I also want to know the field type and field
> size.
>
> Can this be done?
>
> Regards

Hi,

Yes u can do this using

SQL> desc dba_tab_columns
Name Null? Type
----------------------------------------------------- --------
------------------------------------
OWNER NOT NULL
VARCHAR2(30)
TABLE_NAME NOT NULL
VARCHAR2(30)
COLUMN_NAME NOT NULL
VARCHAR2(30)
DATA_TYPE
VARCHAR2(106)
DATA_TYPE_MOD
VARCHAR2(3)
DATA_TYPE_OWNER
VARCHAR2(30)
DATA_LENGTH NOT NULL NUMBER
DATA_PRECISION NUMBER
DATA_SCALE NUMBER
NULLABLE
VARCHAR2(1)
COLUMN_ID NUMBER
DEFAULT_LENGTH NUMBER
DATA_DEFAULT LONG
NUM_DISTINCT NUMBER
LOW_VALUE
RAW(32)
HIGH_VALUE
RAW(32)
DENSITY NUMBER
NUM_NULLS NUMBER
NUM_BUCKETS NUMBER
LAST_ANALYZED DATE
SAMPLE_SIZE NUMBER
CHARACTER_SET_NAME
VARCHAR2(44)
CHAR_COL_DECL_LENGTH NUMBER
GLOBAL_STATS
VARCHAR2(3)
USER_STATS
VARCHAR2(3)
AVG_COL_LEN NUMBER
CHAR_LENGTH NUMBER
CHAR_USED
VARCHAR2(1)
V80_FMT_IMAGE
VARCHAR2(3)
DATA_UPGRADED
VARCHAR2(3)
HISTOGRAM
VARCHAR2(15)

select table_name,column_name,data_type,DATA_LENGTH from
dba_tab_columns where table_ name='<table_name>' and owner='<username>'