現在在做的項目資料庫從sqlserver 更改到了oracle所以項目裡所有的sql語句全部要換成支援oralce的樣式。在過程中遇到了這個連表更新。弄了一下午才終於把它搞定了讓我們來看一下原來的句子:sqlserver : update table1 set 欄位1=table2.欄位1,欄位2=table2.欄位2,欄位3=table2.欄位3 from (select 欄位4,欄位1,欄位2,欄位3 from table2 wheretime between '" +time1+ "'
1. 定義變數declare n integer; //定義單個變數//定義多個變數DECLARE n integer;mm integer;2. 賦值n:=12;mm:=100; for 語句DECLAREn integer;mm integer;beginn:=12;mm:=100;for n in 10..1000 loopinsert into tab_test (Pk,TESTE) VALUES (cast(n as varchar(23)),cast(n as varchar(25)
來源資料庫伺服器上執行:以system使用者登入執行sqlC:\Documents and Settings\Administrator>sqlplus system/passwordSQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 28 17:16:47 2013Copyright (c) 1982, 2005, Oracle. All rights reserved.串連到:Oracle Database 10g
1. 設定VMware設定Hard Disk時一定要大於20G,否則建立資料庫時會由於空間不夠導致失敗,此處設定為40G2. 安裝Oracle Linux 6在安裝OS 時選擇如下包:Base System > BaseBase System > Client management toolsBase System > Compatibility librariesBase System > Hardware monitoring utilitiesBase
create or replace procedure p_tx_getfaxdata( )asv_ErrorCode NUMBER; -- 出錯的代碼v_ErrorMsg VARCHAR2(200); -- 錯誤的訊息顯示v_CurrentUser VARCHAR2(8); -- 當前資料庫使用者v_Information VARCHAR2(100); -- 關於錯誤的資訊begin //do the things you need to do.
[解決方案]1)通過尋找已被鎖定的資料庫表以及相關的sid,serial#,spid;select object_name,s.sid,s.serial#,p.spid from v$locked_object l,dba_objects o,v$session s,v$process p where l.object_id=o.object_id and l.session_id=s.sid and s.paddr=p.addr; 2)在資料庫中殺死Sessionalter system
oracle中使用on delete cascade和on delete set null來建立外鍵 其面我們介紹了建立外鍵約束時如果使用oracle預設的建立方式,在刪除被參照的資料時,將無法被刪除,這一點在oracle9i中給了我們更多靈活的選擇,我們可是使用on delete cascade和 on delete set null關鍵字來決定刪除被參照資料時是否要將參照這個資料的那些資料一併刪除,還是將那些參照這條資料的資料的對應值賦空。
SQL分頁預存程序///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////CREATE PROCEDURE [dbo].[sp_PageIndex]( -- Add the parameters for the stored procedure here @tblName varchar(50), -
今天寫oracle語句時發現一個奇怪的問題,糾結了很久沒有找到原因。求大牛解惑。問題精簡如下:select seq,info ,topic from system.help where seq in (select distinct seq from system.help where seq=20); -----(1)與 select seq,info ,topic from system.help where seq
在一般的情況下,使用批量fetch的幾率並不是很多,但是Oracle提供了這個功能我們最好能熟悉一下,說不定什麼時候會用上它。 以下是程式碼片段: declare cursor c1 is select * from t_depart; v_depart t_depart%rowtype ; type v_code_type is table of t_depart.depart_code%type ; v_code v_code_type ; type