Sqlplus联机文档学习

地址:http://download.oracle.com/docs/cd/E11882_01/server.112/e16604/ch_four.htm#i1039255

[原文] Running PL/SQL Blocks

You can also use PL/SQL subprograms (called blocks) to manipulate data in the database. See your Oracle Database PL/SQL Language Reference for information on individual PL/SQL statements.

SQL*Plus treats PL/SQL subprograms in the same manner as SQL commands, except that a semicolon (;) or a blank line does not terminate and execute a block. Terminate PL/SQL subprograms by entering a period (.) by itself on a new line. You can also terminate and execute a PL/SQL subprogram by entering a slash (/) by itself on a new line.

You enter the mode for entering PL/SQL statements when:

  • You type DECLARE or BEGIN. After you enter PL/SQL mode in this way, type the remainder of your PL/SQL subprogram.

  • You type a SQL command (such as CREATE PROCEDURE) that creates a stored procedure. After you enter PL/SQL mode in this way, type the stored procedure you want to create.

SQL*Plus stores the subprograms you enter in the SQL buffer. Execute the current subprogram with a RUN or slash (/) command. A semicolon (;) is treated as part of the PL/SQL subprogram and will not execute the command.

SQL*Plus sends the complete PL/SQL subprogram to Oracle Database for processing (as it does SQL commands).

[译文]

执行PL/SQL块命令

你可以使用PL/SQL子程序(块)来执行数据库的操作。特别的的PL/SQL语句可以参考Oracle数据库PL/SQL语言指导。

Sqlplus对待PL/SQL块命令的执行同SQL命令是一样的方式,除了分号(;)或空行不能终止和执行块命令。如果想结束PL/SQL命令则要在新的一行输入点号(.)。也可以通过在新的一行输入斜划线(/)来终止和执行PL/SQL块命令。

在下列模式进行PL/SQL语法模式:

当输入DECLARE或者是BEGIN,后面就可以按照PL/SQL语法模式进行输入。

输入SQL命令,创建预存储命令,然后就可以按照你的想法进行创建PL/SQL命令了。

Sqlplus存储块命令在SQL缓冲里。使用RUN命令或斜划线(/)执行命令,而分号(;)号是被 当做PL/SQL块命令的一部分看待,而不执行命令。

Sqlplus把PL/SQL块命令像SQL命令一样发给Oracle数据库执行。