Learn Mysql:mysql with Miss Wang. Data Types FAQs and Answers
Teacher: Wang Shaohua QQ Group No.: 483773664 Learning Content
Similarities and differences between integer types and floating-point types
Similarities and differences between floating-point type and fixed-point number types
The similarities and differences between char and varchar types
Similarities and differences in time and date types
The similarities and differences between text and blobs
Considerations for storing path strings
How MySQL stores the Boolean type
Processing of NULL
When creating a table in MySQL, it is most appropriate to consider which data type to choose for the field. Selecting the appropriate data type will improve the efficiency of the database.
One, integer type and floating-point type
The maximum difference between an integer type and a floating-point type is that integer types cannot express decimals, whereas floating-point types can represent decimals;
If the integer type of the field, the expression value is between 0-255, then select tinyint. The most commonly used integer type is the maximum range of int,bigint types;
Floating-point types include two types of float and double, and if you want to represent more than 10 digits after the decimal point, you should select Double.
Ii. types of floating-point numbers and fixed-point numbers
In the case of unspecified precision, the float and double types save the actual precision by default, and the decimal default integer bit is 10, and the decimal digit is 0
In Mysqlk if you want the accuracy of the data to be relatively high, you should select the fixed-point number
Three, char and varchar types
Char length fixed, varchar type length is variable within range
For string types that vary in length, it is best to choose the varchar type
Char trouble prevails over space, but processing speed is faster than varchar, so for string types that have little change in length and require fast query speed, it is best to choose varchar type
Iv. Time and date types
Year years
Time
Date Dates
DateTime and timestamp, indicating a large range, select Datetime.timestamp automatically according to the time zone to correspond to the date time, if there is this requirement, select Timestamp
V. Text and BLOBs
Text type stores only character data
Blob type stores binary data
Vi. How to store paths in MySQL
MySQL uses string types to store paths, such as varchar, text, and so on
If the path includes ' \ ' will be automatically filtered, Workaround: Use '/' and ' \ \ ' instead
1 |
insert into more(path) values ( ‘E:\360yunpan\教学教案‘ );
|
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M02/83/A5/wKiom1d5vobwrwPfAAARZyn3G1k094.png "alt = "Wkiom1d5vobwrwpfaaarzyn3g1k094.png"/>
1 |
insert into more(path) values ( ‘E:\\360yunpan\\教学教案‘ );
|
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M00/83/A5/wKiom1d5voeipjKKAAAVRrk8K9Y420.png "alt = "Wkiom1d5voeipjkkaaavrrk8k9y420.png"/>
Vii. How to use Boolean types in MySQL
MySQL supports Boolean types, denoted by bool or Boolean.
In Mysqlk, the bool or Boolean type is finally converted to the tinyint (1) type.
1 |
alter table more add sex boolean;
|
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M01/83/A4/wKioL1d5voeA4l6EAAAbsLi6soc116.png "alt = "Wkiol1d5voea4l6eaaabsli6soc116.png"/>
Eight, null value (a) null is a strange value
Null is not equal to null value
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M01/83/A5/wKiom1d5voeQBxIBAAAFN1lTjlg642.png "alt = "Wkiom1d5voeqbxibaaafn1ltjlg642.png"/>650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M00/83 /a4/wkiol1d5voecmsbvaaaggzeojhu333.png "alt=" Wkiol1d5voecmsbvaaaggzeojhu333.png "/>
Null is not equal to NULL
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M02/83/A4/wKioL1d5vofi2-SYAAAHqnN5Hbs319.png "alt = "Wkiol1d5vofi2-syaaahqnn5hbs319.png"/>650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M02/83 /a5/wkiom1d5vofgtfciaaahmtdtcja134.png "alt=" Wkiom1d5vofgtfciaaahmtdtcja134.png "/>
Can be compared by IS null or is not NULL
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M00/83/A4/wKioL1d5voeSTrIoAAAGqUzmwYI034.png "alt = "Wkiol1d5voestrioaaagquzmwyi034.png"/>650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M00/83 /a5/wkiom1d5vojg2jotaaahm8cazty769.png "alt=" Wkiom1d5vojg2jotaaahm8cazty769.png "/>
(ii) Setting default values
Many types of columns are populated with NULL if they are not assigned a value and the columns have no default values.
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M00/83/A5/wKiom1d5voihmbhMAAANUnxxAuI317.png "alt = "Wkiom1d5voihmbhmaaanunxxaui317.png"/>
For the convenience of query filtering later, you can set the default value when you define a column
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M01/83/A4/wKioL1d5vojB-FbiAAAXYiZPuh0680.png "alt = "Wkiol1d5vojb-fbiaaaxyizpuh0680.png"/>
Nine, teaching video
Http://edu.51cto.com/course/course_id-6420.html
This article is from "Learn programming with Mr. Wang" blog, please be sure to keep this source http://teacherwang.blog.51cto.com/10946447/1795484
Learn Mysql:mysql with Miss Wang. Data Types FAQs and Answers