Cassandra 测试

ApacheCassandra的CQL命令中,表名和列名在不使用双引号时是不区分大小写的,内部会存储为小写。创建和查询时,使用双引号可以强制保持大小写。关键词、列名和表名在早期版本的CQL中遵循不同的大小写规则。CQL关键词本身是不区分大小写的。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Apache Cassandra™ 3.x

CQL for Apache Cassandra™ 1.2 (Not supported)

CQL for Apache Cassandra™ 2.2 and 3.x

All Posts - Datastax Community

区分大小写,双引号括起来

cqlsh:store> CREATE TABLE "TEST"(Foo int PRIMARY KEY ,"Bar" int);
cqlsh:store> DESC TABLES 

"TEST"  shopping_cart

cqlsh:store> CREATE TABLE TEST(Foo int PRIMARY KEY ,"Bar" int);
cqlsh:store> DESC TABLES 

"TEST"  test  shopping_cart

cqlsh:store> 

Uppercase and lowercase

Keyspace, column, and table names created using CQL 3 are case-insensitive unless enclosed in double quotation marks. If you enter names for these objects using any uppercase letters, Cassandra stores the names in lowercase. You can force the case by using double quotation marks. For example:

CREATE TABLE test ( Foo int PRIMARY KEY, "Bar" int );

The following table shows soem examples of partial queries that work and do not work to return results from the test table:

Queries that Work

Queries that Don't Work

SELECT foo FROM . . .

SELECT "Foo" FROM . . .

SELECT Foo FROM . . .

SELECT "BAR" FROM . . .

SELECT FOO FROM . . .

SELECT bar FROM . . .

SELECT "foo" FROM . . .

SELECT Bar FROM . . .

SELECT "Bar" FROM . . .

SELECT "foo" FROM ... works because internally, Cassandra stores foo in lowercase. The double-quotation mark character can be used as an escape character for the double quotation mark.

Case sensitivity rules in earlier versions of CQL apply when handling legacy tables.

CQL keywords are case-insensitive. For example, the keywords SELECT and select are equivalent. This document shows keywords in uppercase.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值