0

I am trying to do something like this:

SELECT 'John Doe' example_name;

Result:

example_name
John Doe

I can do this in PostgreSQL and SQL Server, but this does not work in Oracle.

Any suggestions?

  • 3
    Hint: `FROM DUAL` – Dai May 05 '23 at 01:01
  • 1
    Yes, DUAL is typically what we use. However, it can actually be *any* table if you add ROWNUM = 1. The point is to generate a single row and supply the only column as a literal. DUAL is a table with one row. But we could all do the same things if it didn't exist. – Paul W May 05 '23 at 02:09

1 Answers1

2

Prior to version 23c, Oracle requires you to use the DUAL table when synthesising table data from values:

This works for me in Oracle 11g R2 on SQLFiddle.com:

SELECT
    'John Doe' AS example_name
FROM
    dual;

Screenshot proof:

enter image description here

Dai
  • 141,631
  • 28
  • 261
  • 374