connect to DB from sqlplus using script
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: connect to DB from sqlplus using script

  1. #1
    Join Date
    May 2013
    Posts
    2

    connect to DB from sqlplus using script

    Hi DBA's

    i am looking for a script that can be run from sqlplus to connect to multiple databases.
    where the script has service name as variable and can prompt me to enter service name everytime i run the script.
    i have installed oracle client on the windows machine which is using the tnsnames.ora to connect to the DB's which are on linux.

    This task can be achived by typing

    sql> conn system/password@testdb

    but i am looking for something like this
    sql> conn.sql
    Enter DB_NAME : testdb (or whatever the DB i am trying to connect)

    is there a way this can be acheived.

    Thanks

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    Yes, it can be achieved.

    Having said that, would that mean that conn.sql script would have the account and password hardcoded? the same for all databases?
    That's a very, very bad idea.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    May 2013
    Posts
    2
    Thanks for the hint Pablo..

    i got it like this

    conn system/password@&SID

    and it does what i want.

    Thanks much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width