原创 根據表中的行創建一個分隔列表

比如name中的A,B,C oracle11.2的分析函數listagg select cid,            sum(sal) as total_sal,            listagg(ename,' ,') withi

原创 remap_tablespace修改數據庫表空間

首先,以schemas方式導出用戶JCMS24的全部數據: expdp system/system directory=data_pump_dir dumpfile=test_user.dmp schemas=JCMS24 說明:使用sy

原创 表空間的一些知識

1.創建表空間 create tablespace xxx datafile 'd:\...\book.dbf' size 32M autoextend on next 10M maxsize 1000M; 注:表空間一般放置位置sele

原创 oracle創建本月日曆

with x1 as /*1、給定一個日期*/ (select to_date('2015-07-01','yyyy-mm-dd') as cur_date from dual), x2 as /*2、取月初*/ (select trun

原创 PGA資源的管理

PAG_AGGREGATE_RAEGET的使用情況,比如:PGA cache hit percentage 可以使用以下視圖觀察: 監控PGA work area 的幾個視圖: v$sql_workarea_histogram v$pga

原创 oracle查詢用戶下每張表的信息

 SELECT t1.Table_Name AS "表名稱", t3.comments AS "表說明", t1.Column_Name AS "字段名稱", t1.Data_Type AS "數據類型", t1.Data_Leng

原创 關於函數row_number,rank,dense_rank排序

eg:返回排名前三的用戶 select no,           sal,           row_number() over(partition by mo order by sal desc) as row_number,   

原创 計算百分比-比例函數ratio_to_report

select no as 部門,                      工資合計,                      總合計,                      round((工資合計/總合計)*100,2) as 工

原创 取最大值最小值

分析函數 select no,           eno,           max(name) keep(dense_rank first order by sal) over(partition by no) as 最小值,   

原创 查看oracle數據庫的使用狀態

 所要用到的視圖:  v$session,v$sesstat,v$statname,v$sqlarea,v$session_wait,v$process select * from v$process; select * from v

原创 日期常用取值

select date,           to_number(to_char(date,'hh24')) 時,           to_number(to_char(date,'mi')) 分,           to_numbe

原创 計算累計差

思路:先將需要進行累積的值變成負值,再進行累加,即得到累計差 with x as (select rownum as seq,a.* from (select 編號,項目,金額 from detail order by 編號) a) se

原创 oracle簡單小知識

1.約束 constraint constraint_name check(codition) constraint constraint_name unique(column_name) constraint constraint_

原创 計算兩個日期之間的工作天數

返回A,B兩個員工聘用日期之間的工作天數 create table test as select level as id from dual connect by level<500; select sum(case         

原创 extract用法

與to_char一樣,extract可以提取時間字段中的年月日時分秒。不同的是,extract的返回值確實number類型。 create table test as  select extract(year from systimest