当前位置:网站首页>MySQL built-in functions

MySQL built-in functions

2022-06-13 05:15:00 strive_ one

mysql Built in functions in

  • String function
  • Mathematical functions
  • Date time function
  • Type conversion function
  • Process control
     Insert picture description here

String function

  • Look at the ascii Code value ascii(str), str Return when empty string 0
     Insert picture description here
  • see ascii The character corresponding to the code value char( Numbers )
     Insert picture description here
  • String concatenation concat(str1,str2…)
     Insert picture description here
  • Contains the number of characters length(str)
     Insert picture description here
  • Intercepting string
    • left(str, len) Return string str Left side len Characters
       Insert picture description here
    • right(str,len) Return string str Right side len Characters
       Insert picture description here
    • substring(str,pos,len) Return string str The location of pos rise len Characters
       Insert picture description here
  • Remove the space
    • ltrim(str) Returns the string with the left space removed str
       Insert picture description here
    • rtrim(str) Returns the string with the right space removed str
       Insert picture description here
  • trim([ Direction remstr from str) Return to delete... From one side remstr String after str, Direction words include both、leading、trailing, On both sides 、 Left 、 Right
     Insert picture description here
  • Return from n A string of space characters space(n)
     Insert picture description here
  • Replace string replace(str,from_str,to_str)
     Insert picture description here
  • toggle case ,lower(str)、upper(str)
     Insert picture description here  Insert picture description here

Mathematical functions

  • Find the absolute value abs(n)
     Insert picture description here
  • seek m Divide n The remainder of mod(m,n), Same as operator %
     Insert picture description here
     Insert picture description here
  • The floor ( Rounding down )floor(n), No greater than n Maximum integer for
     Insert picture description here
     Insert picture description here
  • The ceiling ( Rounding up )ceiling(n), Not less than n Maximum integer for
     Insert picture description here
     Insert picture description here
  • To find a rounding value round(n,d),n Means the original number ,d For decimal places , The default is 0
     Insert picture description here
     Insert picture description here
  • seek x Of y The next power pow(x,y)
     Insert picture description here
  • Get the pi PI()
     Insert picture description here
  • random number rand(), The value is 0-1.0 Floating point number
     Insert picture description here
  • There are also many trigonometric functions , You can query documents when using

Date time function

  • Get child value , Value is positive type , Function as follows :
    • year(date) return date A year of ( The scope is 1000 To 9999)
    • month(date) return date Month value in
    • day(date) return date Date value in
    • hour(time) return time The number of hours ( The scope is 0 To 23)
    • minute(time) return time Minutes of ( The scope is 0 To 59)
    • second(time) return time The number of seconds ( The scope is 0 To 59)
       Insert picture description here
  • Date calculation , Use ± Operator , The keyword after the number is year、month、day、hour、minute、second
     Insert picture description here
  • Date formatting date_format(date,format)
    • Parameters format Optional value :
      • %Y Year of acquisition , Return the full year
      • %y Year of acquisition , Returns the abbreviated year
      • %m Get the month , Return to the month
      • %d Acquisition date , Return day value
      • %H When getting , return 24 The number of hours in decimal
      • %h When getting , return 12 The number of hours in decimal
      • %i Get points , Return to minutes
      • %s Get seconds , Return seconds
         Insert picture description here
  • The current date current_date()
     Insert picture description here
  • current time current_time()
     Insert picture description here
  • Current date time now()
     Insert picture description here
Small application

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

md5 encryption

  • Be careful : No matter what the length of the characters we want to encrypt , The length after encryption is 32 Bit fixed .md5 Encryption is irreversible ( According to the ciphertext, the plaintext cannot be decrypted )
     Insert picture description here
     Insert picture description here
     Insert picture description here
     Insert picture description here
     Insert picture description here
     Insert picture description here
     Insert picture description here

sha1 encryption

  • sha1 The encrypted length is 40 Bit
     Insert picture description here
     Insert picture description here
     Insert picture description here
     Insert picture description here
     Insert picture description here

password() password

 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[strive_ one]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280514548624.html