sqlplus常用操作命令2
常用编辑命令:
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的更多相关文章
- sqlplus常用操作命令(转)
SQL*PLUS 是Oracle提供的一个工具程序,它不仅可以用于测试,运行SQL语句和PL/SQL块,而且还可以用于管理Oracle数据库 1.启动sql*plus 为了使用sql*plus,必须 ...
- 【转载】Linux中常用操作命令
说明:开始学习linux系统,为了方便查看,特转载一篇Linux中常用操作命令,转载地址:http://www.cnblogs.com/laov/p/3541414.html 正文: Linux简介及 ...
- Git常用操作命令与图解
Git 是一个很强大的分布式版本控制系统.它不但适用于管理大型开源软件的源代码,管理私人的文档和源代码也有很多优势. Git常用操作命令: 1) 远程仓库相关命令 检出仓库:$ git clone g ...
- svn 常用操作命令
svn 常用操作命令 检出 svn checkout http://路径(目录或文件的全路径) [本地目录全路径] --username 用户名 svn checkout svn://路径(目录或文件 ...
- MongoDB(1):常用操作命令大全
MongoDB常用操作命令大全(转) http://www.jb51.net/article/48217.htm 成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可以进行数据库的一些操 ...
- sqlplus常用命令
原文 sqlplus常用命令 desc 表名 显示表的结构 show user 显示当前连接用户 show error 显示错误 sho ...
- hadoop常用操作命令
#############centos6.8IP常用操作命令#######################DEVICE=eth0TYPE=EthernetONBOOT=yesNM_CONTROLLED ...
- 2018.4.23 git常用操作命令收集(转)
Git常用操作命令收集: 1. 远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/jquery.git 查看远程仓库:$ git remote -v ...
- HBase常用操作命令
HBase常用操作命令 1.进入HBase脚本客户端 #hbase shell #进入HBase脚本客户端 > whoami #查看当前登录用户 > status ...
随机推荐
- Android设备内存和SD卡操作工具类
package cc.c; import java.io.File; import java.util.List; import android.os.StatFs; import java.io.F ...
- [汇编学习笔记][第十七章使用BIOS进行键盘输入和磁盘读写
第十七章 使用BIOS进行键盘输入和磁盘读写 17.1 int 9 中断例程对键盘输入的处理 17.2 int 16 读取键盘缓存区 mov ah,0 int 16h 结果:(ah)=扫描码,(al) ...
- 图片翻页效果引出的animate.css,很好玩,多动动吧~
有一个项目,客户需要页面翻转的效果,需要应用在合作伙伴里面的图片上,一共有43张图片,我把它做成了随机定时的转动,鼠标经过时转动: animate.css科普文章:http://www.dowebok ...
- Android 开源框架
不推荐使用UltimateAndroid.KJFrameForAndroid.ThinkAndroid.Afinal.xUtil等这种集成网络请求.图片加载.数据库ORM.视图依赖注入.UI框架等的集 ...
- JAVA-判断请求来自PC端还是手机端
某些情形,我们需要判断Http请求是来自手机端还是电脑端,关键是取得User-Agent的信息,进行筛选判断即可. 核心类如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
- solr热身
入博客园快满一年,居然没写一篇博客,好惭愧. 公司的搜索系统需要从Lucene.net(更新相当不给力)换成solr了,最近一直在学习solr,相关资料是相当的少啊,特别是还要在.net环境下开发.准 ...
- 一些不熟悉的SQL脚本--约束条件
1.根据表名查询主键的SQL语句 SELECT D.COLUMN_NAME AS COLNAME FROM USER_CONS_COLUMNS D, USER_CONSTRAINTS M WHERE ...
- js基础-需要注意的地方
---因为跟别的语言很像,所以只记录要注意的地方 1.== 和 === 的区别 ===要求类型也相等 "5"==5 = ture "5"===5 = false ...
- 认识WebSocket理论篇
本文转自http://www.ibm.com/developerworks/cn/java/j-lo-WebSocket/ HTML5作为下一代WEB标准,拥有许多引人注目的新特性,如Canvas.本 ...
- hdu 1099 Lottery
这是我第一次写博客,作为一个ACMer,经常进别人的博客,所以自己也想写写博客. HDU 1099 Lottery Time Limit: 2000/1000 MS (Java/Others) ...