oracle 我可以选择除特定列之外的所有列吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16232617/
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-19 01:37:24  来源:igfitidea点击:

Can i select all columns except a specific column?

sqloracle

提问by Moudiz

test_table:

测试表

id   f_name     l_name  age  
--  --------- --------   ------ 

I am new to oracle, but if I want to select all the columns I should use

我是 oracle 的新手,但如果我想选择我应该使用的所有列

select * from test_table

however if I want to select all the columns except age I should write

但是,如果我想选择除年龄之外的所有列,我应该写

select id, f_name, l_name from test_table

Is there a way I can select all the columns but disgarding a column or two?

有没有办法可以选择所有列但忽略一两列?

Because in my work busninse there alot of columns and sometimes I don't need to select them all.

因为在我的工作中,有很多列,有时我不需要全部选择它们。

回答by John Woo

You can't.

你不能。

The only thing that comes into my mind is to create a VIEWfor your SELECTstatement.

我唯一想到的是VIEW为您的SELECT陈述创建一个。

CREATE VIEW employeeList
AS
SELECT id, f_name, l_name -- <<== select only the column you want to project
FROM  test_table;

once your VIEWis created, you can now use *against the view,

一旦你VIEW创建,你现在可以使用*了这个视图,

SELECT * FROM employeeList

回答by Hanky Panky

It's not possible. Either you can SELECT *or you can define which columns you want to select. There is no such SELECT clause in oracle that allows you to return all columns except some automatically. Reference

这是不可能的。您可以SELECT *也可以定义要选择的列。oracle 中没有这样的 SELECT 子句允许您自动返回除某些列之外的所有列。参考