SQL 在oracle中搜索列名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20709944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 00:33:35 来源:igfitidea点击:
search for column names in oracle
提问by msjsam
Because there are many tables with many columns, I need a query to search for column names in a specific table.
因为有很多表有很多列,所以我需要一个查询来搜索特定表中的列名。
example:
例子:
select column_name from table where column_name like '%ID%'
回答by Konstantin
For Oracle
甲骨文
select COLUMN_NAME from ALL_TAB_COLUMNS
where TABLE_NAME='mytable' and COLUMN_NAME like '%ID%';
回答by Rahul Tripathi
Try this:
尝试这个:
SELECT * FROM ALL_TAB_COLUMNS
WHERE COLUMN_NAME LIKE '%ID%'
AND owner = 'database_name' AND table_name = 'MY_TABLE';
回答by Craig
Assuming you are on an Oracle database, try this:
假设您使用的是 Oracle 数据库,请尝试以下操作:
select column_name
from user_tab_columns
where table_name = 'MY_TABLE' and column_name like '%ID%';
If the table is in a different schema, you can use:
如果表在不同的架构中,您可以使用:
select column_name
from all_tab_columns
where owner = 'TABLE_OWNER' and table_name = 'MY_TABLE' and column_name like '%ID%';