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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get table names, then column names

Status
Not open for further replies.

mcambray

Programmer
Dec 21, 2006
4
US
Brand new to Oracle9, need to know equivalent of Informix queries "info columns for tablename;" and "select tabname from systables;" Any help is appreciated.

 
Hi, mcambray

You can get both from:

SELECT table_name, column_name
FROM dba_tab_columns

Regards,



William Chadbourne
Oracle DBA
 
If you query the DBA_TAB_COLUMNS, I suggest a couple of slight adjustments to the query:
Code:
col owner format a30
col table_name format a30
break on owner on table_name
set linesize 200
SELECT owner, table_name, column_name
  FROM dba_tab_columns
 ORDER BY owner,table_name, column_id;
The adjustments:

1) Accommodate multiple Oracle users owning tables with the same name
2) Ensure that the columns appear in "natural" (physical) order
3) Ensure that everything appears by owner, by table, by column order.



[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Thanks for help, but I get "table or view does not exist"
message.
 
Hi, mcambray

This is probably because you don't have DBA privileges. Try this instead:

SELECT table_name, column_name
FROM user_tab_columns

Regards,


William Chadbourne
Oracle DBA
 
Again thanks, no error this time, but also no results.
 
McAmbray,

Change the reference, "user_tab_columns", to "all_tab_columns"...Then you will see results. (The reason that you saw no results with "user_tab_columns" is because the Oracle user with which you connected to the database owns now tables/views itself.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Super! Thanks again. So I got a listing with 1 line containing the table name and column name for each column.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top