如何以小写名称创建表-JavaDB / Derby? [英] How to create table in lower case name - JavaDB/Derby?

查看:110
本文介绍了如何以小写名称创建表-JavaDB / Derby?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用JavaDB / Derby以小写形式创建表及其名称?要检查表是否存在,我正在使用:

Is it possible to create table and it's name in lower case using JavaDB/Derby? To check if table exists I'm using:

ResultSet rs = dbmd.getTables(null, "APP", "user_properties", null);
if (!rs.next()) {/*do something*/};

但是表名'user_properties'必须符合目录中的情况。

But table name 'user_properties' must mach the case in catalog.

推荐答案

Derby遵循ANSI标准,该标准要求将未加引号的标识符折叠为大写。
因此,以下语句:

Derby follows the ANSI standard which requires unquoted identifiers to be folded to uppercase. So, the following statement:

create table user_properties
(
   id integer not null
);

将创建一个表,其名称为 USER_PROPERTIES 还有一个名为 ID 的列。

will create a table with then name USER_PROPERTIES and a column named ID.

您可以通过以下方式强制Derby存储小写(或实际上混合大小写)的名称:使用带引号的标识符:

You can force Derby to store lower case (or actually mixed cased) names by using quoted identifiers:

create table "user_properties"
(
   "id" integer not null
);

将创建一个表,其名称为 user_properties 和一个名为 id 的列。

will create a table with then name user_properties and a column named id.

当您使用带引号的标识符(又名定界标识符)时,它们会变成大小写-敏感,因此必须始终使用双引号引用第二个表。

When you use quoted identifiers (aka "delimited identifiers") they become case-sensitive, so the second table must always be referenced using double quotes.

语句从user_properties中选择* 工作。您必须始终引用它:从 user_properties中选择*

The statement select * from user_properties will not work if the table was created with the second statement. You have to always quote it: select * from "user_properties".

使用带引号的标识符通常会导致很多麻烦,而不是值得的。如果您从未引用过标识符,则可以在调用 getTables()

Using quoted identifiers is usually causing much more trouble than it's worth. If you never ever quote your identifiers you can safely use the upper case name in the call to getTables()

这篇关于如何以小写名称创建表-JavaDB / Derby?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