oracle区分大小写的原因?
Oracle 区分大小写而 SQL Server 和 MySQL 等其他软件默认不区分大小写是否有原因?
我知道有一些方法可以启用/禁用区分大小写,但 oracle 与其他数据库的不同似乎很奇怪.
I know that there are ways to enable/disable case sensitivity, but it just seems weird that oracle differs from other databases.
我也在尝试了解区分大小写的原因.我可以看到Table"和TaBlE"在哪些地方可以被视为等效而不是等效的,但是是否有区分大小写实际上会产生影响的示例?
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?
我对数据库有点陌生,目前正在上课.
I'm somewhat new to databases and am currently taking a class.
推荐答案
默认情况下,Oracle 标识符(表名、列名等)不区分大小写不区分.您可以通过在它们周围使用引号使它们区分大小写(例如:SELECT * FROM "My_Table" WHERE "my_field" = 1
).SQL 关键字(SELECT
、WHERE
、JOIN
等)始终不区分大小写.
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.
另一方面,字符串比较区分大小写敏感(例如:WHERE field='STRING'
将仅匹配 'STRING'
) 默认情况下.您可以通过将 NLS_COMP
和 NLS_SORT
设置为适当的值来使它们不区分大小写(例如:LINGUISTIC
和 BINARY_CI
,分别).
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_COMP
and NLS_SORT
to the appropriate values (eg: LINGUISTIC
and BINARY_CI
, respectively).
注意:在查询数据字典视图(例如:dba_tables
)时,如果您创建的名称不带引号,则名称将为大写,并且将适用第二段中解释的字符串比较规则在这里.
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.
默认情况下,某些数据库(Oracle、IBM DB2、PostgreSQL 等)将执行区分大小写的字符串比较,其他数据库不区分大小写(SQL Server、MySQL、SQLite).这无论如何都不是标准的,所以请注意您的数据库设置是什么.
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.
相关文章