zoukankan      html  css  js  c++  java
  • oracle sqlplus

    1. DOS

    内含两种方法:

    1. sqlplus username@connect_identifier,如以下示例中:sqlplus bzgl@ora10g

    2. 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 星期五 1214 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 星期五 1214 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中断开



    1. 通过SQL Plus登录

    1. 开始所有程序Oracle-OraHomeApplication DevelopermentSQL Plus

    它将调用:C:oracleora92BINSQLPLUSW.EXE

    1. 利用“登录”窗口登录

    1. 填满3个框

    1. 填满前两个框

    1. 填满前一个框

    1. 设置编辑环境

    编辑环境可以用于设置调试时选择编辑的默认编辑器,默认系统通常为notepad

    1. 向控制台输出

    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

    再次运行程序即可。

    1. 修改

    当然,复制代码后修改再执行确实简单,但是这里要介绍的不是这种方法。

    利用SQLPLUSedit,将可以对当前的输入进行编辑,它将打开默认的编辑器进行编辑,如何设置默认编辑器在步骤三有说明:

    示例:

    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>


    1. 显示信息:

    利用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

     

    【转载】SQLPLUS的使用大全


     

  • 相关阅读:
    linux查看CPU和内存信息
    linux yum命令详解
    查看文件中关键字前后几行的内容
    vue.js+web storm安装及第一个vue.js
    android GPS: code should explicitly check to see if permission is available
    ASP.NET MVC Identity 使用自己的SQL Server数据库
    阿里云服务器,tomcat启动,一直卡在At least one JAR was scanned for TLDs yet contained no TLDs就不动了
    ASP.NET MVC4 MVC 当前上下文中不存在名称“Scripts”
    python 将windows字体中的汉字生成图片的方法
    Java android DES+Base64加密解密
  • 原文地址:https://www.cnblogs.com/volnet/p/994877.html
Copyright © 2011-2022 走看看