-
DOS:
内含两种方法:
-
sqlplus username@connect_identifier,如以下示例中:sqlplus bzgl@ora10g
-
sqlplus username[/password][@connect_identifier],如以下示例中:sqlplus bzgl/bzgl@ora10g
|
Microsoft Windows [版本 6.0.6000] 版权所有 (C) 2006 Microsoft Corporation。保留所有权利。 C:UsersGoCool>sqlplus bzgl@ora10g SQL*Plus: Release 9.2.0.1.0 - Production on 星期五 12月 14 10:50:12 2007 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. 请输入口令: 连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> exit 从Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options中断开 C:UsersGoCool>sqlplus bzgl/bzgl@ora10g SQL*Plus: Release 9.2.0.1.0 - Production on 星期五 12月 14 10:50:44 2007 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. 连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> exit 从Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options中断开 |
-
通过SQL Plus登录
-
开始所有程序Oracle-OraHomeApplication DevelopermentSQL Plus
它将调用:C:oracleora92BINSQLPLUSW.EXE
-
利用“登录”窗口登录
-
填满3个框
-
填满前两个框
-
填满前一个框
-
设置编辑环境
编辑环境可以用于设置调试时选择编辑的默认编辑器,默认系统通常为notepad
-
向控制台输出
Oracle内置包DMBS_OUTPUT.PUT_LINE(RESULT
|
SQL> BEGIN 2 DBMS_OUTPUT.PUT_LINE('AAABBBCCC'); 3 END; 4 / PL/SQL 过程已成功完成。 SQL> SET SERVEROUTPUT ON SQL> BEGIN 2 DBMS_OUTPUT.PUT_LINE('AAABBBCCC'); 3 END; 4 / AAABBBCCC PL/SQL 过程已成功完成。 |
/符号代表向控制台输出
但是注意到上面一半的代码虽然过程已成功完成,但是却没有达到预期效果(向控制台输出)
这是因为SERVEROUTPUT属性默认设置为OFF所致,只需运行:
SQL> SET SERVEROUTPUT ON
即可将其换为ON。
再次运行程序即可。
-
修改
当然,复制代码后修改再执行确实简单,但是这里要介绍的不是这种方法。
利用SQLPLUS的edit,将可以对当前的输入进行编辑,它将打开默认的编辑器进行编辑,如何设置默认编辑器在步骤三有说明:
示例:
|
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. 连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> BEGIN 2 DBMS_OUTPUT.PUTLINE('AAABBBCCC');--注意PUTLINE错误应为PUT_LINE 3 END; 4 / DBMS_OUTPUT.PUTLINE('AAABBBCCC');--注意PUTLINE错误应为PUT_LINE * ERROR 位于第 2 行: ORA-06550: 第 2 行, 第 14 列: PLS-00302: 必须声明 'PUTLINE' 组件 ORA-06550: 第 2 行, 第 2 列: PL/SQL: Statement ignored SQL> EDIT 已写入文件 afiedt.buf 1 BEGIN 2 DBMS_OUTPUT.PUT_LINE('AAABBBCCC');--注意PUTLINE错误应为PUT_LINE 3* END; SQL> / PL/SQL 过程已成功完成。 SQL> EDIT 已写入文件 afiedt.buf 1 SET SERVEROUTPUT ON; 2 BEGIN 3 DBMS_OUTPUT.PUT_LINE('AAABBBCCC');--注意PUTLINE错误应为PUT_LINE 4* END; SQL> / SET SERVEROUTPUT ON; * ERROR 位于第 1 行: ORA-00922: 选项缺失或无效 SQL> EDIT 已写入文件 afiedt.buf 1 BEGIN 2 DBMS_OUTPUT.PUT_LINE('AAABBBCCC');--注意PUTLINE错误应为PUT_LINE 3* END; SQL> SET SERVEROUTPUT ON SQL> / AAABBBCCC PL/SQL 过程已成功完成。 SQL> |
-
显示信息:
利用SQL> SHOW ALL可以显示当前环境变量的值。
也可以利用SQL>SHOW PARAMETERS来显示。
|
SQL> show serveroutput serveroutput OFF SQL> set serveroutput SP2-0265: serveroutput必须被置为 ON 或 OFF SQL> set serveroutput on SQL> show serveroutput serveroutput ON 大小2000格式WORD_WRAPPED |