bitsCN.com
MySQL数据表中内容大小写区分的设置
MYSQL在默认的情况下查询是不区分大小写的,例如:
mysql> create table t1( -> name varchar(10)); Query OK, 0 rows affected (0.09 sec) mysql> insert into t1 values('you'),('You'),('YOU'); Query OK, 3 rows affected (0.05 sec) Records: 3 Duplicates: 0 Warnings: 0
对这个表,缺省情况下,下面两个查询的结果是一样的:
mysql> select * from t1 where name = 'you'; +------+ | name | +------+ | you | | You | | YOU | +------+ 3 rows in set (0.00 sec) mysql> select * from t1 where name = 'YOU'; +------+ | name | +------+ | you | | You | | YOU | +------+ 3 rows in set (0.00 sec)
如果想让MYSQL知道你输入的字母是大写还是小写的,修改表:
mysql> alter table t1 change name name varchar(10) binary; Query OK, 3 rows affected (0.20 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from t1 where name = 'you'; +------+ | name | +------+ | you | +------+ 1 row in set (0.00 sec) mysql> select * from t1 where name = 'YOU'; +------+ | name | +------+ | YOU | +------+ 1 row in set (0.00 sec)
如果你只是想在SQL语句中实现的话:
mysql> select * from t1 where name = binary 'YOU'; +------+ | name | +------+ | YOU | +------+ 1 row in set (0.02 sec) mysql> select * from t1 where name = binary 'you'; +------+ | name | +------+ | you | +------+ 1 row in set (0.00 sec)
如果不想这么麻烦而想服务一开启就让大小写一致的话:
可以修改my.ini或者my.cnf
[mysqld] lower_case_table_names=1 (0:区分;1:不区分)
然后重启MYSQL服务。
mysql> show variables like '%case_table%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 1 | +------------------------+-------+ 1 row in set (0.00 sec)
bitsCN.com

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。

“mysql-connector”是mysql官方提供的驱动器,可以用于连接使用mysql;可利用“pip install mysql-connector”命令进行安装,利用“import mysql.connector”测试是否安装成功。

MySQL是一种常见的关系型数据库,是许多网站和应用程序的核心组件。随着数据量越来越大,如何优化MySQL的性能就变得尤为重要。其中一个关键领域是数据表的压缩,在本文中我们将介绍MySQL中的数据表压缩技术。压缩表和非压缩表MySQL中有两种类型的数据表:压缩表和非压缩表。非压缩表是MySQL默认的表类型,它使用固定长度的行格式,对数据进行存储。这意味着数据

在mysql中,是否需要commit取决于存储引擎:1、若是不支持事务的存储引擎,如myisam,则不需要使用commit;2、若是支持事务的存储引擎,如innodb,则需要知道事务是否自动提交,因此需要使用commit。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor
