删除数据表中的重复记录
1.先创建一个表CREATE TABLE APPTEST (APP_ID INTEGER primary key NOT NULL,MOBILE nvarchar2(50) NOT NULL);向其中插入1kw条测试数据2.假设其中MOBILE字段大量重复,要删除重复记录,可以有如下三种方法:(1)简单利用rowid删除delete from APPTEST a where rowid not in (select max(rowid) from APPTEST b where a.mobile=b.mobile);据说,这种方法在数据量很大时,效率并不高有一些人说这种方法因为用到了rowid,所以效率较高。经测试,花费时间2222s。回滚空间自动膨胀到2.5G。(2)利用分析函数delete APPTEST where rowid in (select
(zt)oracle的分析函数over 及开窗函数(增加了一点自己的理解)
oracle的分析函数over 及开窗函数[@more@]一:分析函数overOracle从8.1.6开始提供分析函数,分析函数用于计算基于组的某种聚合值,它和聚合函数的不同之处是对于每个组返回多行,而聚合函数对于每个组只返回一行。 下面通过几个例子来说明其应用。 1:统计某商店的营业额。 date sale1 202 153 144 185 30create table test_over(date1 number,num number)insert into test_over values (1,10);insert into test_over values (2,33);insert into test_over values (3,12);insert into test_over values (4,23);insert into test_over valu
spool用法示例
下面文章简单介绍了一下spool的用法[@more@]set pagesize 0; --//##分页set echo off; --//##显示脚本中正在执行的SQL语句set space 0; --//##输出列间空格数set newp none; --//##页和页之间间隔set verify off; --//##文件校验set termout off; --//##屏幕内容输出set trimout on; --//##标准输出每行的拖尾空格set trimspool on; --//##重定向(spool)输出每行的拖尾空格set feedback off; --//##查询的行数set colsep =; --//##域输出分隔符set heading off; --//##列标题set linesize 500; --//##行允许字符数set timing off; --//#
查找系统中热点块top10
------查找系统中热点块top10 select /*+rule */ * from dba_objects where data_object_id in (select obj from (select obj from x$bh order by tch desc) where rownum<11); [@more@]------查找系统中热点块top10 select /*+rule */ * from dba_objects where data_object_id in (select obj from (select obj from x$bh order by tch desc) where rownum<11);
linux设置自动关机的方法
我用的方法是用crontab调用linux的关机命令。1.root登陆到linux主机2.运行crontab -e命令3.然后点击"i",对文本框进行编辑4.将下面内容填入:0 18 * * * halt -p意思是每天18:00整定时运行halt -p命令halt -p命令就是关机的意思。5.运行“:wq”进行保存退出6.运行下面的命令:/sbin/service crond restart意思是重启crond服务。7.设置成功感受:1.关机命令有很多种shutdown now这种关机命令不包含关闭电源,所以当你运行之后发现机器的电源还亮着。init 0这个关机命令很好,而且也包含关闭电源。但是不知道为什么,不能在cront