Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a blank/empty column with SELECT query in oracle?

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:

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.

like image 470
user3878988 Avatar asked Aug 02 '16 20:08

user3878988


People also ask

How do I make an empty column in SQL?

In this article, we will look into how you can set the column value to Null in SQL. update students set Gender = NULL where Gender='F'; SELECT * FROM students ; Output: Column value can also be set to NULL without specifying the 'where' condition.


2 Answers

I think you should use 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.

like image 97
ScaisEdge Avatar answered Oct 05 '22 17:10

ScaisEdge


In DB2, using single quotes instead of your double quotes will work. So that could translate the same in Oracle..

SELECT CustomerName AS Customer, '' AS Contact  FROM Customers; 
like image 22
Son Ha Avatar answered Oct 05 '22 18:10

Son Ha