-2

In MSSQL I can type into script editor and execute the following:

SELECT 'TEST' AS MyColumn

Which will output a single row containing TEST in a column called MyColumn

enter image description here

What is the equivalent in Oracle?

Comic Coder
  • 519
  • 1
  • 9
  • 32
  • I agree the question is the same as the one linked but if I have no idea about the dual table as a new user to Oracle, Litterally been using it for half a day how would I know that the following question is the same? https://stackoverflow.com/questions/73751/what-is-the-dual-table-in-oracle – Comic Coder Jun 08 '17 at 08:31

3 Answers3

6

it is:

SELECT 'TEST' AS MyColumn FROM dual;

Dual is a table with one column and one record, built into Oracle especially for this purpose:

SELECT * FROM dual;

yields

Dummy
-----
X

If you would construct this table in other databases, queries on dual would also work. (I use this to unit test Oralcle-queries on Sqlite)

realbart
  • 3,497
  • 1
  • 25
  • 37
6

You just need FROM DUAL:

SELECT 'TEST' AS MyColumn
FROM DUAL;

DUAL is a special built-in table that has one row.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
2

add 'from dual' at the end so

select 'Test' AS MyColumn from dual;
dbajtr
  • 2,024
  • 2
  • 14
  • 22