[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1709
  • Last Modified:

Oracle SQL Synonyms

I'm working with SQL in Oracle. I want to write a select query using table and column synonyms. For example, how would I re-write the following select statement:

SELECT Saleno, Item, Amount
FROM Sales;

If the synonyms were:
Saleno =n
Item - i
amount = a
sales = s

Are there any other rules I should know?
0
kevin1478
Asked:
kevin1478
4 Solutions
 
Naveen KumarProduction Manager / Application Support ManagerCommented:

try:

1) SELECT Saleno n, Item i, Amount q
FROM Sales s;

OR

2)
create synonym s for
SELECT Saleno n, Item i, Amount q
FROM Sales;

select * from s;

Thanks
0
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
i have put q as aias for amount column .. that is a typing mistake..just change it to A

Thanks
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
like this, if I understand what you mean:

SELECT s.Saleno n, s.Item i, s.Amount a
FROM Sales s;
0
 
konektorCommented:
select s.n, s.i, s.a
  from (select Saleno as n, Item as i, Amount as a
              from Sales) s

using synonyms is usefull in sql statements where tables are joined ...

select s.Saleno, s.Item, s.Amount
  from Sales s, Items o
 where s.Saleno = i.ItemNo
 
0
 
kevin1478Author Commented:
Thank you for your fast reply.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now