http://blog.blueshop.com.tw/pili9141/articles/52397.aspx
1 CEIL(n)
2 --獲得 > n 或 = n 的最小整數
3
4 ex.
5 select ceil(3.01) from dual;
6
7 cil(3.01)
8 ----------
9 4
10
11 select ceil(-3.01) from dual;
12
13 ceil(-3.01)
14 ----------
15 -3
16
17 FLOOR(n)
18 --獲得 < id =" ‘10010001′" id =" ‘10010001′" x =" 1" y =" 2" z="3"> @y
print ‘x > y’ –打印字符串’x > y’
else if @y > @z
print ‘y > z’
else print ‘z > y’
–CASE
use pangu
update employee
set e_wage =
case
when job_level = ‘1′ then e_wage*1.08
when job_level = ‘2′ then e_wage*1.07
when job_level = ‘3′ then e_wage*1.06
else e_wage*1.05
end
–WHILE CONTINUE BREAK
declare @x int @y int @c int
select @x = 1 @y=1
while @x < c =" [email=" y =" @y" x =" @x" y =" 1" stockid =" str(nid)" stockname =" ’str_name’" stockpath =" ’stock_path’" stockindex =" 24" stocksex =" ‘man’" stockname =" (select" stockid =" 4)" id ="*" stockname =" “xxx”" stockid =" 3]" stockname =" default" stockname =" null" stocknumber =" Stockname" stockid =" 3" e_wage =" (select">=表達式的最小整數返回的數據類型與表達式相同可為
–INTEGER/MONEY/REAL/FLOAT類型
FLOOR(numeric_expression) –返回<=表達式的最小整數返回的數據類型與表達式相同可為 –INTEGER/MONEY/REAL/FLOAT類型 ROUND(numeric_expression) –返回以integer_expression為精度的四捨五入值返回的數據 –類型與表達式相同可為INTEGER/MONEY/REAL/FLOAT類型 ABS(numeric_expression) –返回表達式的絕對值返回的數據類型與表達式相同可為 –INTEGER/MONEY/REAL/FLOAT類型 SIGN(numeric_expression) –測試參數的正負號返回0零值1正數或-1負數返回的數據類型 –與表達式相同可為INTEGER/MONEY/REAL/FLOAT類型 PI() –返回值為π即3.1415926535897936 RAND([integer_expression]) –用任選的[integer_expression]做種子值得出0-1間的隨機浮點數 —-字符串函數—- ASCII() –函數返回字符表達式最左端字符的ASCII碼值 CHAR() –函數用於將ASCII碼轉換為字符 –如果沒有輸入0 ~ 255之間的ASCII碼值CHAR函數會返回一個NULL值 LOWER() –函數把字符串全部轉換為小寫 UPPER() –函數把字符串全部轉換為大寫 STR() –函數把數值型數據轉換為字符型數據 LTRIM() –函數把字符串頭部的空格去掉 RTRIM() –函數把字符串尾部的空格去掉 LEFT(),RIGHT(),SUBSTRING() –函數返回部分字符串 CHARINDEX(),PATINDEX() –函數返回字符串中某個指定的子串出現的開始位置 SOUNDEX() –函數返回一個四位字符碼 –SOUNDEX函數可用來查找聲音相似的字符串但SOUNDEX函數對數字和漢字均只返回0值 DIFFERENCE() –函數返回由SOUNDEX函數返回的兩個字符表達式的值的差異 TOP Google 發短消息 加為好友 Google 當前離線 UID8 帖子30 精華0 積分15 貢獻15 金幣28 閱讀權限10 在線時間2 小時 註冊時間2009-8-21 最後登錄2010-11-6 工程師 UID8 帖子30 精華0 積分15 貢獻15 金幣28 閱讀權限10 在線時間2 小時 註冊時間2009-8-21 最後登錄2010-11-6 3# 發表於 2009-8-22 17:04 | 只看該作者 –0兩個SOUNDEX函數返回值的第一個字符不同 –1兩個SOUNDEX函數返回值的第一個字符相同 –2兩個SOUNDEX函數返回值的第一二個字符相同 –3兩個SOUNDEX函數返回值的第一二三個字符相同 –4兩個SOUNDEX函數返回值完全相同 QUOTENAME() –函數返回被特定字符括起來的字符串 /*select quotename(’abc’, ‘{’) quotename(’abc’) 運行結果如下 ———————————-{ {abc} [abc]*/ REPLICATE() –函數返回一個重複character_expression指定次數的字符串 /*select replicate(’abc’, 3) replicate( ‘abc’, -2) 運行結果如下 ———– ———– abcabcabc NULL*/ REVERSE() –函數將指定的字符串的字符排列順序顛倒 REPLACE() –函數返回被替換了指定子串的字符串 /*select replace(’abc123g’, ‘123′, ‘def’) 運行結果如下 ———– ———– abcdefg*/ SPACE() –函數返回一個有指定長度的空白字符串 STUFF() –函數用另一子串替換字符串指定位置長度的子串 —-數據類型轉換函數—- CAST()函數語法如下 CAST() (AS [ length ])
CONVERT()函數語法如下
CONVERT() ([ length ], [, style])
select cast(100+99 as char) convert(varchar(12), getdate())
運行結果如下
—————————— ————
199 Jan 15 2000
—-日期函數—-
DAY() –函數返回date_expression中的日期值
MONTH() –函數返回date_expression中的月份值
YEAR() –函數返回date_expression中的年份值
DATEADD(, , )
–函數返回指定日期date加上指定的額外日期間隔number產生的新日期
DATEDIFF(, , )
–函數返回兩個指定日期在datepart方面的不同之處
DATENAME(, ) –函數以字符串的形式返回日期的指定部分
DATEPART(, ) –函數以整數值的形式返回日期的指定部分
GETDATE() –函數以DATETIME的缺省格式返回系統當前的日期和時間
—-系統函數—-
APP_NAME() –函數返回當前執行的應用程序的名稱
COALESCE() –函數返回眾多表達式中第一個非NULL表達式的值
COL_LENGTH(<’table_name’>, <’column_name’>) –函數返回表中指定字段的長度值
COL_NAME(, ) –函數返回表中指定字段的名稱即列名
DATALENGTH() –函數返回數據表達式的數據的實際長度
DB_ID(['database_name']) –函數返回數據庫的編號
DB_NAME(database_id) –函數返回數據庫的名稱
HOST_ID() –函數返回服務器端計算機的名稱
HOST_NAME() –函數返回服務器端計算機的名稱
IDENTITY([, seed increment]) [AS column_name])
–IDENTITY()函數只在SELECT INTO語句中使用用於插入一個identity column列到新表中
/*select identity(int, 1, 1) as column_name
into newtable
from oldtable*/
ISDATE() –函數判斷所給定的表達式是否為合理日期
ISNULL(, ) –函數將表達式中的NULL值用指定值替換
ISNUMERIC() –函數判斷所給定的表達式是否為合理的數值
NEWID() –函數返回一個UNIQUEIDENTIFIER類型的數值
NULLIF(, )
–NULLIF函數在expression1與expression2相等時返回NULL值若不相等時則返回expression1的值
————————————————– ——————————
sql中的保留字
action add aggregate all
alter after and as
asc avg avg_row_length auto_increment
between bigint bit binary
blob bool both by
cascade case char character
change check checksum column
columns comment constraint create
cross current_date current_time current_timestamp
data database databases date
datetime day day_hour day_minute
day_second dayofmonth dayofweek dayofyear
dec decimal default delayed
delay_key_write delete desc describe
distinct distinctrow double drop
end else escape escaped
enclosed enum explain exists
fields file first float
float4 float8 flush foreign
from for full function
global grant grants group
having heap high_priority hour
hour_minute hour_second hosts identified
ignore in index infile
inner insert insert_id int
integer interval int1 int2
int3 int4 int8 into
if is isam join
key keys kill last_insert_id
leading left length like
lines limit load local
lock logs long longblob
longtext low_priority max max_rows
match mediumblob mediumtext mediumint
middleint min_rows minute minute_second
modify month monthname myisam
natural numeric no not
null on optimize option
optionally or order outer
outfile pack_keys partial password
precision primary procedure process
processlist privileges read real
references reload regexp rename
replace restrict returns revoke
rlike row rows second
select set show shutdown
smallint soname sql_big_tables sql_big_selects
sql_low_priority_updates sql_log_off sql_log_update sql_select_limit
sql_small_result sql_big_result sql_warnings straight_join
starting status string table
tables temporary terminated text
then time timestamp tinyblob
tinytext tinyint trailing to
type use using unique
unlock unsigned update usage
values varchar variables varying
varbinary with write when
where year year_month zerofill