Foundations MySQL data types and operators

Foundations of the early years of learning MySQL data types and operators notes, for subsequent review study:

1. Data type int (11), behind the figures note 11, which represents the width of the data is a specified type, the predetermined number of digital values ​​can be displayed. Other types of data may be required to specify the display width is defined when the table structure, if not specified, the system defaults for each type of specified width.

2. MySQL using a decimal floating-point and fixed-point representation. Single precision floating point, there are two types: single-precision floating-point (float) and double precision floating point type (double). Only one fixed-point type: decimal. Floating-point and fixed-point type can be used type (M, N) is represented, where M is called progress, represents the total number of bits; N called scale, represents the number of decimal places.

3. Whether fixed or floating-point type, if the schedule specified by the user is beyond the scope of progress, this time rounding processing.

4. A float with respect to the fixed-point bit length under certain circumstances, floating-point data can be represented by a larger range, it will cause the disadvantage that the progress of the problem.

5. MySQL fixed-point number is stored as a string in the progress when relatively high (such as currency and scientific terms) used decimal type is better, two floating-point addition and subtraction are also prone comparison operation problem, so when using the float should be noted, do avoid doing floating-point comparison.

YEAR 6. Save as type, both incoming integer, can also pass character. If the type is inserted over the range YEAR, the value will be converted to 2000.

7. Save as type TIME, if not legal, when the memory becomes 00:00:00.

8. The use of a string or numeric data into a data type DATE, DATE long date format to meet.

9. MySQL allow "stringent" syntax: Any punctuation marks may be used as the interval between the date portion. For example, "98-10-19", "98.10.18", "98/10/19" and "98 @ 10 @ 19 @" are equivalent, these words are correctly inserted into the database.

10. Insert DATETIME data types, string types and numbers may be used type of data insertion, as long as the date format to meet DATETIME. For example: "YYYY-MM-DD HH: MM: SS", "YYYYMMDDHHMMSS", or digital YYYYMMDDHHMMSS, YYMMDDHHMMSS can be expressed.

11. MySQL allow "stringent" Syntax: Any punctuation marks can be used as part of an interval between the date or time portion, for example: "98-10-19 12:12:12", "12 + 12 + 98.10.19 12 "," 98 @ 10 @ 12 * 9 12 * 12 "," 98 # 10 # 19 12:12:12 "are equivalent and are allowed.

12 is used to store character string data type string, the string may be stored in addition to data, you may also store other data, such as images, sound binary data.

13. MySQL So far two types of character data: text strings and binary strings.

14. VARCHAR, TEXT, BLOB types are variable length, depending on the storage needs for the actual length of the column worth, rather than on the maximum possible length type. For example, a VARCHAR (10) can hold a maximum length of a string of 10 characters, the actual storage needs actual length L plus a string of bytes (for the record length of the string). For character string "abcd", L 4, and 5 bytes of storage needs.

15. CHAR (M) is the fixed length character string, when defining the length of the string. When stored in the right side of the space is filled to a specified length. M represents a column length, M ranges from 0 to 255 characters. When CHAR values ​​are retrieved, trailing spaces will be removed.

16. VARCHAR (M) is a variable length string, M is the maximum length of the column. M range is 0 ~ 65535.VARCHAR human trailing spaces reserved only during storage and retrieval.

17. equal to (=) for determining not null, but the security equal to (<=>) can.

18. LIKE with matching characters:

  "%" Character matches any number, even zero characters

  "_" Can only match one character.

19. If you want to delete all records in the table, in addition to ways to use DELETE FROM table name watches, you can also use TRUNCATETABLE statement, TRUNCATE to delete the original table, and re-create a new table. TRUNCATE say directly delete the table instead of deleting records, and therefore perform faster than DELETE.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/160163.htm