Run the SQL statement at the RMAN prompt.

Source: Internet
Author: User

When executing SQL statements at the RMAN prompt to manually restore the database, sometimes the SQL * Plus prompt and the operating system prompt are required. It is cumbersome to switch back at the RMAN prompt. In fact, RMAN provides us with some simple SQL statements and PL/SQL methods under the command line to avoid the above situation. This article describes some common commands at the RMAN prompt and their usage. 1. Execute SQL statement syntax at the RMAN prompt: SQL '<command>'. The syntax is relatively simple, that is, enter SQL at the prompt and then run the SQL command, commands are enclosed in single quotes. commands are generally executable SQL statements. They can also be PL/SQL blocks. If an SQL statement contains a file name, the file name and path must be enclosed by two single quotes. Double quotation marks must be used at the beginning and end of the SQL statement to execute the SQL query statement, however, there is no result to output the commonly used command startup [nomount | mount] At the RMAN prompt. shutdown immediate alter system archive log current alter database open [resetlogs] 2. Demonstrate executing SQL statement [SQL] a at the RMAN prompt. Execute commonly used starup and alter SQL statement robin @ SZDB: ~> Export ORACLE_SID = GOBO1 robin @ SZDB: ~> Rman target/Recovery Manager: Release 10.2.0.3.0-Production on Tue Jun 4 11:04:26 2013 Copyright (c) 1982,200 5, Oracle. all rights reserved. connected to target database (not started) RMAN> startup nomount; oracle instance started Total System Global Area 536870912 bytes Fixed Size 2074080 bytes Variable Size 314575392 bytes Database Buffers 213909504 bytes Redo Buffers 6311936 bytes RMAN> al Ter database mount; using target database control file instead of recovery catalog database mounted RMAN> alter database open; database opened RMAN> list copy of archivelog all; ---> View archived logs of the current database, 1 Archived Log List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- --------------------------- ---- 2084 1 8 A 20130604 09:53:17/u02/database/GOBO1/archive/ arch_816906485_20.8.arc RMAN> SQL' Alter system archive log current '; ---> archive the current log SQL statement: alter system archive log current RMAN> list copy of archivelog all; ---> an Archived Log List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- --------------------------- ---- 2084 1 8 A 20130604 09:53:17/u02/ database/GOBO1/archive/arch_816906485_1_8.arc 2085 1 9 A 20130604 10:46:36/u02/database/GOBO1/archive/arch _ 816906485_00009.arc B. Execute the SQL query statement as follows. No results are output for RMAN> SQL 'select sysdate from dual'; SQL statement: select sysdate from dual RMAN> SQL 'select * from v $ database'; SQL statement: select * from v $ database c. Execute an SQL statement with a path and a file name -- the following statement does not start with double quotation marks and contains the path in double single quotes, receive error message RMAN> SQL 'create tablespace ts1 datafile'/u02/database/GOBO1/oradata/ts1.dbf 'size 10 m'; RMAN-00571: ============================================== ==================================== RMAN-00569: ================ error message stack follows ============================ RMAN-00571: ========================================================== ============================== RMAN-00558: error encountered while parsing input commands RMAN-01006: error signalled during parse RMAN-02001: unrecognized punctuation symbol "/" -- The following SQL statement is successfully executed by RMAN> SQL "create tablespace ts1 datafile''/u02/database/GOBO1/oradat A/ts1.dbf ''size 10 m "; SQL statement: create tablespace ts1 datafile ''/u02/database/GOBO1/oradata/ts1.dbf'' size 10 m d. Execute PL/SQL block RMAN> SQL 'begin dbms_lock.sleep (3); end; '; SQL statement: begin dbms_lock.sleep (3); end; e, rman block Command Execution PL/SQL block RMAN> run {2> SQL 'begin dbms_lock.sleep (3); end; '; 3 >} SQL statement: begin dbms_lock.sleep (3); end; RMAN> run {2> SQL 'drop tablespace ts1 including co Ntents and datafiles '; 3 >} SQL statement: drop tablespace ts1 including contents and datafiles RMAN> shutdown immediate; database closed database dismounted Oracle instance shut down f. Switch to the system prompt RMAN> host; robin @ SZDB: ~> Exit host command complete RMAN>

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.