如何在Oracle数据库中小写对象? [英] How to lower case objects in Oracle database?
问题描述
是否可以用小写字母命名Oracle DB
中的表,列?
Is there any way to name my Tables,Columns in the Oracle DB
in lower case letters?
我搜索了很多,一些建议说我应该在这样的创建中使用双引号:
I search a lot and some recommendations say i should use double quotes in the creation like this :
CREATE TABLE "test" (a number);
这里的问题是:
它迫使我通过查询用double quotes
装饰我的所有表!
It forces me to decorate all my tables with double quotes
through querying !
如果我写:
SELECT * FROM test ;
我将收到语法错误.
我想将我所有的表,字段都命名为小写,因为我将通过使用(c3)功能的ORM
(实体框架)在我的模型中使用它,所以如果我有这样的Table:
I want to name all my tables , fields as lower case because i will use this in my model through ORM
(Entity Framework) which use (Pluralization and Singularization
) feature , so if i have Table like this :
CITY
根据Oracle约定.
CITY
according to Oracle convention .
等效项将是CITY
实体,而作为导航属性的复数将是CITies
!
The equivalent will be CITY
entity and the pluralization as navigation property will be CITies
!!
推荐答案
[TL; DR]最简单的方法是永远不要在对象名称周围使用双引号,而只是让oracle在其名称中区分大小写默认方式.
默认情况下,Oracle数据库区分大小写;但是,默认情况下,它们也会将所有内容都转换为大写,以便区分大小写,即用户.
Oracle databases are, by default, case sensitive; however, they will also, by default, convert everything to upper-case so that the case sensitivity is abstracted from you, the user.
CREATE TABLE tEsT ( column_name NUMBER );
然后:
SELECT COUNT(*) FROM test;
SELECT COUNT(*) FROM Test;
SELECT COUNT(*) FROM TEST;
SELECT COUNT(*) FROM tEsT;
将全部给出相同的输出,并且:
Will all give the same output and:
SELECT * FROM USER_TABLES;
输出:
TABLE_NAME
----------
TEST
(注意表名是大写).
如果使用双引号,则oracle将在表名称中使用大小写:
If you use double quotes then oracle will respect your use of case in the table name:
CREATE TABLE "tEsT" ( column_name NUMBER );
和:
SELECT * FROM USER_TABLES;
输出:
TABLE_NAME
----------
TEST
tEsT
(注意:现在有两个名为TEST
和tEsT
的表,并且oracle尊重第二个表的区分大小写).
(Note: there are now two tables named TEST
and tEsT
and oracle has respected the case sensitivity of the second one).
这篇关于如何在Oracle数据库中小写对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!