------------高级查询 开窗函数--------------select ename,sal,max(sal)over(),min(sal)over()from emp;select ename,sal,sum(sal)over(),sum(sal)over(orderby ename)from--;连续求和select deptno,sal ,sum(sal)over(partitionby deptno orderby ename)as s from emp;--分部门连续求和
数据字典
-----------数据字典select table_name from all_tables where owner ='SCOTT'--查询用户scott下的所有表select*from all_tab_columns where table_name ='emp'--查询表emp的所有字段select*from all_constraints where table_name ='EMP'--查询表的约束select*from sys.all_ind_columns where table_name ='EMP'--查询表的索引列select table_name ,comments from dictionary where table_name like'%TABLE%';--数据字段视图
--创建索引createindex abc on student(sid,sname);createindex abc1 on student(sname,sid);--删除索引dropindex pk_dept1;--SQL优化--删除一张表的重复记录 可以使用唯一字段 --methhod1deletefromtablewhere id notin(selectmin(id)from t groupby name,age)--method2deletefrom t where id in(Selectdistinct a2.id from t a1,t a2 where a1.id>a2.id and a1.name=a2.name and a1.age=a2.age);--methos3deletefrom t a1 wherenotexists(select*from t a2 where a1.id>a2.id and a1.name=a2.name and a1.age=a2.age );