CooperMAN
CooperMAN

Reputation: 121

Selecting all columns and constant value from Oracle table

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

Upvotes: 12

Views: 45956

Answers (3)

Manasse
Manasse

Reputation: 160

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

Upvotes: 2

KV Prajapati
KV Prajapati

Reputation: 94645

Try,

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

Upvotes: 11

Jeremy Thompson
Jeremy Thompson

Reputation: 65624

See this tutorial: Select constant as a Column

Select *,5 as "ConstColumn" From TableA;

Upvotes: 14

Related Questions