Ref:http://www.adp-gmbh.ch/ora/sql/table_cast.html create or replace type date_obj as object (dt date)/create or replace type date_table as table of date_obj/create or replace function date_range(from_dt in date, to_dt in date) return date_table
declare cnt number;begin ---查詢要建立的表是否存在 select count(*)into cnt from user_tables where table_name='ENTRY_MODIFYSTATUS'; ---如果存在則刪除該表 if cnt>0 then dbms_output.put_line('表存在不建立'); else dbms_output.put_line('表不存在');
最近要進行導數的工作,從好幾張表中匯入到一張表,其中資料可能重複,所以在匯入之前要進行資料的比對。 方法一:我用group by having count(*)>1將重複的資料提取出來,然後進行人工比對,事實證明,有夠笨的! 方法二:請教了一位資深人員,提供了一個更好的方法。就是將三個欄位串連起來作為主鍵,進行資料是否重複的判斷。這裡值得注意的是某列的值可能為空白,所以要賦一個Null 字元串過去。select * from t1 where nvl(col1,
SQ本文通過舉例的方式來教你如何在Oracle中實現SELECT TOP N的方法。1.在Oracle中實現SELECT TOP N :由於ORACLE不支援SELECT TOP語句,所以在ORACLE中經常是用ORDER BY跟ROWNUM的組合來實現SELECT TOP N的查詢。簡單地說,實現方法如下所示: SELECT 列名1...列名n FROM (SELECT 列名1...列名n FROM 表名
查看使用者select * from dba_users 查看使用者表select * from user_tables /* Formatted on 2012-01-20 오전 10:32:56 (QP5 v5.149.1003.31008) */SELECT DISTINCT d.table_name, C.TABLESPACE_NAME ind_tbsp_name FROM user_indexes SELECT
create or replace procedure UpdatePhoto(v_id in integer,v_binaryPhoto in blob) isbegin update usersinfo u set u.photo=v_binaryPhoto where u.id=v_id;end UpdatePhoto;/ using System;using System.Collections.Generic;using System.ComponentModel;using
(length(trim(cbkssj)) is null這個語句應該只適用於oracle的奇怪情況,判斷length等於null?!除了這個以外奉送一條滿強的sql文法,裡面有很多的or和and,經過這次的經驗,我發現如果寫錯了or和and會增加語句的難度.已知:有兩個時間欄位,kssj和jssj,如果都為空白則算全年,其他即使大於kssj的,算以後的時間.小於jssj的算今年開始至結束時間的.最後的語句: where ((length(trim(cbkssj)) is null and
1、Where子句中的串連順序: ORACLE採用自下而上的順序解析WHERE子句。 根據這個原理,表之間的串連必須寫在其他WHERE條件之前, 那些可以過濾掉最大數量記錄的條件必須寫在WHERE子句的末尾。 舉例: (低效)select … from table1 t1 where t1.sal > 300 and t1.jobtype = '0001' and 20 < (select count(*) from table1 t2 where t2.