String
The string is similar to ‖i like Mysql.‖ and ' MySQL is powerful. ' Such values can be enclosed in double quotes or single quotes.
Not only can you use normal characters in a string, but you can also use several escape sequences, which are used to represent special characters, as shown in table 1-2. Each escape sequence begins with a backslash ("\"), indicating that the following character is interpreted using the escape character instead of the normal character. Note that the NUL byte differs from the null value, NUL is a 0-value byte, and null represents no value.
Table 1-2 string Transfer sequence table
Sequence implication
-an ASCII 0 (NUL) character
\ n a new line character
\ r A carriage return (using \ r \ n As the new row flag in Windows)
\ t a locator
\b A backspace
\ ' A single quotation mark ("'") character
\‖ a double quotation mark ("" ") character
\ \ A backslash ("\") character
\% a "%" character. It is used to search for "%" text instances in the body, otherwise "%" here will be interpreted as a wildcard character
\_ a "_" character. It is used to search the text instance of "_" in the body, otherwise "_" here will be interpreted as a wildcard character
It is important to note that there are several ways to use quotes in a string:
- If the string is enclosed in the same quotation marks, repeat the quote in the string where the quotation marks are required.
- If the string is enclosed in another quotation mark, you do not need to double-write the corresponding quotation mark and use it directly in the string, which is not treated in a special way.
- Use a backslash, expressed as a transfer sequence, which is not used to enclose the string in single or double quotation marks.
For example, the result of the following statement is:
mysql> Select ' Hello ', ' "Hello" ', ' "" Hello "" ', ' Hel ' lo ', ' \ ' Hello ';
numeric value
The number in MySQL is a value similar to 100 or 3.1215936. MySQL supports values that are described as integers (no fractional parts) or floating-point numbers (with fractional parts):
- Integers consist of a sequence of numbers. A floating-point number consists of an Arabic numeral sequence, a decimal point and another sequence of Arabic numerals. The sequence of two Arabic numerals can be empty, but cannot be empty at the same time.
- MySQL supports scientific notation. Scientific notation is represented by an integer or floating-point number followed by an "E" or "e", a symbol ("+" or "-", must have) and an integer exponent.
- A minus sign "-" can be placed before the value to indicate a negative value.
For example, the following are the valid values:
Integer value: 1221 0-32
Floating point: 294.42-32032.6809e+10 148.
Date and time values
Date and time values are some similar to "1999-06-17" or "12:30:43" values. MySQL also supports a combination of date/time, such as "1999-06-17 12:30:43".
It is important to note that MySQL represents the date in the order of the year-month-day. This may be different from the high-level language you've learned.
Now () & Sysdate ()
The difference between self-experience
Curdate () & Curtime ()
Data types for MySQL