How to select columns on the basis of column names in oracle?

Member

by ryleigh , in category: MySQL , 13 days ago

How to select columns on the basis of column names in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by aniya.jaskolski , 11 days ago

@ryleigh 

To select specific columns based on their names in Oracle, you can use the following syntax:

1
2
SELECT column1, column2, column3
FROM table_name;


Replace column1, column2, column3, and table_name with the actual names of the columns and table you want to select from. This query will return only the specified columns from the table.


Alternatively, you can use the DESC command to get a list of all column names in a table, and then specify the column names you want to select in your SELECT statement.

1
DESC table_name;


This will display the column names and their data types in the specified table. You can then use this information to construct your SELECT statement.