Home  >  Article  >  Database  >  sqlserver,oracle ,Mysql数据库 关于区分大小写查询的问题

sqlserver,oracle ,Mysql数据库 关于区分大小写查询的问题

PHP中文网
PHP中文网Original
2017-03-31 16:02:311625browse

SQLSERVER

在sqlserver 中 查询默认是不区分大小写  即 where a='ABC'  与where a=‘abc’是一样的

但是我们可以通过方法 设置是否区分大小写

方法一:

ALTER TABLE tb   (指定某表的某列)
ALTER COLUMN colname nvarchar(100) COLLATE Chinese_PRC_CI_AS          --不区分大小写

ALTER TABLE tb   (指定某表的某列)
ALTER COLUMN colname nvarchar(100) COLLATE Chinese_PRC_CS_AS         --区分大小写

alter database 数据库 COLLATE Chinese_PRC_CS_AS  (指定整个数据库)

方法二:

select * from servers where convert(varbinary, name)=convert(varbinary, N'RoCKEY')

ORACLE

Oracle10g 中查询默认是区分大小写的 (使用sql语句查询当前oracle版本:select * from v$version)

这里也可以设置不区分大小写,步骤如下

ALTER SESSION SET NLS_COMP=ANSI;
ALTER SESSION SET NLS_SORT=binary_ci;

效果图:

如果是使用like的话 要用正则区分

效果图:

MYSQL

mysql的 like  默认是不区分大小写的   like binary 区分大小写

 以上就是sqlserver,oracle ,Mysql数据库 关于区分大小写查询的问题的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn