国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > Oracle > 正文

Oracle PL/SQL學(xué)習(xí)筆記(1)

2024-08-29 13:45:51
字體:
供稿:網(wǎng)友
1 SQL*Plus環(huán)境
--------------------------------------
show all 顯示所有SQL*Plus的命令名字
list or l 顯示緩沖區(qū)的內(nèi)容
list 4 顯示當(dāng)前SQL命令的第4行,并把第4行作為當(dāng)前行。
change or c 用新的內(nèi)容替換原來在一行中第一次出現(xiàn)內(nèi)容,例如:SQL>c/(...)/('analyst')/
input or i 增加一行或多行
append or a 在一行后追加內(nèi)容
del 刪除當(dāng)前行 刪除SQL緩沖區(qū)中的當(dāng)前行
run 顯示并運(yùn)行SQL緩沖區(qū)中的命令
/ 運(yùn)行SQL緩沖區(qū)中的命令
edit 把SQL緩沖區(qū)中的命令寫到操作系統(tǒng)下的文本文件,
并調(diào)用操作系統(tǒng)提供的編輯器執(zhí)行修改。
set linesize 80 設(shè)置行的大小為80個(gè)字符寬度
set pagesize 100 設(shè)置頁(yè)的大小為100行
ttitle 'smaple ttitle' 設(shè)置頁(yè)頭標(biāo)
BTitle 'smaple btitle' 設(shè)置頁(yè)腳標(biāo)
spool /home/zxin10/myresult.log 設(shè)置sqlplus的輸出到文件中
spool off(out) 停止輸出文件
column column_name format a18 wrap heading ’smaple-column-title’
格式化列輸出,每列寬度18個(gè)字符,超過18個(gè)自動(dòng)換行,列標(biāo)題換成'column-title'
CLEAR COLUMNS 將所有列的顯示屬性設(shè)為缺省值.
2 異常exception
--------------------------------------
no_data_found
表示select沒有查詢到滿足條件的數(shù)據(jù)行。
others
表示Oracle預(yù)定義錯(cuò)誤范圍之外的任何錯(cuò)誤,Oracle用這個(gè)"others"捕捉所有 未知的錯(cuò)誤。可以使用sqlcode函數(shù),sqlerrm函數(shù)在錯(cuò)誤處理模塊中顯示錯(cuò)誤 代碼和錯(cuò)誤信息。而且,others處理必須是一個(gè)塊的最后一個(gè)錯(cuò)誤處理,否則, others處理的優(yōu)先級(jí)比較高,權(quán)利比較大,它會(huì)捕捉所有錯(cuò)誤,包括預(yù)定義的Oracle 錯(cuò)誤和非預(yù)定義的Oracle錯(cuò)誤。
too_many_rows
Oracle的隱式游標(biāo),一次只能檢索一行數(shù)據(jù),使用隱式游標(biāo)時(shí),異常處理機(jī)制假如檢測(cè) 到游標(biāo)返回的數(shù)據(jù)是多行數(shù)據(jù),它就拋出too_many_rows類型的異常。
dup_val_on_index
在某個(gè)索引上,出現(xiàn)重復(fù)值。
value_error
在某個(gè)目標(biāo)字段中,放入的數(shù)據(jù)長(zhǎng)度或者數(shù)據(jù)范圍,超出目標(biāo)字段定義的長(zhǎng)度或者范圍 ,如,把'8613905180088'這個(gè)字符串插入userid字段中,而userid定義為varchar2(10), 就會(huì)出現(xiàn)這種異常。 Exception Raised when ...
access_INTO_NULL
Your PRogram attempts to assign values to the attributes of an uninitialized
(atomically null) object. CASE_NOT_FOUND
None of the choices in the WHEN clauses of a CASE statement is selected, and
there is no ELSE clause. COLLECTION_IS_NULL
Your program attempts to apply collection methods other than EXISTS to an
uninitialized (atomically null) nested table or varray, or the program attempts
to assign values to the elements of an uninitialized nested table or varray. CURSOR_ALREADY_OPEN
Your program attempts to open an already open cursor. A cursor must be closed
before it can be reopened. A cursor FOR loop automatically opens the cursor to
which it refers. So, your program cannot open that cursor inside the loop. DUP_VAL_ON_INDEX
Your program attempts to store duplicate values in a database column that is
constrained by a unique index. INVALID_CURSOR
Your program attempts an illegal cursor Operation sUCh as closing an unopened cursor. INVALID_NUMBER
In a SQL statement, the conversion of a character string into a number fails

