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 ...
随机推荐
- Linux下redis的安装及用法
1.下载源代码包redis-2.8.21.tar.gz,并将其上传到指定文件夹/urs/src,然后对其进行解压: [root@Slave1pc src]# tar -xvf redis-2.8.21 ...
- Qt快速入门系列教程目录
Qt快速入门系列教程目录
- EffectiveC#18--用IComparable和IComparer实现对象的顺序关系
1..Net框架提供了接口来描述对象的顺序关系:IComparable 和IComparer. 2.IComparable 为类定义了自然顺序,实现IComparer接口的类可以描述其它可选的顺序 3 ...
- System.AccessViolationException: 尝试读取或写入受保护的内存 解决办法
netsh winsock reset --运行此命令解决 错误描述: 之前装的vs2010后 再又安装了vs2013 ,运行之前的vs2010项目 就出现以上错误 错误应用程序名称: w3wp. ...
- 前端--关于javascript对象
在javascript中对象是一种基本的数据类型,在数据结构上是一种散列表,可以看作是属性的无序集合,除了原始值其他一切都是对象.它可以用来表示现实世界中或者我们大脑中抽象出来的客体,这和其他面向对象 ...
- Android Activity和intent
- 在 Xcode中 修改文件中自动创建的Created by和Copyright
在Xcode里创建的时候,会自动生成注释 // Created byxxx on 15/7/10. // Copyright (c) 2015年 xxxx. All rights reserved ...
- NSData、NSString 、 NSFileManager
1 NSData和NSMutableData的基本使用 1.1 问题 NSData类是IOS提供的用于以二进制的形式操作文件数据的类,NSData有两个常用的属性length和bytes,leng ...
- where和having的区别
1.用的地方不一样 where可以用在select update delete insert......into语句中 having只能用在select语句中 2.执行顺序不一样 where的搜索条 ...
- oc语言--面向对象的三大特性
一.封装 1.什么是封装 在程序上,隐藏对象的属性和实现细节,仅对外公开接口,控制在程序中属性的读和修改的访问级别:将对象得到的数据和行为(或功能)相结合,形成一个有机的整体,也就是将数据与操作数据的 ...