? "declaration"
Welcome reprint, but please keep the original source of the article →_→
Life One number: http://www.cnblogs.com/smyhvae/
Article Source: http://www.cnblogs.com/smyhvae/p/4028040.html
Body
In the previous chapter, we learned the installation of MySQL software, since the software has been installed, now formally start the basic knowledge of MySQL learning bar, even if the 0 basis, but also to step by step. Well, the first thing to learn is the MySQL data type.
First, the data type:
- 1, integral type (xxxint)
- 2. Float type (float and double)
- 3. Fixed-point number (decimal)
- 4. String (Char,varchar,xxxtext)
- 5. Binary data (XXXBLOB)
- 6. Date and Time type
Second, the data type introduction:
1. Integral type:
Note: M represents the maximum display width. Of these, int uses the most.
2, floating-point type (float and double):
Note: The parameter M only affects the display effect, does not affect the precision, but the D is different, will affect the precision.
3. Fixed-point number (decimal):
Decimal (m,d) fixed-point type floating-point types hold approximate values in the database, while fixed-point types hold exact values in the database. The parameter m is the maximum number (precision) of a fixed-point type number with a range of 0~65,d digits to the right of the decimal point and a range of 0~30, but not more than M. The calculation of the fixed-point number can be accurate to 65 digits.
4. String (Char,varchar,xxxtext):
Note: If you want to save text, use text. Ah
5. Binary data (XXXBLOB):
Xxxblob and Xxxtext are corresponding, but stored in different ways, Xxxtext is stored in the text, if the storage of English words will be case-sensitive, and Xxxblob is stored in binary mode, not case-sensitive. The data stored by Xxxblob can only be read out in its entirety. Xxxtext can specify a character set, Xxxblob does not specify a character set.
For example, if we want to deposit a picture file, we can save the binary stream of the picture. Because it can only read the whole, the overhead is higher, the reading is slow, so it is used less in the actual development.
6. Date and Time type:
timestamp (timestamp) is very 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 last time the record was modified, not the actual time of storage.
The time in Datatime can be represented by a string. Note that in the database, the string is represented by single quotation marks .
Third, the properties of the data type:
When you define a data type, you can define some properties at the same time.
Where thePrimary_key primary key means: When you define a database, you can define a column's field as the primary key to uniquely represent the database, so that each row of records is unique. For example, if you define a primary key for a number, everyone has a unique ID. It is generally not good to define primary keys with meaningful content.
Auto_increament: Auto Increment. This property can be used in the primary key.
Category: Databases
Database Learning notes 2--mysql data types