Operate databases in Solaris Shell

Source: Internet
Author: User
Tags ftp login

Originally published on Netease blog 20:17:39

Operating the database in Solaris shell is not very complicated. The whole process is the same as writing an FTP login shell.

The following is the shell I wrote after referring to the online materials:

1. Execute SQL commands

#! /Usr/bin/sh

If [$ #! = 2]
Then
Echo "not enough arguments"
Exit 1
Fi
Sqlplus $1/$2 <EOF
Spool off;

@ Test. SQL
Exit
EOF

This shell function is very simple, that is, entering sqlplus, using a user to connect to a database instance, and then executing a test. SQL script. you can also directly write SQL commands in shell scripts, but note the line feed problem.

2. Start the database

#! /Usr/bin/sh

Sqlplus/nolog <EOF

Connect/As sysdba

Startup;

Exit

EOF

3. Stop the database

This script only needs to change startup to shutdown immediate.


This shell is written in here document technology, indicating that the input parameters after shell are between two EOF.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.