Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

usage of $INDEXCOL

Status
Not open for further replies.

ltoni

Technical User
Aug 9, 2000
7
0
0
IT
I have to grab out of a table the name of the columns.
I found the command $INDEXCOL
but I wasn't able to use it.

Can you help me? [sig][/sig]
 
I am not sure what DB you are using, but Oracle has a table called USER_TAB_COLUMNS that has all of the field names for each table that the user owns:

SQL>desc user_tab_columns
Name Null? Type
------------------------------- -------- ----
TABLE_NAME NOT NULL VARCHAR2(30)
COLUMN_NAME NOT NULL VARCHAR2(30)
DATA_TYPE VARCHAR2(9)
DATA_LENGTH NOT NULL NUMBER
DATA_PRECISION NUMBER
DATA_SCALE NUMBER
NULLABLE VARCHAR2(1)
COLUMN_ID NOT NULL 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

Using this, a simple query can get you all of the columns for a table:

SQL>select column_name from user_tab_columns
where table_name = 'TEST';

Hope this helps... [sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
sorry, I'm using interbase DB
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top