常用编辑命令:
A[ppend] text 将text附加到当前行之后
C[hange] /old /new 将当前行中的old替换为new
CLear] buff[er] 清除缓冲区中的所有行
DEL 删除当前行
DEL x 删除第x行
L[ist] 列出缓冲区中所有行
L[ist] x 列出缓冲区中第x行
R[un]或/ 运行缓冲区中保存的语句
x 将第x行作为当前行

SQL> select product_id,name
from
products; PRODUCT_ID NAME
---------- ------------------------------
Modern Science
Chemistry
Supernova
Tank War
Z Files
: The Return
Space Force
From Another Planet
Classical Music
Pop
Creative Yell
My Front Line rows selected. SQL> 1 --输入1显示第1行
* select product_id,name
SQL> append ,price --在第1行增加列,price
* select product_id,name,price
SQL> list --列出缓冲区中所有行
select product_id,name,price
from
* products
SQL> 1 --指定要修改的行
* select product_id,name,price
SQL> change /price / description --将列price替换为description
SP2-: String not found.
SQL> change /price /description
* select product_id,name,description
SQL> list
select product_id,name,description
from
* products
SQL> / --执行缓冲区中保存的语句 PRODUCT_ID NAME DESCRIPTION
---------- ------------------------------ --------------------------------------------------
Modern Science A description of modern science
Chemistry Introduction to Chemistry
Supernova A star explodes
Tank War Action movie about a future war
Z Files Series on mysterious activities
: The Return Aliens return
Space Force Adventures of heroes
From Another Planet Alien from another planet lands on Earth
Classical Music The best classical music
Pop The best popular music
Creative Yell Debut album
My Front Line Their greatest hits rows selected. SQL> run --同上,执行缓冲区中保存的语句
select product_id,name,description
from
* products PRODUCT_ID NAME DESCRIPTION
---------- ------------------------------ --------------------------------------------------
Modern Science A description of modern science
Chemistry Introduction to Chemistry
Supernova A star explodes
Tank War Action movie about a future war
Z Files Series on mysterious activities
: The Return Aliens return
Space Force Adventures of heroes
From Another Planet Alien from another planet lands on Earth
Classical Music The best classical music
Pop The best popular music
Creative Yell Debut album
My Front Line Their greatest hits rows selected. SQL>

二、保存、检索并运行文件

SQL> list  --列出缓冲区中的内容
select product_id,name,description
from
* products SQL> save /home/oracle/test_save.sql --保存缓冲区中的内容到指定路径指定的文件中
Created file /home/oracle/test_save.sql
SQL> get test_save.sql
select product_id,name,description
from
* products
SQL> start test_save.sql --将保存的文件内容读入缓冲区并执行 PRODUCT_ID NAME DESCRIPTION
---------- ------------------------------ --------------------------------------------------
Modern Science A description of modern science
Chemistry Introduction to Chemistry
Supernova A star explodes
Tank War Action movie about a future war
Z Files Series on mysterious activities
: The Return Aliens return
Space Force Adventures of heroes
From Another Planet Alien from another planet lands on Earth
Classical Music The best classical music
Pop The best popular music
Creative Yell Debut album
My Front Line Their greatest hits rows selected. SQL> @test_save.sql --同start PRODUCT_ID NAME DESCRIPTION
---------- ------------------------------ --------------------------------------------------
Modern Science A description of modern science
Chemistry Introduction to Chemistry
Supernova A star explodes
Tank War Action movie about a future war
Z Files Series on mysterious activities
: The Return Aliens return
Space Force Adventures of heroes
From Another Planet Alien from another planet lands on Earth
Classical Music The best classical music
Pop The best popular music
Creative Yell Debut album
My Front Line Their greatest hits rows selected. SQL> spool /home/oracle/select.txt --将以下输出的结果保存到指定文件中
SQL> / PRODUCT_ID NAME DESCRIPTION
---------- ------------------------------ --------------------------------------------------
Modern Science A description of modern science
Chemistry Introduction to Chemistry
Supernova A star explodes
Tank War Action movie about a future war
Z Files Series on mysterious activities
: The Return Aliens return
Space Force Adventures of heroes
From Another Planet Alien from another planet lands on Earth
Classical Music The best classical music
Pop The best popular music
Creative Yell Debut album
My Front Line Their greatest hits rows selected. SQL> spool off --停止输出结果,并关闭该文件,如果不spoo off,则后面输入的所有结果都会写入到上面的select.txt文件
SQL>
[root@rhel201 oracle]# ls
afiedt.buf oradiag_oracle select.txt testbak test_save.sql test.sql
[root@rhel201 oracle]# cat test_save.sql
select product_id,name,description
from
products
/
[root@rhel201 oracle]# cat select.txt
SQL> / PRODUCT_ID NAME DESCRIPTION
---------- ------------------------------ --------------------------------------------------
Modern Science A description of modern science
Chemistry Introduction to Chemistry
Supernova A star explodes
Tank War Action movie about a future war
Z Files Series on mysterious activities
: The Return Aliens return
Space Force Adventures of heroes
From Another Planet Alien from another planet lands on Earth
Classical Music The best classical music
Pop The best popular music
Creative Yell Debut album
My Front Line Their greatest hits rows selected. SQL> spool off
[root@rhel201 oracle]#

