QUOTENAME() -- The function returns a string enclosed by a specific character
/*select quotename('abc', '{') quotename('abc')
The operation results are as follows
----------------------------------{
{abc} [abc]*/
REPLICATE() -- The function returns a string with the specified number of times
/*select replicate('abc', 3) replicate( 'abc', -2)
The operation results are as follows
----------- -----------
abcabcabc NULL*/
REVERSE() -- The function reverses the character arrangement order of the specified string
REPLACE() -- The function returns a string that has been replaced with the specified substring
/*select replace('abc123g', '123', 'def')
The operation results are as follows
----------- -----------
abcdefg*/
SPACE() -- The function returns a blank string of the specified length
STUFF() -- The function replaces the substring of the specified position length with another substring
---Data type conversion function ----
The CAST() function syntax is as follows
CAST() (<expression> AS <data_ type>[ length ])
The CONVERT() function syntax is as follows
CONVERT() (<data_ type>[ length ], <expression> [, style])
select cast(100+99 as char) convert(varchar(12), getdate())
The operation results are as follows
------------------------------ ------------
199 Jan 15 2000
---Date function ---
DAY() -- function returns the date value in date_expression
MONTH() -- function returns the month value in date_expression
YEAR() -- function returns the year value in date_expression
DATEADD(<datepart> ,<number> ,<date>)
--The function returns the new date generated by the specified date and the specified additional date interval number
DATEDIFF(<datepart> ,<number> ,<date>)
--The function returns the differences between two specified dates in datepart
DATENAME(<datepart> , <date>) --The function returns the specified part of the date as a string
DATEPART(<datepart> , <date>) --The function returns the specified part of the date as an integer value
GETDATE()--The function returns the current date and time of the system in the default format of DATETIME
---System functions ---
APP_NAME() -- The function returns the name of the currently executed application
COALESCE() -- The function returns the value of the first non-NULL expression among many expressions
COL_LENGTH(<'table_name'>, <'column_name'>) --function returns the length value of the specified field in the table
COL_NAME(<table_id>, <column_id>) --The function returns the name of the specified field in the table, i.e. the column name
DATALENGTH() -- The function returns the actual length of the data of the data expression
DB_ID(['database_name']) -- The function returns the database number
DB_NAME(database_id) -- The function returns the name of the database
HOST_ID() -- The function returns the name of the server computer
HOST_NAME() -- The function returns the name of the server computer
IDENTITY(<data_type>[, seed increment]) [AS column_name])
--IDENTITY() function is only used in the SELECT INTO statement to insert an identity column into the new table
/*select identity(int, 1, 1) as column_name
into newtable
from oldtable*/
ISDATE()--function determines whether the given expression is a reasonable date
ISNULL(<check_expression>, <replacement_value>) --The function replaces the NULL value in the expression with the specified value
ISNUMERIC() --- The function determines whether the given expression is a reasonable numerical value
NEWID() -- The function returns a value of type UNIQUEIDENTIFIER
NULLIF(<expression1>, <expression2>)
--NULLIF function returns NULL when expression1 and expression2 are equal. If the value is not equal, it returns the value of expression1.
--------------------------------------------------------------------------------
Reserved words in 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
Previous page123Read the full text