mysql怎么看表大小写 mysql表大小查询
使MySQL查询区分大小写的实现方法
1、一种方法是可以设置表或行的collation,使其为binary或case
sensitive。在MySQL中,对于Column
Collate其约定的命名方法如下:
*_bin:
表示的是binary
case
sensitive
collation,也就是说是区分大小写的
*_cs:
case
sensitive
collation,区分大小写
*_ci:
case
insensitive
collation,不区分大小写
###########
#
Start
binary
collation
example
###########
mysql
create
table
case_bin_test
(word
VARCHAR(10))
CHARACTER
SET
latin1
COLLATE
latin1_bin;
Query
OK,
rows
affected
(0.02
sec)
mysql
INSERT
INTO
case_bin_test
VALUES
('Frank'),('Google'),('froogle'),('flickr'),('FlicKr');
Query
OK,
5
rows
affected
(0.00
sec)
Records:
5
Duplicates:
Warnings:
mysql
SELECT
*
FROM
case_bin_test
WHERE
word
LIKE
'f%';
+---------+
|
word
|
+---------+
|
froogle
|
|
flickr
|
+---------+
2
rows
in
set
(0.00
sec)
mysql
SELECT
*
FROM
case_bin_test
WHERE
word
LIKE
'F%';
+---------+
|
word
|
+---------+
|
Frank
|
|
FlicKr
|
+---------+
4
rows
in
set
(0.00
sec)
###########
#
End
###########
2、另外一种方法
###########
#
Start
case
sensitive
collation
example
###########
mysql
create
table
case_cs_test
(word
VARCHAR(10))
CHARACTER
SET
latin1
COLLATE
latin1_general_cs;
Query
OK,
rows
affected
(0.08
sec)
mysql
INSERT
INTO
case_cs_test
VALUES
('Frank'),('Google'),('froogle'),('flickr'),('FlicKr');
Query
OK,
5
rows
affected
(0.00
sec)
Records:
5
Duplicates:
Warnings:
mysql
SELECT
*
FROM
case_cs_test
WHERE
word
LIKE
'F%';
+---------+
|
word
|
+---------+
|
Frank
|
|
FlicKr
|
+---------+
4
rows
in
set
(0.00
sec)
mysql
SELECT
*
FROM
case_cs_test
WHERE
word
LIKE
'f%';
+---------+
|
word
|
+---------+
|
froogle
|
|
flickr
|
+---------+
2
rows
in
set
(0.00
sec)
###########
#
end
###########
3、还有一种方法就是在查询时指定collation
mysql
create
table
case_test
(word
VARCHAR(10))
CHARACTER
SET
latin1;
Query
OK,
rows
affected
(0.01
sec)
mysql
INSERT
INTO
case_test
VALUES
('Frank'),('Google'),('froogle'),('flickr'),('FlicKr');
Query
OK,
7
rows
affected
(0.01
sec)
Records:
7
Duplicates:
Warnings:
mysql
SELECT
*
FROM
case_test
WHERE
word
LIKE
'f%';
+---------+
|
word
|
+---------+
|
Frank
|
|
froogle
|
|
flickr
|
|
FlicKr
|
+---------+
6
rows
in
set
(0.01
sec)
mysql
SELECT
*
FROM
case_test
WHERE
word
LIKE
'F%';
+---------+
|
word
|
+---------+
|
Frank
|
|
froogle
|
|
flickr
|
|
FlicKr
|
+---------+
6
rows
in
set
(0.01
sec)
mysql
SELECT
*
FROM
case_test
WHERE
word
COLLATE
latin1_bin
LIKE
'F%';
+---------+
|
word
|
+---------+
|
Frank
|
|
FlicKr
|
+---------+
4
rows
in
set
(0.05
sec)
mysql
SELECT
*
FROM
case_test
WHERE
word
COLLATE
latin1_bin
LIKE
'f%';
+---------+
|
word
|
+---------+
|
froogle
|
|
flickr
|
+---------+
2
rows
in
set
(0.00
sec)
mysql
SELECT
*
FROM
case_test
WHERE
word
LIKE
'f%'
COLLATE
latin1_bin;
+---------+
|
word
|
+---------+
|
froogle
|
|
flickr
|
+---------+
2
rows
in
set
(0.00
sec)
mysql
SELECT
*
FROM
case_test
WHERE
word
LIKE
'F%'
COLLATE
latin1_bin;
+---------+
|
word
|
+---------+
|
Frank
|
|
FlicKr
|
+---------+
4
rows
in
set
(0.01
sec)
mysql
SELECT
*
FROM
case_test
WHERE
word
LIKE
'F%'
COLLATE
latin1_general_cs;
+---------+
|
word
|
+---------+
|
Frank
|
|
FlicKr
|
+---------+
4
rows
in
set
(0.04
sec)
mysql数据库表名区分大小写
使用mysql的时候,创建的表明都是大写的,但是查询语句中表明用消息就会报错,表不存在。
查询后发现mysql默认配置是表明区分大小写的,如果要修改成不区分大小写,需要修改一下配置。
mysql 怎么检查大小写敏感
1、linux下mysql安装完后是默认:区分表名的大小写,不区分列名的大小写;
2、用root帐号登录后,在/etc/my点吸烟f 中的[mysqld]后添加添加lower_case_table_names=1,重启MYSQL服务,这时已设置成功:不区分表名的大小写;
lower_case_table_names参数详解:
lower_case_table_names = 0
其中 0:区分大小写,1:不区分大小写
MySQL在Linux下数据库名、表名、列名、别名大小写规则是这样的:
1、数据库名与表名是严格区分大小写的;
2、表的别名是严格区分大小写的;
3、列名与列的别名在所有的情况下均是忽略大小写的;
4、变量名也是严格区分大小写的;
MySQL在Windows下都不区分大小写。
3、如果想在查询时区分字段值的大小写,则:字段值需要设置BINARY属性,设置的方法有多种:
A、创建时设置:
CREATE TABLE T(
A VARCHAR(10) BINARY
);
B、使用alter修改:
ALTER TABLE `tablename` MODIFY COLUMN `cloname` VARCHAR(45) BINARY;
C、mysql table editor中直接勾选BINARY项。
栏 目:Mysql
本文地址:https://www.xiuzhanwang.com/a1/Mysql/17182.html
您可能感兴趣的文章
阅读排行
本栏相关
- 04-02怎么忽略mysql密码 mysql怎么取消密码
- 04-02mysql文字乱码怎么办 mysql中文乱码怎样
- 04-02怎么把数组导入mysql 把数据放入数组
- 04-02mysql配置怎么解决 mysql配置失败怎么重
- 04-02mysql企业版怎么安装 mysql数据库企业版
- 04-02怎么更改mysql到d盘 mysql怎么移到d盘
- 04-02mysql怎么看表大小写 mysql表大小查询
- 04-02Mysql怎么关联多个表 mysql 关联
- 04-02mysql怎么查语句 mysql数据查询语句
- 04-02怎么关闭mysql的自启 关闭mysql自启动
随机阅读
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-10C#中split用法实例总结
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-10SublimeText编译C开发环境设置
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 01-11ajax实现页面的局部加载
- 01-10delphi制作wav文件的方法
- 04-02jquery与jsp,用jquery