我是cassandra的新手,正在查看官方文档。我发现cassandra中的表概念与RDBMS非常相似。
https://cassandra.apache.org/doc/latest/cql/index.html将教我如何创建表,插入表等。
但是下面是https://www.tutorialspoint.com/cassandra/cassandra_data_model.htm的消息。
它说,与关系表中列族的模式不固定的情况不同,Cassandra不会强制单个行包含所有列。
下图显示了Cassandra列系列的示例。
我的问题是我在当前的cassandra中找不到这种设计,下面是我运行一些简单的insert命令的屏幕截图。
由于我只插入两列将INSERT插入emp(emp_id,emp_city)VALUES(5,'abc'),因此其余字段将设置为null,这与常规rdbms非常相似。>
那么您能告诉我如何在第一张图片中实施“不同的行具有不同的列”吗? 非常感谢。
答案 0 :(得分:1)
当您省略特定列的数据时,Cassandra不会插入const UserInputWithValue = ({ onChange, initialValue }) => {
// initilized once, no need to memoize
const [value,setValue] = useState(initialValue);
const handleChange = useCallback(
(event) => {
setValue(event.target.value)
onChange(event.target.value);
},
[onChange]
);
// Controlled
return <input type="text" value={value} onChange={handleChange} />;
};
。当您读取数据并且缺少数据时,将返回null
。最好使用null
检查数据在磁盘上的放置方式。例如,对于我的数据:
sstabledump
对于最后一行,我可以看到我没有实际数据,因为cqlsh:test> select * from test.st1;
id | c1 | s1 | v1
----+------+----+------
10 | null | 10 | null
1 | 1 | 2 | 1
1 | 2 | 2 | 1
2 | 10 | 3 | null
(4 rows)
为空:
cells
但是如果我明确插入 {
"partition" : {
"key" : [ "2" ],
"position" : 97
},
"rows" : [
{
"type" : "static_block",
"position" : 144,
"cells" : [
{ "name" : "s1", "value" : 3, "tstamp" : "2019-04-12T14:33:47.198445Z" }
]
},
{
"type" : "row",
"position" : 144,
"clustering" : [ 10 ],
"liveness_info" : { "tstamp" : "2019-04-29T12:49:31.450239Z" },
"cells" : [ ]
}
]
}
:
null
然后我将在数据文件中将其视为cqlsh:test> insert into test.st1(id, s1, c1, v1) values (3, 10, 3, null);
内的墓碑:
cells