How can I get column names from a table in Oracle

Blog-36.jpg

In this blog, we will learn how to get column names from a table in Oracle. Oracle is a database software that uses the Relational database management concept, which means we can store the data in the form of tables.

Table of Contents:

How can I get column names from a table in Oracle?

In Oracle, you can get column names from the table with the following syntax:

Syntax

SELECT column_name 
FROM user_tab_columns 
WHERE table_name = 'YOUR_TABLE_NAME';

Explanation:

  • user_tab_clumns: it is a dictionary view in Oracle, that provides the information about the columns present in a table.
  • table_name = ‘YOUR_TABLE_NAME’: this filters the row where the table name is equal to “YOUR_TABLE_NAME”.

Example to get column names from a table in Oracle

Suppose we have a table Employee that has some data in it.

Table: Employee

ID Name Dept
1ClarkSales
2JohnHR
3PiyushOps
4OliveIT

Now, If you want to print all the columns from the table, let’s run the following Query:

Query:

SELECT column_name 
FROM all_tab_columns 
WHERE table_name = 'Employee' order by column_name;

Output:

COLUMN_NAME
--------------------------------------------------------------------------------
DEPT
EMPID
NAME

Conclusion

So far in this article, we have learned how we can get column names from a table in Oracle with an example. If you want to excel in your career in SQL, you should visit our SQL course.

About the Author

Technical Writer | Business Analyst

Yash Vardhan Gupta is an expert in data and business analysis, skilled at turning complex data into clear and actionable insights. He works with tools like Power BI, Tableau, SQL, and Markdown to develop effective documentation, including SRS and BRD. He helps teams interpret data, make informed decisions, and drive better business outcomes. He is also passionate about sharing his expertise in a simple and understandable way to help others learn and apply it effectively.

Intellipaat