三、格式化列

SQL> /

PRODUCT_ID PRODUCT_TYPE_ID NAME                           DESCRIPTION                                             PRICE
---------- --------------- ------------------------------ -------------------------------------------------- ----------
Modern Science A description of modern science 19.95
Chemistry Introduction to Chemistry
Supernova A star explodes 25.99
Tank War Action movie about a future war 13.95
Z Files Series on mysterious activities 49.99
: The Return Aliens return 14.95
Space Force Adventures of heroes 13.49
From Another Planet Alien from another planet lands on Earth 12.99
Classical Music The best classical music 10.99
Pop The best popular music 15.99
Creative Yell Debut album 14.99
My Front Line Their greatest hits 13.49 rows selected. SQL> col product_id format 99 --两位数字
SQL> col name heading product_name format a13 word_wrapped --将列name显示为product_name,13个字符串,自动换行
SQL> col descripton format a20 word_wrapped --20个字符串,自动换行
SQL> col proce format $99.99 --以该格式显示price列内容
SQL> / PRODUCT_ID PRODUCT_TYPE_ID product_name DESCRIPTION PRICE
---------- --------------- ------------- -------------------------------------------------- ----------
Modern A description of modern science 19.95
Science Chemistry Introduction to Chemistry
Supernova A star explodes 25.99
Tank War Action movie about a future war 13.95
Z Files Series on mysterious activities 49.99
: The Aliens return 14.95
Return Space Force Adventures of heroes 13.49
From Another Alien from another planet lands on Earth 12.99
Planet Classical The best classical music 10.99
Music Pop The best popular music 15.99
Creative Yell Debut album 14.99
My Front Line Their greatest hits 13.49 rows selected. SQL> -----------
SQL> show linesize
linesize 200
SQL> show pagesize
pagesize 50
SQL> set linesize 150
SQL> set pagesize 80
SQL> SQL> set verify on --启用old行和new行的输出
SQL> /
Enter value for test:
old : select * from products where product_type_id=&test
new : select * from products where product_type_id= PRODUCT_ID PRODUCT_TYPE_ID product_name DESCRIPTION PRICE
---------- --------------- ------------- -------------------------------------------------- ----------
Modern A description of modern science 19.95
Science Chemistry Introduction to Chemistry SQL> set verify off --禁用old和new
SQL> /
Enter value for test: PRODUCT_ID PRODUCT_TYPE_ID product_name DESCRIPTION PRICE
---------- --------------- ------------- -------------------------------------------------- ----------
Supernova A star explodes 25.99
Tank War Action movie about a future war 13.95
Z Files Series on mysterious activities 49.99
: The Aliens return 14.95
Return SQL>

说明:
save filename 保存内容,保存时加上路径
save filename replace/apend 保存并替换/追加
get filename 打开filename文件
start filename 打开filename文件并执行
@filename 同上
edit filename 使用记事本或vi打开filename文件进行编辑,如果不指定filename,则打开当前缓冲区中的内容
define _edit='editor'或define _edit='vi'定义默认编辑器
spool filename 将输出结果保存到指定文件
spool off 结束结果输出

