Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I need to query the database to get the column names, not to be confused with data in the table. For example, if I have a table named EVENT_LOG that contains eventID, eventType, eventDesc, and eventTime, then I would want to retrieve those field names from the query and nothing else.

I found how to do this in:

But I need to know: how can this be done in Oracle?

2 Answers

0 votes
by (40.7k points)

You can try querying the USER_TAB_COLUMNS table for table column metadata.

Query:

SELECT table_name, column_name, data_type, data_length

FROM USER_TAB_COLUMNS

WHERE table_name = 'MYTABLE'

0 votes
by (1.9k points)

Let us show all column names to return or display each as is in Oracle. Query= SELECT column_name FROM ALL_TAB_COLUMNS WHERE table_name = 'TABLE_NAME' Here, ALL_TAB_COLUMNS gives information about columns of tables, views and clusters accessible by the user. TABLE_NAME is a table created by the user.

Related questions

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...