zoukankan      html  css  js  c++  java
  • 行sqlSQL*PLUS使用(三)

    最近使用开发的过程中出现了一个小问题,顺便记录一下原因和方法--行sql

        SQL> desc test; 名称 是不是为空? 类型 ----------------------------------------- -------- ------------------------ ID VARCHAR2(50) NAME VARCHAR2(20)

        begin for i in 10 ..1000 loop insert into test values(i,'wqp'); update test set name='top'; end loop; commit; end;

        演示 pause  变量

        SQL> show pause; PAUSE 为 OFF SQL> show pagesize pagesize 14

        set pause on set pause ***************************

        这样再做查询 select  * from test

        2:设置自动提交

        set autocommit on

        或者

        set autocommit immediate

        关闭: set  autocommit off

        set autocommit on 

        表现状态:

        show autocommit

        这样做DML语句的时候会自动提交;但是一般设置为关闭,以免错误提交后懊悔。

        
    SQL清屏命令:  
    clear screen

        编辑脚本:

        define命令:定义一些变量:

        SQL> define

        DEFINE _DATE           = "28-5月 -13" (CHAR)

        DEFINE _CONNECT_IDENTIFIER = "orcl" (CHAR)

        DEFINE _USER           = "HR" (CHAR)

        DEFINE _PRIVILEGE      = "" (CHAR)

        DEFINE _SQLPLUS_RELEASE = "1101000600" (CHAR)

        DEFINE _EDITOR         = "Notepad" (CHAR)

        DEFINE _O_VERSION      = "Oracle Database 11g Enterprise Edition Release 11.1.

        6.0 - Production

        With the Partitioning, OLAP, Data Mining and Real Application Testing options"

        CHAR)

        DEFINE _O_RELEASE      = "1101000600" (CHAR)

        DEFINE _RC             = "0" (CHAR)

        可以看到  _editor = notepad

        在windows中 notepad的路径一定要包含在path环境变量中,

        edit ss

        默认是编辑 ss的文件。

        PL/SQL要另起一行 加上/ 才能执行。

        4:列出sql 缓冲区中的内容并修改

        list 或者 l

        编辑缓冲区以后行命令:

        表现出来的缓冲区内容 * 代表以后行,

        如果某行出现错误,错误内容的行为以后行,

        change 命令使用:

        change命令 缩写 c

        用法: SQL> l 1 select id ,name from test 2 where id > 10 3 and id <100 4* SQL> l 4 --列出第四行数据 4* SQL> l3 --列出第三行数据 3* and id <100 SQL> c/100/15 --这句是把 100修改成10 3* and id <15 SQL> l ---列出修改后的sql 1 select id ,name from test 2 where id > 10 3 and id <15 4* SQL> / ID NAME -------------------------------------------------- ------------ 11 top 12 top 13 top 14 top 11 top 12 top 13 top 14 top 已选择8行。

        每日一道理
    人生是洁白的画纸,我们每个人就是手握各色笔的画师;人生也是一条看不到尽头的长路,我们每个人则是人生道路的远足者;人生还像是一块神奇的土地,我们每个人则是手握农具的耕耘者;但人生更像一本难懂的书,我们每个人则是孜孜不倦的读书郎。

        在某一行 添加部分sql   命令:  append    简称  a

        SQL> list 1 select id ,name from test 2 where id > 10 3 and id <15 4* SQL> l 3 --列出第三行 3* and id <15 SQL> a and name like '%to' -- a 是append的缩写 是在这个语句后追加响应的语句 后面是追加的语句 3* and id <15 and name like '%to' SQL> list 1 select id ,name from test 2 where id > 10 3 and id <15 and name like '%to' 4* SQL> / 未选定行 SQL> l 3 3* and id <15 and name like '%to' --列出第三行 SQL> c/'%to'/'%to%' --修改第三行 c是change的缩写 /需要修改的地方/修改后的内容 3* and id <15 and name like '%to%' SQL> list 1 select id ,name from test 2 where id > 10 3 and id <15 and name like '%to%' 4* SQL> / ID NAME -------------------------------------------------- -------------------- 11 top 12 top 13 top 14 top 11 top 12 top 13 top 14 top 已选择8行。

        在某一行后插入一行的命令:   input   简称 i 

        SQL> list 1 select id ,name from test 2 where id > 10 3 and id <15 and name like '%to%' 4 5 0 6* 0 /** dddd**/ --这里是上一次插入错误了,下次修改 SQL> 0 /** this is a demo **/ --往第0行插入了一个注释; SQL> list 1 /** this is a demo **/ 2 select id ,name from test 3 where id > 10 4 and id <15 and name like '%to%' 5 6 0 7* 0 /** dddd**/ SQL> 4 ---如果想在某一行后插入语句,首先 list 到 行号 这样就能够把行号设置为以后行 4* and id <15 and name like '%to%' SQL> i and name is not null -----表现以后行后,可以通过 input 命令 简称 i 停止追加 sql 语句 SQL> list 1 /** this is a demo **/ 2 select id ,name from test 3 where id > 10 4 and id <15 and name like '%to%' 5 and name is not null 6 7 0 8* 0 /** dddd**/ SQL>

    文章结束给大家分享下程序员的一些笑话语录: 腾讯的动作好快,2010年3月5日19时28分58秒,QQ同时在线人数1亿!刚刚看到编辑发布的文章,相差才2分钟,然后连专题页面都做出来了,他们早就预料到了吧?(其实,每人赠送10Q币,轻轻松松上两亿!)

    --------------------------------- 原创文章 By
    行和sql
    ---------------------------------

  • 相关阅读:
    L1-049 天梯赛座位分配​​​​​​​
    L1-046 整除光棍 大数除法
    天梯赛 L1-043 阅览室
    Hdu 1022 Train Problem I 栈
    蓝桥杯 历届试题 格子刷油漆  (动态规划)
    第九届蓝桥杯省赛真题 日志统计
    2018年第九届蓝桥杯第7题 螺旋折线
    2018年第九届蓝桥杯省赛 递增三元组
    蓝桥杯 历届试题 高僧斗法  (尼姆博弈)
    K-th Number
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3106601.html
Copyright © 2011-2022 走看看