常用的分析函数
--计算employees表中相同经理下的每一雇员和雇佣日期正好位于雇员正前后的雇员的平均薪水:SELECT manager_id, last_name, salary, AVG(salary) over(PARTITION BY manager_id ORDER BY hire_date rows BETWEEN 1 pr...
killing my session in oracle
转自http://www.orafaq.com/files/KillingMySessions_1.txt KILLING MY SESSIONS IN ORACLEAuthor JP VijaykumarDate Nov 14th 2009Many a time, developers ask for procedures to kill there own s...
oracle 正规表达式
转自 http://www.psoug.org/reference/regexp.htmlGeneral InformationAnchoring Characters Character Class Description^ Anchor the expression to th...
查看表空间使用率SQL语句
spool /home/oracle/tablespace.sql SELECT file_name, tablespace_name, bytes/(1024*1024) bytes1, autoextensible, maxbytes/(1024*1024) maxbytes1, user_bytes/(1024*1024) user_bytes1 FROM dba_data_f...
Long类型转Lob类型
SQL> create table t (x long);Table created.SQL> insert into t values('asdarewhdfhsdkjfh');1 row created.SQL> commit;Commit complete.SQL> create table a (x clob);Table created.SQL> insert into ...
序列的回顾
-- Create sequence create sequence testseqminvalue 5 --最小值 maxvalue 20 --最大值start with 5 --开始值increment by 1 --增长速度cache 10&nbs...
迁移某个表的数据
一、把表的数据导出exp userid=scott/tiger@orcl tables=emp file=E:\oracle\orabak.dmp log=E:\oracle\orabak.log 二、把表的数据导入imp userid=scott/tiger@orcl file=/home/oracle/orabak.dmp...
快速删除某个用户下的所有表数据
一、禁止所有的外键约束在pl/sql developer下执行如下语句:SELECT 'ALTER TABLE ' || table_name || ' disable CONSTRAINT ' || constraint_name || ';' FROM user_constraints where CONSTRAINT_TYPE = 'R';...
排序后,查询某个范围的记录
有表ord(ordseq, ordno, ctrpty, orddt), 其中ordseq为number型,ordno和ctrpty为varchar2型,而orddt为日期型,查询显示ord表按ordseq排序后第21至30条记录首先按ordseq排序查询ord表,看都有什么内容SELECT ord.ords...
按季度求和或平均值等例子
SELECT * FROM SCOTT.EMP ORDER BY HIREDATE; 结果如下:1 7369 SMITH CLERK 7902 1980-12-17 800.00 202 7499 ALLEN SALESMAN 7698 1981-2-2...
表和列的说明(comments)的用法
-- Add comments to the tablecomment on table EMP is 'Employee';-- Add comments to the columnscomment on column emp.mgr is 'Manager';-- Retrieving Table CommentsSELECT * FROM user_tab_com...