官术网_书友最值得收藏!

Partial inserts

You are not, of course, required to provide values for all columns—other than primary key columns—when inserting a row. If, for instance, we decide to allow users to register without providing an email, we may issue this perfectly valid query:

    INSERT INTO "users"
("username", "encrypted_password")
VALUES (
'bob',
0x10920941a69549d33aaee6116ed1f47e19b8e713
);

In the preceding query, we only insert values for the username and encrypted_password fields; the row will have no value in the email field.

Do empty columns take up space?
Only columns with values take up storage space in Cassandra. This is in contrast to relational databases, in which every row has space allocated for every column, whether or not that column has a value. So, there's little downside to defining columns in Cassandra that you expect to rarely populate; they'll only take up space where they have values. For a full reference on the INSERT statement in CQL, consult the DataStax CQL documentation at http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/insert_r.html.

We haven't explored all of the possibilities for INSERT statements yet, but we'll cover many of them in future chapters.

主站蜘蛛池模板: 黄骅市| 太康县| 通州市| 神农架林区| 洛南县| 禄丰县| 通城县| 呼玛县| 石阡县| 宿迁市| 永寿县| 泗洪县| 仁怀市| 拜泉县| 丰原市| 谷城县| 宜兰市| 洛阳市| 龙胜| 辽阳县| 富民县| 合水县| 临海市| 通州市| 永春县| 库尔勒市| 含山县| 绿春县| 扎兰屯市| 安顺市| 南岸区| 和田市| 昌江| 类乌齐县| 武安市| 定州市| 台中县| 墨竹工卡县| 嘉善县| 苏尼特左旗| 东兴市|