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

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.

主站蜘蛛池模板: 澳门| 田林县| 历史| 梁河县| 应城市| 炉霍县| 文山县| 辽宁省| 贡觉县| 岳池县| 厦门市| 晋州市| 巴彦淖尔市| 万山特区| 来宾市| 汶上县| 屏东县| 宿迁市| 大英县| 盖州市| 永寿县| 固安县| 河北省| 义马市| 南澳县| 洱源县| 汉沽区| 巴林左旗| 衡山县| 舞钢市| 家居| 凌源市| 新邵县| 莱西市| 田东县| 道孚县| 淳安县| 盱眙县| 吉安市| 桦南县| 霍州市|