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

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.

主站蜘蛛池模板: 罗江县| 临海市| 五峰| 青海省| 青田县| 南江县| 库伦旗| 肇庆市| 红河县| 剑阁县| 临夏市| 瑞金市| 儋州市| 永登县| 尼勒克县| 灵丘县| 建昌县| 浦城县| 昌邑市| 安远县| 栾川县| 嘉祥县| 永福县| 防城港市| 桐城市| 宝山区| 海门市| 涞水县| 行唐县| 玉溪市| 汉川市| 仪征市| 辉南县| 乡宁县| 临泽县| 新余市| 巴里| 砀山县| 浦北县| 周至县| 绥棱县|