Selecting all columns and constant value from Oracle table

39,879

Solution 1

See this tutorial: Select constant as a Column

Select *,5 as "ConstColumn" From TableA;

Solution 2

Try,

Select TableA.*, 5 as "ColumnAlias" From TableA

Solution 3

I don't think this is really possible, because the * character is not a replacing content. I get back this error: ORA-00923

Share:
39,879
Admin
Author by

Admin

Updated on November 21, 2020

Comments

  • Admin
    Admin over 3 years

    How can I select all columns and add a column with a constant value in Oracle?

    With MS SQL Server, I can use:

    Select *,5 From TableA;
    

    I will get this:

    column1      column2    5
    xx           xx         5
    xx           xx         5
  • Jeremy Thompson
    Jeremy Thompson over 12 years
    @CooperMAN - looks like your new here to SO, if you mark the answer you'll get a couple of points and soon will earn the privilege to be able to upvote and downvote HTH