SQL 从 Oracle 表中选择所有列和常量值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8146384/
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
Selecting all columns and constant value from Oracle table
提问by CooperMAN
How can I select all columns and add a column with a constant value in Oracle?
如何在 Oracle 中选择所有列并添加具有常量值的列?
With MS SQL Server, I can use:
使用 MS SQL Server,我可以使用:
Select *,5 From TableA;
I will get this:
我会得到这个:
column1 column2 5 xx xx 5 xx xx 5
回答by Jeremy Thompson
See this tutorial: Select constant as a Column
请参阅本教程:选择常量作为列
Select *,5 as "ConstColumn" From TableA;
回答by adatapost
Try,
尝试,
Select TableA.*, 5 as "ColumnAlias" From TableA
回答by JoeF
For a string I was able to do this with 11g:
对于一个字符串,我可以用 11g 做到这一点:
SELECT A1.*, 'ActionType' as "OptionType"
FROM TableA A1;
回答by Manasse
I don't think this is really possible, because the * character is not a replacing content. I get back this error: ORA-00923
我不认为这真的可能,因为 * 字符不是替换内容。我得到这个错误:ORA-00923