The minute representation in the Database SQL statement should use Mi (a very important issue, which was previously considered to be the same as that in Java and can be expressed using mm); proofread rules (query Time Zone in case sensitive)

Source: Internet
Author: User

Java

The date indicated by the previous write Java code is YYYY-MM-DD hh: mm: SS

Mm (uppercase for month) and mm (lowercase for minutes)


SQL

But in SQL, the situation is completely different.

(Cause: the reason is that SQL statements are case-insensitive, so both mm and mm cannot be used, and the month should be defined as Mi)

We want to write the YYYY-MM-DD hh: MI: SS, using mi to represent minutes.


To_date ('1970-01-01 13:14:20 ', 'yyyy-mm-dd hh24: MI: ss ')

 

Bytes -----------------------------------------------------------------------------------------------

 

Description of the Case sensitivity issue, which leadsProofreading rules

 

Fuzzy search and normal query:

Mysql> select * From collage where coll_name like 'a % ';
+ --------- + ----------- +
| Coll_id | coll_name |
+ --------- + ----------- +
| 8 | AA |
| 9 | AA |
+ --------- + ----------- +
2 rows in SET (0.00 Sec)

Mysql> select * From collage where coll_name = 'a ';
+ --------- + ----------- +
| Coll_id | coll_name |
+ --------- + ----------- +
| 8 | AA |
| 9 | AA |
+ --------- + ----------- +
2 rows in SET (0.01 Sec)


No problem during data insertion :

Insert into collage values ('8', 'A ');

Insert into collage values ('9', 'A ');

 

 

Case sensitivity

Select * from a where a = 'abcde' collate chinese_prc_cs_ai -- case sensitive

Select * from a where a = 'abcde' collate chinese_prc_ci_ai -- case insensitive

Select * From collage where coll_name like 'a % 'collate gbk_bin; this isMySQLOfProofreading rules.

Mysql> select * From collage where coll_name like 'a %'Collate gbk_bin;
+ --------- + ----------- +
| Coll_id | coll_name |
+ --------- + ----------- +
| 8 | AA |
+ --------- + ----------- +

For UTF-8

utf8_bin 

You can specify rules when creating a table.


Create Table T1 (...)
Default Character Set Latin1Collate latin1_danish_ci;


For this table


Create Table Collage
(
Coll_id int not null auto_increment primary key,
Coll_name varchar (30) not null
) Engine = MyISAM
Default Character Set GBKCollateGbk_bin;


Zero network y9', jq wj p) j

 

 


 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.