官方修正典藏版SQL 语句大全(三)

----日期函数----

DAY() --函数返回 date_expression 中的日期值

MONTH() --函数返回date_expression中的月份值

YEAR() --函数返回 date_expression 中的年份值

DATEADD(,,date>)

--函数返回指定日期 date 加上指定的额外日期间隔 number 产生的新日期

DATEDIFF(,,date>)

--函数返回两个指定日期在 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(<expression1>, <expression2>)

--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

s 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


https://www.bilibili.com/video/BV1qL411u7eE?p=2&spm_id_from=pageDriver


关注“BlankLB”,可以免废获取超多编程资料源码课件

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容