A little bit of learning shell+sql

Source: Internet
Author: User
Tags sqlplus

Meaningless script, big God do not spray/

[[email protected] desktop]# vim oraclesh.sh #!/bin/bashclear# function Test_parameter1 () {' echo  ' su - oracle -c  ' Sqlplus /nolog ' <<end           conn sys/sys as sysdba             select  '-------show parameter --******* View all initialization parameters of the system ****** '   Sga from dual;        show parameter; exitend "; echo ;echo -e  "\t show parameter  --******* View all initialization parameters of the system ******";} TEST_SGA2 ()   {#1. User SGA Info # ' echo  ' su - oracle -c  ' Sqlplus / as  sysdba ' <<exit ' echo  ' su - oracle -c  ' Sqlplus /nolog ' <<end           conn sys/sys as sysdba             clear screen;        select  '-------Show  parameter sga--View SGA Parameters '  sga from dual;         show parameter sga;        select  '-------Show  parameter sga_max_size--View system SGA Max current maximum '  sga from dual;           show parameter sga_max_size;         select  '-------show sga--View user SGA information '  sga from dual;         show sga;        select  '------- Select sum (current_size)  from v\ $sga _dynamic_components--View current shared memory SGA Total size '  sga from  dual;        select sum (current_size)  from v\ $SGA _dynamic_components;exitend "; Echo  " ";echo -e  "\t show parameter sga  --view SGA parameters  "; echo - e  "\t show parameter sga_max_size  --View system SGA Current maximum limit";echo -e  "\t  show sga  --View user SGA Information ";echo -e " \t select sum (current_size)  from  v\ $SGA _dynamic_components--View current shared memory SGA Total size ";echo "   " }test_shared3 () {' echo  ' su -  oracle -c  ' Sqlplus /nolog ' <<end           conn sys/sys as sysdba             clear screen;        show parameter shared_ Pool_size;        select component,current_size from v\ $SGA _dynamic_components        where component= ' Shared pool ' ; Exitend ';echo ;echo -e  "\t  view shared pool size  \n \t show parameter shared_pool_size   \ n ";echo -e " \t select component,current_size from v\ $SGA _dynamic_components  \n \t where component= ' Shared pool ' ";} Test_data4 () {' echo            ' su - oracle  -c  ' Sqlplus / as sysdba ' <<end                  select  '-------select name from v\$ datafile--View data Files '  sga from dual;                  select name from v\ $datafile;                  select  '-------select  Name from v\ $tempfile '  sga from dual;                 select  Name from v\ $tempfile; Exitend ';echo             -e  "\n\t  View data file: \n \t select name from v\ $datafile;  \n  \t select name v\ $tempfile; \ n ";} #数组ora = (test_parameter1 test_sga2 test_shared3 test_data4) #查询PS3 = "Query information:" Name= (      "User parameter initialization information query!"                                                          "      "User SGA information query!"                                                                       "    " User share pool size!                                                                        "    " See where the data file disk is located!                                                             ") select i in   "${name[@]}" docase  $REPLY  in            1|2|3|4)               clear               ${ora[$[$REPLY  - 1]]}               echo               ;;            *)                echo                echo  "SELECT Error, Exit!" "              exit 1;; esacdone[[email protected] D esktop]# sh oraclesh.sh1)   User parameter initialization information query!                                       &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;2)   User SGA information query!                                                               3)   user share pool size! &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;4)   View data file disk location!          Inquiry Information:3sql> name          type  value------------------------------------ ----------- ------------------------------shared_pool_size       big  integer 0sql>   2  component         Current_size---------------------------------------------------------------- ------------Shared pool            369098752sql> disconnected from  Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 -  productionwith the partitioning, olap, data mining and real  application testing options   view shared Pool size     show parameter  Shared_pool_size   select component,current_size from v$sga_dynamic_components     where component= ' shared pool ' query information: 1)   User parameter initialization information query!                                               &NBSP;&NBSP;&NBSP;2)   User SGA information query!                                                               3)   user share pool size! &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;4)   View data file disk location!          Inquiry Information:4sql>  SGA-------------------------------------------------------------select name from v$ datafile--Viewing data files sql>  NAME--------------------------------------------------------------------------------/u01/app/oracle/oradata/orcl/system01.dbf/u01/app/oracle/oradata/orcl/sysaux01.dbf/u01/app/oracle/oradata/orcl/undotbs01.dbf/u01/app/ oracle/oradata/orcl/users01.dbf/u01/app/oracle/oradata/orcl/example01.dbfsql>  SGA-----------------------------------------select name from v$tempfilesql>  NAME--------------------------------------------------------------------------------/u01/app/oracle/oradata/ orcl/temp01.dbfsql> disconnected from oracle database 11g enterprise  edition release 11.2.0.1.0 - productionwith the partitioning, olap,  data mining and real application testing options   Viewing data files:    select name from v$datafile;    select name v$tempfile; Query information: E Select error, Exit! [[email protected] desktop]#














This article is from the "One Meter Sunshine" blog, please be sure to keep this source http://sunshine3.blog.51cto.com/3988340/1703840

A little bit of learning shell+sql

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.