Learn Mysql:mysql with Mr. Wang date and time type of data type
Teacher: Wang Shaohua QQ Group No.: 483773664 Learning Content
Characteristics and use of year type
characteristics and use of time type
characteristics and use of date type
characteristics and use of datetime types
characteristics and use of timestamp type
MySQL represents the date and time data types in the following ways:
1. Year Type
2. Time Type
3. Date type
4. DateTime type
5. Timestamp type
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M02/83/A3/wKiom1d5Hduiff22AADvCneclyI895.jpg " >
I. Introduction to year type (i)
Year uses a string to represent years
The value of year type is displayed in MySQL in yyyy form
Value range: 1901-2155
(ii) Example 1. Create a table
| 12345 |
create table history (      id int primary Key auto_increment, title varchar (10 ),      y year |
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M00/83/A2/wKioL1d5HduzOchIAAAWuyJS91s386.png " >
2 normal value of inserting language
| 1 |
insertintohistory(title,y)values(‘中华人民共和国成立‘,‘1949‘); |
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M00/83/A3/wKiom1d5HdvjLWx2AAAU8wxaZ5E856.png " >
3. Insert less than 1901 value
| 1 |
insertintohistory(title,y)values(‘史前文明‘,‘1900‘); |
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M01/83/A2/wKioL1d5HduzyHSMAAAKkPJE58A115.png " >
4. Insert a 2-digit value
1-69 conversion to 2001-2069
70-99 conversion to 1970-1999
0 conversion to 0000
| 123 |
insert into history (title,y) values ( ' 1-69 ' ,23); insert into history (title,y) values ( ' 70-99 ' ,85); insert into history (title,y) values ( ' 0 ' ,0); |
650) this.width=650; "border=" 0 "src=" http://s3.51cto.com/wyfs02/M01/83/A3/wKiom1d5HdyxV4fkAAAlAyIuz7w737.png " >
The difference between 5, 0 and ' 0 '
0 means 0000
' 0 ' means 2000
| 12 |
insert into history (title,y) values ( ' two zeros difference ' ,0); insert into history (title,y) values ( ' two zeros difference ' , ' 0 '!-- to learn mysql:mysql data type date and time type with Mr. Wang |