码迷,mamicode.com
首页 > 数据库 > 详细

oracle 简单SQL

时间:2014-05-01 21:33:20      阅读:447      评论:0      收藏:0      [点我收藏+]

标签:style   class   tar   ext   color   get   int   http   rgb   line   数据   

1,  insert into test select * from test;(造测试数据)

2,  create table b as select * from a; (创建表结构一样的空表,数据可同上插入数据)

 

3,linux系统下让sqlplus支持历史命令回调

在linux中实现上述功能,需要一个小工具,叫做rlwrap,这个程式本身是个Shell,可以运行任何你提供给它的命令包括参数,并添加命令历史浏览功能。 The rlwrap program is under the GPL license。
 
步骤:
1,下载
2,安装
*注意以下操作要在root用户下执行
[root@localhost ~]$ tar -xzvf rlwrap-0.37.tar.gz
[root@localhost ~]$ cd rlwrap-0.37
[root@localhost rlwrap-0.37]# ./configure
[root@localhost rlwrap-0.37]# make
[root@localhost rlwrap-0.37]# make install
 
或是你用yum搞定吧
先搜下看你的yum repo有没有
yum search rlwarp && yum install -y rlwarp;
 
OK, 安装完毕,接下来就是如何使用了
 
3,使用
切换到oracle 用户下
[root@localhost rlwrap-0.37]# su - oracle
在sqlplus前面加上rlwrap就可以了
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba
 
OK,现在可以试下上下键调用历史命令了,真方便
 
注意:其中rlwrap是一个工具,不仅可以应用在sqlplus上,其它像rman 或者别的工具都可以在其前面加上rlwrap来实现历史命令调用
 
当然每次调用sqlplus前都要敲rlwrap也有些烦,有个办法,就是使用别名,以后就可以更方便的使用sqlplus了,方法如下:
 
alias sqlplus=‘rlwrap sqlplus‘
 
把上面的语名加到.bash_profile里就可以了
 
4,在linux环境下使用sqlplus,在回删(backspace)时往往会出现乱码。
出现乱码是由于oracle的sqlplus不使用gnu的 readline库造成的。   解决方法有两种: 1。要使用回删键(backspace)时,同时按住ctrl键 2。设定环境变量 在bash下:$ stty erase ^?或者把 stty erase ^? 添加到.bash_profile中。 在csh下:$ stty erase ^H或者把 stty erase ^H  添加到.cshrc中。
 
5,oracle sqlplus 简单清屏
clear screen

oracle 简单SQL,码迷,mamicode.com

oracle 简单SQL

标签:style   class   tar   ext   color   get   int   http   rgb   line   数据   

原文地址:http://www.cnblogs.com/ruiy/p/StructuredQueryLanguage.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!