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?
kevin1478Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
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

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.