SQL命令大全-中英文對照
更新時間:2007年11月22日 22:36:10 作者:
QUOTENAME() --函數(shù)返回被特定字符括起來的字符串
/*select quotename('abc', '{') quotename('abc')
運行結(jié)果如下
----------------------------------{
{abc} [abc]*/
REPLICATE() --函數(shù)返回一個重復(fù)character_expression 指定次數(shù)的字符串
/*select replicate('abc', 3) replicate( 'abc', -2)
運行結(jié)果如下
----------- -----------
abcabcabc NULL*/
REVERSE() --函數(shù)將指定的字符串的字符排列順序顛倒
REPLACE() --函數(shù)返回被替換了指定子串的字符串
/*select replace('abc123g', '123', 'def')
運行結(jié)果如下
----------- -----------
abcdefg*/
SPACE() --函數(shù)返回一個有指定長度的空白字符串
STUFF() --函數(shù)用另一子串替換字符串指定位置長度的子串
----數(shù)據(jù)類型轉(zhuǎn)換函數(shù)----
CAST() 函數(shù)語法如下
CAST() (<expression> AS <data_ type>[ length ])
CONVERT() 函數(shù)語法如下
CONVERT() (<data_ type>[ length ], <expression> [, style])
select cast(100+99 as char) convert(varchar(12), getdate())
運行結(jié)果如下
------------------------------ ------------
199 Jan 15 2000
----日期函數(shù)----
DAY() --函數(shù)返回date_expression 中的日期值
MONTH() --函數(shù)返回date_expression 中的月份值
YEAR() --函數(shù)返回date_expression 中的年份值
DATEADD(<datepart> ,<number> ,<date>)
--函數(shù)返回指定日期date 加上指定的額外日期間隔number 產(chǎn)生的新日期
DATEDIFF(<datepart> ,<number> ,<date>)
--函數(shù)返回兩個指定日期在datepart 方面的不同之處
DATENAME(<datepart> , <date>) --函數(shù)以字符串的形式返回日期的指定部分
DATEPART(<datepart> , <date>) --函數(shù)以整數(shù)值的形式返回日期的指定部分
GETDATE() --函數(shù)以DATETIME 的缺省格式返回系統(tǒng)當(dāng)前的日期和時間
----系統(tǒng)函數(shù)----
APP_NAME() --函數(shù)返回當(dāng)前執(zhí)行的應(yīng)用程序的名稱
COALESCE() --函數(shù)返回眾多表達(dá)式中第一個非NULL 表達(dá)式的值
COL_LENGTH(<'table_name'>, <'column_name'>) --函數(shù)返回表中指定字段的長度值
COL_NAME(<table_id>, <column_id>) --函數(shù)返回表中指定字段的名稱即列名
DATALENGTH() --函數(shù)返回數(shù)據(jù)表達(dá)式的數(shù)據(jù)的實際長度
DB_ID(['database_name']) --函數(shù)返回數(shù)據(jù)庫的編號
DB_NAME(database_id) --函數(shù)返回數(shù)據(jù)庫的名稱
HOST_ID() --函數(shù)返回服務(wù)器端計算機(jī)的名稱
HOST_NAME() --函數(shù)返回服務(wù)器端計算機(jī)的名稱
IDENTITY(<data_type>[, seed increment]) [AS column_name])
--IDENTITY() 函數(shù)只在SELECT INTO 語句中使用用于插入一個identity column列到新表中
/*select identity(int, 1, 1) as column_name
into newtable
from oldtable*/
ISDATE() --函數(shù)判斷所給定的表達(dá)式是否為合理日期
ISNULL(<check_expression>, <replacement_value>) --函數(shù)將表達(dá)式中的NULL 值用指定值替換
ISNUMERIC() --函數(shù)判斷所給定的表達(dá)式是否為合理的數(shù)值
NEWID() --函數(shù)返回一個UNIQUEIDENTIFIER 類型的數(shù)值
NULLIF(<expression1>, <expression2>)
--NULLIF 函數(shù)在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
您可能感興趣的文章:
相關(guān)文章
SQL Server的鏈接服務(wù)器技術(shù)小結(jié)
這篇文章主要介紹了SQL Server的鏈接服務(wù)器技術(shù)的相關(guān)資料,需要的朋友可以參考下2014-07-07SQL Server 排序函數(shù) ROW_NUMBER和RANK 用法總結(jié)
下面的例子和SQL語句均在SQL Server 2008環(huán)境下運行通過,使用SQL Server自帶的AdventureWorks數(shù)據(jù)庫。2009-07-07行轉(zhuǎn)列之SQL SERVER PIVOT與用法詳解
這篇文章主要給大家介紹了關(guān)于行轉(zhuǎn)列之SQL SERVER PIVOT與用法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用SQL SERVER具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09SQL Server內(nèi)存遭遇操作系統(tǒng)進(jìn)程壓榨案例分析
最近一臺DB服務(wù)器偶爾出現(xiàn)CPU報警,我的郵件報警閾值設(shè)置的是15%,開始時沒當(dāng)回事,以為是有什么統(tǒng)計類的查詢,后來越來越頻繁2014-03-03Sql Server 壓縮數(shù)據(jù)庫日志文件的方法
Sql Server 日志 _log.ldf文件太大,數(shù)據(jù)庫文件有500g,日志文件也達(dá)到了500g,占用磁盤空間過大,且可能影響程序性能,需要壓縮日志文件,下面小編給大家講解下Sql Server 壓縮數(shù)據(jù)庫日志文件的方法,感興趣的朋友一起看看吧2022-11-11教你幾種在SQLServer中刪除重復(fù)數(shù)據(jù)方法
數(shù)據(jù)庫的使用過程中由于程序方面的問題有時候會碰到重復(fù)數(shù)據(jù),重復(fù)數(shù)據(jù)導(dǎo)致了數(shù)據(jù)庫部分設(shè)置不能正確設(shè)置……2010-04-04