On always learning new things....



After using Oracle for quite a while I'm pretty confident that some bits of it i pretty much know inside out and there is nothing more i can really learn. Today i was reminded of the fact that however well you think you know something there is always more to know....

And embarrassingly this was something about the tnsnames.ora file and connectivity - one of the first things you learn (and one that you are constantly working with).

So here is what i learnt at school today dad..... (and i'd be interested if i just missed class the day they mentioned this - am i the only one to not realise this was possible....?)

I'll keep it short as it is pretty basic

A standard tnsnames entry looks something like this

RICH =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = server)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = RICH)
    )
  )


Something we'll all be familiar with.

you then just connect using sqlplus user/pass@RICH - no surprises there.

but.......

did you know you could do this?

RICH,SOME_OTHER_NAME =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = server)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = RICH)
    )
  )


i.e. add a second alias (separated by a comma) - now both of these aliases work fine and connect to the same database

so sqlplus user/pass@RICH connects to the same place as user/rich@SOME_OTHER_NAME

I guess normally you;d never have repeat entries in the file anyway, but occasionally i have seen it done - this means you only have to store the config once - useful eh?

Well anyway i learnt something today, maybe you will too (or then again maybe you won't...) :-)

Comments