Commonly used functions in SQL statements

1. Function

1. sysdate : The current date includes time

2. length (str) function: returns the length of the string, str represents a string

3. concat (str1, str2): str1, str2 are both strings, concatenate the strings str1 and str2 together

        ||: It is a string concatenation character

4. chr(ASCCII): It converts ASCCII code into characters

5. substr (str,index[,len]): string interception function, str is a string, the starting position of index interception, and the length of len interception

6. trim ([s from ]str): str represents a string, s represents a character, which means removing the spaces at both ends of the string. If s is added, it means removing the characters s at both ends of the string.

        ltrim( str[,'s'] ): Remove spaces or characters s on the left side of the string

        rtrim( str[,'s'] ): Remove spaces or characters s on the right side of the string

7. replace (str, s, d): Replace the function str string, the content to be replaced by s, and replace d with the content, which means replacing the s in str in the character with d.

8.lpad/rpad(str,len[,s]): str represents a string, len represents the length of the expanded string, s: represents the content to be expanded, optional parameters

9.initcap(str): str represents a string, capitalize the first letter of the English word in the string

10.lower/upper(str): Convert all strings to lowercase/uppercase

11.instr(str,s[,n1,n2]): Find the position of a certain character in the string, str string, s: the character to be queried, n1 means starting the search from the position, n2 means the number of this character occurrences

12. floor (n): rounding function, only the integer part is taken, no rounding is performed

13. mod (m,n): a function that finds the remainder of m divided by n

14. round (n,s): rounding function, n represents the number, s represents the precision, the default is 0

15.power(m,n): Find the nth power of m

16. to_number (str[,format]): Convert string to number, str string, format format string

17. to_date (str,format): Convert a string into a date in a fixed format, str is a date, format: date format

        yyyy: represents a 4-digit year

        MM: represents two months

        dd: represents the day of two digits

        hh24: indicates the hour in 24-hour format

        mi: represents minutes

        ss: represents seconds

        day: represents the day of the week

18. to_char (date,format): Convert date into string, date is a date, format: date format

19. add_months (date,n): Add and subtract n months to the date

20.months_between(date1,date2): Find the number of months between two dates

21.last_day(date): Get the last day of the current month

22.trunc(): truncation function

23. nvl (variable, default value): If the value of the variable is empty, the function returns the default value. If the value of the variable is not empty, the function returns the value of the variable.

2. Affairs

A transaction (TRANSACTION) is a series of operations performed as a single logical unit of work. These operations are submitted to the system as a whole, and either all or none of them are executed .

Transactions must have the following four attributes, referred to as ACID attributes:

Atomicity: A transaction is a complete operation. Each step of the transaction is indivisible (atomic); either all are executed or none are executed.

Consistency: When the transaction is completed, the data must be in a consistent state

Isolation: All concurrent transactions that modify data are isolated from each other, which indicates that transactions must be independent and should not depend on or affect other transactions in any way

Durability: After a transaction is completed, its modifications to the database are retained permanently, and the transaction log can maintain the permanence of the transaction.

table backup

create table table name as select statement;

Guess you like

Origin blog.csdn.net/weekendholiday/article/details/128103142