Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql Learning Notes (2)-MySQL data type

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

[text]

In the previous chapter, we learned about the installation of MySQL software. now that the software is installed, let's officially start learning the basics of MySQL, even if it is zero, one step at a time. Well, the first thing to learn is the data type of MySQL.

1. Data type:

1. Integer (xxxint)

2. Floating point type (float and double)

3. Fixed points (decimal)

4. String (char,varchar,xxxtext)

5. Binary data (xxxBlob)

6. Date and time type

2. Introduction of data types:

1. Integer:

Note: M represents the maximum display width. Among them, int is the most used.

2. Floating point (float and double):

Note: the parameter m only affects the display effect and does not affect the accuracy, but d is different, which will affect the accuracy.

3. Fixed points (decimal):

Decimal fixed-point type floating-point type stores approximate values in the database, while fixed-point types store exact values in the database. The parameter m is the maximum number of fixed-point type numbers (precision), the range is the number of digits to the right of the decimal point d, the range is 0: 30, but not more than m. The calculation of fixed points can be accurate to 65 digits.

4. String (char,varchar,xxxtext):

Note: if you want to save text, you can use text. Ah!

5. Binary data (xxxBlob):

XXXBLOB and xxxtext correspond to each other, but the storage method is different. XxxTEXT is stored as text. If you store English, it will be case-sensitive, while xxxBlob is stored in binary mode and is not case-sensitive. The data stored in xxxBlob can only be read as a whole. XxxTEXT can specify a character set, but xxxblob does not need to specify a character set.

For example, if we want to save a picture file, we can store the binary stream of the picture. Because it can only be read as a whole, it is expensive and slow to read, so it is used less in actual development.

6. Date and time type:

Timestamp (timestamp) is special. If you define a field of type timestamp, the time of this field will be automatically refreshed when other fields are modified. So the field of this data type can hold the time when the record was last modified, rather than the actual storage time.

The time in datatime can be expressed as a string. Note that in the database, the string is represented in single quotation marks.

3. Attributes of the data type:

When defining a data type, you can define some properties at the same time.

Among them, the meaning of the PRIMARY_KEY primary key: when defining a database, you can define the fields of a column as the primary key to uniquely represent the database, so that each row of records is unique. For example, if the student number is defined as the primary key, then each person has a unique id. It is generally not good to use meaningful content to define a primary key.

AUTO_INCREAMENT: increments automatically. You can use this property in the primary key.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report