常用编辑命令:
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. Android窗口管理服务WindowManagerService显示Activity组件的启动窗口(Starting Window)的过程分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8577789 在Android系统中,Activ ...

  2. mysql 5.6 General error: 1364 Field mysql 严格模式导致

    问题:SQLSTATE[HY000]: General error: 1364 Field 解决方法:set global sql-mode=”NO_AUTO_CREATE_USER,NO_ENGIN ...

  3. VS2012 拆分视图按钮不见,代码,设计

    工具--选项--HTML设计器 然后重启就有了.

  4. .net中用到的一些方法

    //文件操作string fullDirPath = Utils.GetMapPath(string.Format("/aspx/{0}/", buildPath)); Direc ...

  5. String和StringBuilder 的使用区别

    String 类有不可变性,每次执行操作时都会创建一个新的String对像,需要对该对象分配新的空间. StringBuilder 解决了对字符串重复修改过程中创建大量对象的问题.初始化一个Strin ...

  6. String()与toString()区别和应用

    首先,String()和toString()方法都是将其它类型的变量转换为字符串的方法.但两者存在一定的区别: x.toString(): 无法转换null和undefined: 来看下面的小例子: ...

  7. BestCoder Round #20 部分题解(A,B,C)(hdu5123,5124,5125)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud who is the best? Time Limit: 2000/1000 MS ...

  8. 【solr专题之一】Solr快速入门

    一.Solr学习相关资料 1.官方材料 (1)快速入门:http://lucene.apache.org/solr/4_9_0/tutorial.html,以自带的example项目快速介绍发Solr ...

  9. java读取xml文件报“org.xml.sax.SAXParseException: Premature end of file” .

    背景:java读取xml文件,xml文件内容只有“<?xml version="1.0" encoding="UTF-8"?>”一行 java读取该 ...

  10. django中使用json.dumps处理数据时,在前台遇到字符转义的问题

    django后台代码: import json ctx['dormitory_list'] = json.dumps([{", "is_checked": 1}, {&q ...