2015年5月11日 星期一

Oracle listagg distinct

select col1, 
regexp_replace(
    listagg(col2, ',') within group (order by col2)
    ,'([^,]+)(,\1)+', '\1')
where rn = 1
group by col1;
ref from here

2015年3月27日 星期五

Oracle connection數上限 - 查詢

--The number of sessions the database was configured to allow

SELECT name, value 
  FROM v$parameter
 WHERE name = 'sessions';

--The number of sessions currently active

SELECT COUNT(*)
  FROM v$session;

2014年12月30日 星期二

解決:ORA-01000: maximum open cursors exceeded

先看看目前可用的數量是多少 show parameter open_cursors; 進行修改 alter system set open_cursors=1000 scope=both sid='*'; Oracle建議值為500

2014年8月8日 星期五

改win7的預設動態tcp port範圍

用netsh這個命令,可以從命令中的help得到用法 netsh interface ipv4 set dynamicportrange tcp 10000 10000

2014年7月4日 星期五

Batch file to delete files older than N days

forfiles -p "C:\what\ever" -s -m *.* -d <number of days> -c "cmd /c del @path"
See forfile documentation for more details.
For more goodies refer to An A-Z Index of the Windows XP command line

If you don't have forfiles installed on your machine, copy it from any Windows 2003 Server to your Windows XP machine at %WinDir%\system32\ This is possible since the EXE is fully compatible between Win2003 and WinXP.

Later versions of Windows and Windows Server have it installed by default.

Update Win7: Syntax has changed a little therefore the updated command is:
forfiles -p "C:\what\ever" -s -m *.* /D -<number of days> /C "cmd /c del @path"
ref from stackoverflow