SqlPlus remote connection database

There are two machines A and B, B has a database installed, and now I want to use sqlplus to link it directly on A

 

1: Put the oralce client in the attachment on the A machine, unzip it, assign 777 permissions, and configure the environment variables

2: Create a shell like the following:

 

DB_USER="username"
DB_PASSWD=aaaaaaaa
DB_SERVER=1.2.3.4:1521
DB_SID=pst4
select_sql="Select * from Databaseversion"
sqlplus ${DB_USER}/${DB_PASSWD}@\"//${DB_SERVER}/${DB_SID}\" <<EOF
`echo "${select_sql};"`
exit
EOF

 3 : Execute the shell directly

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326687341&siteId=291194637