11

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
CooperMAN
  • 111
  • 1
  • 1
  • 3

3 Answers3

14

See this tutorial: Select constant as a Column

Select *,5 as "ConstColumn" From TableA;
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
10

Try,

Select TableA.*, 5 as "ColumnAlias" From TableA
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
  • @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 – Jeremy Thompson Nov 16 '11 at 03:59
1

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

Manasse
  • 150
  • 1
  • 10