sqlplus常用操作命令2的更多相关文章

  1. sqlplus常用操作命令(转)

    SQL*PLUS 是Oracle提供的一个工具程序,它不仅可以用于测试,运行SQL语句和PL/SQL块,而且还可以用于管理Oracle数据库  1.启动sql*plus 为了使用sql*plus,必须 ...

  2. 【转载】Linux中常用操作命令

    说明:开始学习linux系统,为了方便查看,特转载一篇Linux中常用操作命令,转载地址:http://www.cnblogs.com/laov/p/3541414.html 正文: Linux简介及 ...

  3. Git常用操作命令与图解

    Git 是一个很强大的分布式版本控制系统.它不但适用于管理大型开源软件的源代码,管理私人的文档和源代码也有很多优势. Git常用操作命令: 1) 远程仓库相关命令 检出仓库:$ git clone g ...

  4. svn 常用操作命令

    svn 常用操作命令 检出 svn checkout http://路径(目录或文件的全路径) [本地目录全路径] --username 用户名 svn checkout svn://路径(目录或文件 ...

  5. MongoDB(1):常用操作命令大全

    MongoDB常用操作命令大全(转) http://www.jb51.net/article/48217.htm 成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可以进行数据库的一些操 ...

  6. sqlplus常用命令

    原文 sqlplus常用命令 desc 表名            显示表的结构 show user           显示当前连接用户 show error            显示错误 sho ...

  7. hadoop常用操作命令

    #############centos6.8IP常用操作命令#######################DEVICE=eth0TYPE=EthernetONBOOT=yesNM_CONTROLLED ...

  8. 2018.4.23 git常用操作命令收集(转)

    Git常用操作命令收集: 1. 远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/jquery.git 查看远程仓库:$ git remote -v ...

  9. HBase常用操作命令

    HBase常用操作命令 1.进入HBase脚本客户端 #hbase shell #进入HBase脚本客户端 > whoami    #查看当前登录用户 > status           ...

随机推荐

  1. Linux正則表達式-反复出现的字符

    星号(*)元字符表示它前面的正則表達式能够出现零次或多次.也就是说,假设它改动了单个字符.那么该字符能够在那里也能够不在那里,而且假设它在那里,那可能会不止出现一个.能够使用星号元字符匹配出如今引號中 ...

  2. [转]Laravel 4之请求

    Laravel 4之请求 http://dingjiannan.com/2013/laravel-request/ 获取请求数据 获取当前请求所包括的所有GET和POST数据 Route::get(' ...

  3. LabVIEW新手5大错误

    虽然NI LabVIEW软件长期以来一直帮助工程师和科学家们快速开发功能测量和控制应用,但不是所有的新用户都会遵循LabVIEW编程的最佳方法. LabVIEW图形化编程比较独特,因为只需看一眼用户的 ...

  4. EffectiveC#7--选择恒定的原子值类型数据

    1.恒定类型就是一但它们被创建,它们(的值)就是固定的. 恒定类型可以很好的在基于哈希代码的集合上工作.以Object.GetHashCode()方法返回的值,对同一个实例是必须相同的 2.一个客户类 ...

  5. MongoDB学习笔记06

    在shell中删除一个集合,执行db.test.drop()或者db.runCommand({"drop":"test"}),在MongoDB中命令其实是作为一 ...

  6. SPOJ 4206 Fast Maximum Matching (二分图最大匹配 Hopcroft-Carp 算法 模板)

    题目大意: 有n1头公牛和n2头母牛,给出公母之间的m对配对关系,求最大匹配数.数据范围:  1 <= n1, n2 <= 50000, m <= 150000 算法讨论: 第一反应 ...

  7. Win8.1系统下安装nodeJS

    Nodejs简介 Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高效.Node.js ...

  8. JSON的parse()方法

    JSON方法也可以接受另外的一个参数,作为还原函数. 实例: var book = { title:"JavaScript Learn", author:["wang&q ...

  9. float的理解

    1.浮动包裹性——浮动具有让元素按displya:inline-block显示(如果没有设置宽度和高度,则它可以显示的尽量窄高 度尽量小).2.浮动破坏性——浮动元素漂浮在标准流之上(但没有脱离文档流 ...

  10. 序列化layer创建的弹出表单并ajax提交

    /** *createTime:2015-09-13 *updateTime:2015-09-13 *author:刘俊 *phone:13469119119 *QQ:418873053 **/ va ...