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

2019-01-03 04:05发布

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?

25条回答
Evening l夕情丶
2楼-- · 2019-01-03 04:42
SELECT COLUMN_NAME 'all_columns' 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME='user';
查看更多
神经病院院长
3楼-- · 2019-01-03 04:44

For SQL Server 2008, we can use information_schema.columns for getting column information

SELECT *
FROM   information_schema.columns
WHERE  table_name = 'Table_Name'
ORDER  BY ordinal_position  
查看更多
We Are One
4楼-- · 2019-01-03 04:44
SELECT COLUMN_NAME 
FROM YourDatabase.INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = 'YourTableName'
查看更多
老娘就宠你
5楼-- · 2019-01-03 04:45
describe YOUR_TABLE;

In your case :

describe EVENT_LOG;
查看更多
啃猪蹄的小仙女
6楼-- · 2019-01-03 04:50

You could also try this, but it might be more information than you need:

sp_columns TABLE_NAME
查看更多
Evening l夕情丶
7楼-- · 2019-01-03 04:51

Just select first row from the table , for oracle : select * from <table name> where rownum = 1;

查看更多
登录 后发表回答