Chinaunix首页 | 论坛 | 博客
  • 博客访问: 98443
  • 博文数量: 36
  • 博客积分: 2000
  • 博客等级: 大尉
  • 技术积分: 375
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-25 13:47
个人简介

EnjoyIt

文章分类

全部博文(36)

文章存档

2014年(3)

2009年(1)

2008年(32)

我的朋友

分类: Oracle

2008-02-25 15:07:27

sqlplus
命令行参数
/ as {sysdba|sysopr}:使用操作系统用户验证,以osdba或osopr一员的身份登录,如验证通过,被赋予sysdba或sysopr的权限
使用格式:sqlplus "/ as sysdba"
/nolog:不执行connect操作,直接进入sqlplus操作界面
-s:silent模式,不显示sqlplus启动信息和提示符
<:接受sql脚本从标准输入重定向
<<:立即文档
提示符命令
accept variable [number|char|date] [format format] [default default] [prompt text] [hide]:接受输入变量
例子:accept pwd char format a8 prompt 'Password:' hide
column column [format format] [heading heading]:设定对某个域的显示格式
如果要同时改变某域的输出长度和标题,必须使用column命令
见emp的定义,name本为char(20),输出缩为10位,duty本为 char(1),扩张为6位,以便有足够的空间显示中文标题。
SQL>column name format a10 heading '姓名';
SQL>column duty format a6 heading '职位';
SQL>column age format 999999 heading '年龄';
SQL>column upd_ts format a14 heading '更新时间';
SQL>select name,duty,age,upd_ts from emp;
show option:显示SET的选项
spool [filename|off]:输出重定向文件
timing [start text|show|stop]:定时器
SET选项
autocommit:自动提交insert、update、delete带来的记录改变,缺省为off
colsep:域输出分隔符
define:识别命令中的变量前缀符,缺省为on,也就是'&',碰到变量前缀符,后面的字符串作为变量处理
如果待更新内容包含'&'(在URL中很常见),而define非设为off,sqlplus会把'&'后面紧跟的字符串当成变量,提示输入,这里必须重新输入'&'和那个字符串,才能实现正常更新。将define设为off,就不再进行变量判断。
SQL>set define off;
SQL>update bbs_forum set url='' where forum_id=1;
echo:显示start启动的脚本中的每个sql命令,缺省为on
feedback:回显本次sql命令处理的记录条数,缺省为on
heading:输出域标题,缺省为on
linesize:输出一行字符个数,缺省为80
如果一行输出超过linesize,会回车到第二行,这样格式就会混乱。
markup html:html格式输出,缺省为off
通常需要与spool配合,否则html输出就没有意义。
numwidth:输出number类型域长度,缺省为10
长number类型的域常常因为输出长度的问题,引起误会。
pagesize:输出每页行数,缺省为24
为了避免分页,可设定为0。
termout:显示脚本中的命令的执行结果,缺省为on
timing:显示每条sql命令的耗时,缺省为off
trimout:去除标准输出每行的拖尾空格,缺省为off
trimspool:去除重定向(spool)输出每行的拖尾空格,缺省为off
例子
以文本形式下载表数据
oracle缺乏将表中数据输出至文本文件的工具,因此只能利用sqlplus和unix工具做变通的处理
sqlplus -s dbuser/oracle set colsep |;
set echo off;
set feedback off;
set heading off;
set pagesize 0;
set linesize 1000;
set numwidth 12;
set termout off;
set trimout on;
set trimspool on;
spool tmp.txt;
select * from emp;
spool off;
exit
EOF
tr -d ' ' < tmp.txt >emp.txt 删除空格,可选
注意:一定要用spool,如果在命令行中直接用>tmp.txt可能会造成数据缺失,至少在Unixware7上如此
假定某域是char(n),如中间出现回车\n,则下载出的这条记录的格式将会错乱,不宜采用此方法
 
命令:E:\oracle\ora92\Apache\Apache\bin\htpasswd.exe
生成文件:E:\oracle\ora92\sqlplus\admim\iplusdba.pw
//建立新文件及使用者
htpasswd -c -b filename userName passWord
//新增使用者或更新原使用者密碼
htpasswd -b filename userName passWord
cmd>cd E:\oracle\ora92\Apache\Apache\bin
cmd>htpasswd.exe  -bc E:\oracle\ora92\sqlplus\admin\iplusdba.pw admin 12345
-c  Create a new file.
-n  Don't update file; display results on stdout.
-m  Force MD5 encryption of the password (default).
-d  Force CRYPT encryption of the password.
-p  Do not encrypt the password (plaintext).
-s  Force SHA encryption of the password.
-b  Use the password from the command line rather than prompting for it.
阅读(853) | 评论(0) | 转发(0) |
0

上一篇:SCN(3)

下一篇:共享&专用

给主人留下些什么吧!~~