1:給出時間,如"2011-7-23",查詢星期幾;
select to_char(to_date('2011-7-23','yyyy-mm-dd'),'day','nls_date_language = american') from dual;
結果: saturday
select to_char(to_date('2011-7-23','yyyy-mm-dd'),'day') from dual;
結果: 星期六
2:查詢系統時間;
select sysdate from dual;
3: round() 四捨五入,trunc(x,y) 擷取小數點後floor(y)位
4:迴圈列印輸出:
sql> set serverout on必須 設定伺服器輸出 開啟 不然看不到結果。sql> begin
2 for i in 1..10 loop
3 dbms_output.put_line(round(dbms_random.value*100));
4 end loop;
5 end;
6 /
5:rownum 隱式游標 取前多少行
select id from xx表 where rownum
select a.id from(select id from b order by name)a where orwnum
6:查詢本機ip,某**ip
select utl_inaddr.get_host_address() from dual;
select utl_inaddr.get_host_address('www.qq.com') from dual;
一些oracle函式
使用case表示式直接在select語句中執行條件邏輯 select ename,sal,case when sal 2000 then underpaid when sal 4000 then overpaid else ok end as status from emp coalesce函式用實...
ORACLE 的一些操作
檢視表建立時間 select ao.from all objects ao where object name module and object type table select from user tables select username,count username from v ses...
ORACLE 一些操作語句
查詢表的外來鍵 包括名稱,引用表的表名和對應的鍵名,下面是分成多步查詢 select from user constraints c where c.constraint type r and c.table name 要查詢的表 查詢外來鍵約束的列名 select from user cons c...