oracle oracle区分大小写的原因?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7425153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:32:37  来源:igfitidea点击:

Reason why oracle is case sensitive?

oracledatabase-designcase-sensitive

提问by Steve

Is there a reason why Oracle is case sensitive and others like SQL Server, and MySQL are not by default?

Oracle 区分大小写而其他 SQL Server 和 MySQL 等默认情况下不区分大小写是否有原因?

I know that there are ways to enable/disable case sensitivity, but it just seems weird that oracle differs from other databases.

我知道有一些方法可以启用/禁用区分大小写,但是 oracle 与其他数据库不同似乎很奇怪。

I'm also trying to understand reasons for case sensitivity. I can see where "Table" and "TaBlE" can be considered equivalent and not equivalent, but is there an example where case sensitivity would actually make a difference?

我还试图了解区分大小写的原因。我可以看到“Table”和“TaBlE”在哪里可以被认为是等效的而不是等效的,但是有没有区分大小写实际上会产生影响的例子?

I'm somewhat new to databases and am currently taking a class.

我对数据库有点陌生,目前正在上课。

回答by NullUserException

By default, Oracle identifiers (table names, column names, etc.) are case-insensitive. You can make them case-sensitive by using quotes around them (eg: SELECT * FROM "My_Table" WHERE "my_field" = 1). SQL keywords (SELECT, WHERE, JOIN, etc.) are always case-insensitive.

默认情况下,Oracle 标识符(表名、列名等)不区分大小写。您可以通过在它们周围使用引号使它们区分大小写(例如:)SELECT * FROM "My_Table" WHERE "my_field" = 1。SQL 关键字(SELECTWHEREJOIN等)始终不区分大小写。

On the other hand, string comparisons are case-sensitive(eg: WHERE field='STRING'will only match columns where it's 'STRING') by default. You can make them case-insensitive by setting NLS_COMPand NLS_SORTto the appropriate values (eg: LINGUISTICand BINARY_CI, respectively).

另一方面,默认情况下,字符串比较是区分大小写的(例如:WHERE field='STRING'只会匹配它所在的列'STRING')。您可以通过将NLS_COMP和设置NLS_SORT为适当的值(例如:分别为LINGUISTICBINARY_CI)使它们不区分大小写。

Note: When inquiring data dictionary views (eg: dba_tables) the names will be in upper-case if you created them without quotes, and the string comparison rules as explained in the second paragraph will apply here.

注意:在查询数据字典视图(例如dba_tables:)时,如果您创建的名称不带引号,则名称将为大写,并且第二段中解释的字符串比较规则将在此处适用。

Some databases (Oracle, IBM DB2, PostgreSQL, etc.) will perform case-sensitive string comparisons by default, others case-insensitive (SQL Server, MySQL, SQLite). This isn't standard by any means, so just be aware of what your db settings are.

默认情况下,某些数据库(Oracle、IBM DB2、PostgreSQL 等)将执行区分大小写的字符串比较,其他数据库不区分大小写(SQL Server、MySQL、SQLite)。这无论如何都不是标准的,所以请注意您的数据库设置是什么。

回答by David Taylor

Oracle actually treats field and table names in a case-insensitive manner unless you use quotes around identifiers. If you create a table without quotes around the name, for example CREATE MyTable..., the resulting table name will be converted to upper case (i.e. MYTABLE) and will be treated in a case insensitive manner. SELECT * from MYTABLE, SELECT * from MyTable, SELECT * from myTabLe will all match MYTABLE (note the lack of quotes around the table name). Here is a nice article on this issuethat discusses this issue in more detail and compares databases.

Oracle 实际上以不区分大小写的方式处理字段名和表名,除非您在标识符周围使用引号。如果您创建的表名称周围没有引号,例如 CREATE MyTable...,则生成的表名称将被转换为大写(即 MYTABLE),并且将以不区分大小写的方式进行处理。SELECT * from MYTABLE、SELECT * from MyTable、SELECT * from myTabLe 都将匹配 MYTABLE(注意表名周围缺少引号)。这是一篇关于这个问题好文章,更详细地讨论了这个问题并比较了数据库。

回答by tsells

Keep in mind too for SQL Server the case sensitivity is based on the collation. The default collation is case insensitive - but this could be changed to be case sensitive. A similar example is why do the default Oracle databases use a Western European character set when UTF is required for global applications that use non ASCII characters? I think it's just a vendor preference.

请记住,对于 SQL Server,区分大小写是基于排序规则的。默认排序规则不区分大小写 - 但这可以更改为区分大小写。一个类似的例子是,当使用非 ASCII 字符的全局应用程序需要 UTF 时,为什么默认的 Oracle 数据库使用西欧字符集?我认为这只是供应商的偏好。

回答by Gerrat

If I had to guess, I'd say for historical/backwards-compatibility reasons.
Oraclefirst came out in 1977, and it was likely computationally expensive with the technology at the time to do the extra work for case-insensitive searches, so they just opted for exact matches.

如果我不得不猜测,我会说是出于历史/向后兼容性的原因。
Oracle于 1977 年首次问世,当时使用该技术为不区分大小写的搜索做额外的工作可能在计算上很昂贵,因此他们只选择了完全匹配。

回答by nvogel

For some applications case-sensitivity is important and for others it isn't. Whichever DBMS you use, business requirements should determine whether you need case-senitivity or not. I wouldn't worry too much about the "default".

对于某些应用程序区分大小写很重要,而对于其他应用程序则不然。无论您使用哪种 DBMS,业务需求都应确定您是否需要区分大小写。我不会太担心“默认”。