這些是 sql-92 設定語句,使 sql server 2000/2005 遵從 sql-92 規則。
1. set ansi_nulls on
transact-sql 支援在與空值進行比較時,允許比較運算子返回 true 或 false。
通過設定 ansi_nulls off 可將此選項啟用。
當 ansi_nulls 為 off 時,
如果 columna 包含 null 值,則 columna = null 之類的比較操作會返回 true;
如果 columna 除了包含 null 外還包含某些值,則這模擬較操作將返回 false。
比較計算結果為 null 的兩個表示式也會返回 true。
ansi_nulls 設定不影響包含 null 的聯接列。聯接列中包含 null 的行不是結果集的一部分。
當 ansi_nulls 設定為 off 時,以下 select 語句返回 customer 表中 region 為 null 值的所有行:
select customerid, accountnumber, territoryid
from adventureworks.sales.customer
where territoryid = null
如果 set ansi_nulls on
那麼 sql 語句中, 判斷 非空的寫法, 要修改為:
where 字段 is null
因為 set ansi_nulls on 以後,
null = null 將 返回 false.
2. set quoted_identifier on
當 set quoted_identifier 為 on 時,識別符號可以由雙引號分隔,而文字必須由單引號分隔。當 set quoted_identifier 為 off 時,識別符號不可加引號,且必須符合所有 transact-sql 識別符號規則。
3. set ansi_padding on
在未來的 sql server 版本中,ansi_padding 將始終為 on,且將此選項顯式設定為 off 的任何應用程式都將產生錯誤。 請避免在新的開發工作中使用此功能,並著手修改當前使用此功能的應用程式。
下表顯示在將值插入含有char、varchar、binary和varbinary資料型別的列時,set ansi_padding 設定的效果。
char(n) not null 或 binary(n) not null
char(n) null 或 binary(n) null
varchar(n) 或 varbinary(n)
on填充原始值(char列具有尾隨空格的值,binary列具有尾隨零的值),使達到列的長度。
如果 set ansi_padding 為 on,則遵從與char(n)或binary(n)not null 相同的規則。
不剪裁插入varchar列中的字元值的尾隨空格。 不剪裁插入varbinary列中的二進位制值的尾隨零。 不將值填充到列的長度。
off填充原始值(char列具有尾隨空格的值,binary列具有尾隨零的值),使達到列的長度。
如果 set ansi_padding 為 off,則遵從與varchar或varbinary相同的規則。
剪裁插入varchar列中的字元值的尾隨空格。 剪裁插入varbinary列中的二進位制值的尾隨零。
進行填充時,char列用空格填充,binary列用零填充。 進行剪裁時,char列的尾隨空格被剪裁,binary列的尾隨零被剪裁。
儲存過程中is的含義
例子 create or replace procedure proc1 para1 varchar2,para2 out varchar2,para3 in out varchar2 as v name varchar2 20 變數宣告塊 緊跟著的as is 關鍵字,可以理解為pl sql的dec...
oracle儲存過程中 type的含義
例子 create or replace procedure getdeptbyid v deptno in dept.deptno type is v dname dept.dname type v loc dept.loc type begin select dname,loc into v d...
儲存過程中,if語句使用
if語句 判斷使用者輸入的數字 set serveroutput on 1.提示資訊 2.接收鍵盤輸入 num 是乙個位址值 sql優化 num繫結變數 盡量使用繫結變數 select from emp where deptno 10 執行計畫 select from emp where deptn...