Practice: Create shell scripts for tablespace in oracle, oracleshell

Source: Internet
Author: User

Practice: Create shell scripts for tablespace in oracle, oracleshell

#! /Bin/bash # ocpyang@126.com # create tablespaceif [$ #-ne 2]; then echo "Usage: $0 TABLESPACE_NAME TABLESPACE_SIZE" exit 1fi # configure oracle env: about oracle envs, username and passwordORACLE_HOME =/u01/app/oracle/product/11.2.0/db_1ORACLE_SID = orclora_data =/u01/app/oracle/product/11.2.0/db_1/dbs/ora_user = "sys" ora_pass = "password" tablespace_name = $ (echo $1 | tr '[a-z] ''[A-Z]') tablespace_size = $2 outfil Etmp01 =/tmp/createtpstmp01.txt # specify the output file location outfiletmp03 =/tmp/queues # specify the output file location outfiletmp02 =/tmp/createtpstmp02.txt # specify the output file location # check oracle instance is down or up sqlplus-S "$ {ora_user}/$ {ora_pass} as sysdba" <! 01>/dev/null # disable the execution result echo of sqlplus; set feedback off; set termout off; set pagesize 0; set verify off; set echo off; spool $ {outfiletmp01} select sysdate from dual; spool offexit ;! 01ins_jug = 'grep-I "ORA-01034:" ${outfiletmp01 }>$ {outfiletmp02} 'if [-s $ {outfiletmp02}]; thenecho-e "\ e [1; 31 m ************************************** * ************************** \ e [0 m "echo-e" \ e [1; 31 m !!!!, Oracle IS down! \ E [0 m "echo-e" \ e [1; 31 m ************************************** * ************************** \ e [0 m "rm-rf ${outfiletmp01} rm-rf $ {outfiletmp02} exit 1fi # sqlplus-S "$ {ora_user}/$ {ora_pass} as sysdba" <! 01>/dev/null # disable the execution result echo of sqlplus; set feedback off; set termout off; set pagesize 0; set verify off; set echo off; spool $ outfiletmp03select tablespace_name from dba_tablespaces where tablespace_name = '$ {tablespace_name}'; spool offexit ;! 01tps_jug = 'grep-I $ {tablespace_name }$ {outfiletmp03} 'if ["$ {tps_jug}" = "$ {tablespace_name}"]; then echo-e "\ e [1; 32 m The tablespace $ {tablespace_name} exits! \ E [0 m "rm-rf $ {outfiletmp03} exit 1 elsewind_var =$ (sqlplus-s" {ora_user}/$ {ora_pass} as sysdba "<EOF create tablespace $ {tablespace_name} datafile '$ {ora_data}/$ {tablespace_name }. dbf 'size $ tablespace_sizeextent management localuniform size 128 ksegment space management auto; EXIT; EOF) echo-e "\ e [1; 32 m $ {wind_var} \ e [0 m "# Direct display returns resultsrm-rf $ {outfiletmp03} exit 1fi



How to Create a tablespace in oracle

Create a new Command Window, enter the Command at the prompt, and press enter to execute it.
Create tablespace dbspace datafile 'd: \ oracle \ product \ 10.2.0 \ oradata \ orcl \ dbspace. dbf' size 400 M autoextend on next 10 m maxsize unlimited; -- create a tablespace
Drop tablespace dbspace including contents and datafiles; -- delete a TABLESPACE

Where
1) DATAFILE: path for storing tablespace data files
2) SIZE: initially set to 200 M
3) UNIFORM: the size of the specified area is 128 k. If not specified, the default area size is 64 k.
4) The space name histdb is not required to be the same as the data file name histdb. dbf.
5) autoextend on/OFF indicates that automatic table space expansion is started/stopped.
6) alter database datafile 'd: \ oracle \ product \ 10.2.0 \ oradata \ orcl \ histdb. dbf' resize 500 m; // manually modify the data file size

Use the following command to create a user for a tablespace and set the user's default tablespace to the created tablespace.
Create user test1 identified by test1 default tablespace dbspace;
Alter database default tablespace dbspace;
Create user test identified by test;
Select username, default_tablespace defspace from dba_users where username = 'test ';

Linux + oracle database + shell scripts have been learned. What will happen in the future?

If you just want to learn, I believe there is nothing to show off, because linux + oracle + shell, basically I will. We recommend that you be proficient in one or two products. I believe this will allow you to develop your business in the future.

Linux + oralce is a lot of operating systems and databases used by many large enterprises. you are proficient in these two fields, and you have no problem with the monthly salary. GG or MM

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.