because the string does not represent a valid number. (In procedural statements,
VALUE_ERROR is raised.) This exception is also raised when the LIMIT-clause
eXPression in a bulk FETCH statement does not evaluate to a positive number. LOGIN_DENIED
Your program attempts to log on to Oracle with an invalid username and/or passWord. NO_DATA_FOUND
A SELECT INTO statement returns no rows, or your program references a deleted element
in a nested table or an uninitialized element in an index-by table. SQL aggregate
functions such as AVG and SUM always return a value or a null. So, a SELECT INTO
statement that calls an aggregate function never raises NO_DATA_FOUND. The FETCH
statement is expected to return no rows eventually, so when that happens, no
exception is raised. NOT_LOGGED_ON
Your program issues a database call without being connected to Oracle. PROGRAM_ERROR
PL/SQL has an internal problem. ROWTYPE_MISMATCH
The host cursor variable and PL/SQL cursor variable involved in an assignment have
incompatible return types. For example, when an open host cursor variable is passed
to a stored subprogram, the return types of the actual and formal parameters must
be compatible. SELF_IS_NULL
Your program attempts to call a MEMBER method on a null instance. That is, the
built-in parameter SELF (which is always the first parameter passed to a MEMBER
method) is null. STORAGE_ERROR
PL/SQL runs out of memory or memory has been corrupted. SUBs cript_BEYOND_COUNT
Your program references a nested table or varray element using an index number
larger than the number of elements in the collection. SUBs cript_OUTSIDE_LIMIT
Your program references a nested table or varray element using an index number
(-1 for example) that is outside the legal range. SYS_INVALID_ROWID
The conversion of a character string into a universal rowid fails because the
character string does not represent a valid rowid. TIMEOUT_ON_RESOURCE
A time-out occurs while Oracle is waiting for a resource. TOO_MANY_ROWS
A SELECT INTO statement returns more than one row. VALUE_ERROR
An arithmetic, conversion, truncation, or size-constraint error occurs. For example,
when your program selects a column value into a character variable, if the value is
longer than the declared length of the variable, PL/SQL aborts the assignment and raises
VALUE_ERROR. In procedural statements, VALUE_ERROR is raised if the conversion of a
character string into a number fails. (In SQL statements, INVALID_NUMBER is raised.) ZERO_DIVIDE
Your program attempts to divide a number by zero.

3 連接查詢
----------------------------------------
假設(shè)兩個(gè)表s1cardinf,s1prefer
s1cardinf內(nèi)容:
allindex
1
2
3 s1prefer內(nèi)容:
allindex
2
3
4 select a.allindex,b.allindex
from s1cardinf a , s1prefer b
where a.allindex = b.allindex ;
結(jié)果:
allindex,allindex
2 2
3 3 select a.allindex,b.allindex
from s1cardinf a , s1prefer b
where a.allindex (+) = b.allindex ;
結(jié)果:
allindex,allindex
2 2
3 3
null 4 select a.allindex,b.allindex
from s1cardinf a , s1prefer b
where a.allindex = b.allindex (+) ;
結(jié)果:
allindex,allindex
1 null
2 2
3 3


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 宽甸| 武强县| 怀来县| 建阳市| 海宁市| 洪江市| 波密县| 沈阳市| 昌图县| 聊城市| 仁布县| 丰镇市| 三江| 同德县| 八宿县| 平南县| 乌兰察布市| 罗平县| 潜江市| 连南| 丹阳市| 聂拉木县| 忻州市| 泸溪县| 泸定县| 江华| 邢台市| 微山县| 崇信县| 临漳县| 陈巴尔虎旗| 从化市| 枝江市| 嘉兴市| 临汾市| 广德县| 阜新市| 辽中县| 寿阳县| 曲沃县| 印江|