oracle 如何在oracle中使用SELECT查询创建一个空白/空列?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38730089/
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
How to create a blank/empty column with SELECT query in oracle?
提问by user3878988
I want to generate an output with blank/empty column with a "Select" query in oracle. I'm able to achieve this with below sql query:
我想在 oracle 中生成一个带有“选择”查询的空白/空列的输出。我可以使用以下 sql 查询来实现这一点:
SELECT CustomerName AS Customer, "" AS Contact
FROM Customers;
So when I run above sql query it returns a table with two columns "Customer" column with content in it and "Contact" column with no content or blank column. I want to achieve same with oracle query. Any help will be highly appreciated.
因此,当我在 sql 查询上方运行时,它返回一个表,其中包含两列“Customer”列,其中包含内容,“Contact”列没有内容或空白列。我想通过 oracle 查询实现相同的目标。任何帮助将不胜感激。
回答by scaisEdge
I think you should use null
我认为你应该使用 null
SELECT CustomerName AS Customer, null AS Contact
FROM Customers;
And Remember that Oracle
并记住甲骨文
treats a character value with a length of zero as null.
将长度为零的字符值视为空值。
回答by Son Ha
In DB2, using single quotes instead of your double quotes will work. So that could translate the same in Oracle..
在 DB2 中,使用单引号代替双引号是可行的。所以这可以在 Oracle 中翻译相同的内容..
SELECT CustomerName AS Customer, '' AS Contact
FROM Customers;