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

Table and column options

The table creation statement given in the previous section is very simple: little more than a list of column names and their respective types. In contrast, an SQL CREATE TABLE statement will often look quite complex, with multiple options set on each column, such as defaults, constraints, and nullability flags. What sorts of bells and whistles can we add to a CQL table?

At the table level, Cassandra does have quite a few configuration options known as table properties. These properties allow you to tune a wide range of under-the-hood aspects of the table, such as caching, compression, garbage collection, and read repair. Table properties do not, however, bear on the table's behavior from the application's standpoint. For this reason, we won't go into detail about them in this book.Columns, on the other hand, have very few knobs to turn. In fact, outside of the type, each column is pretty much the same. There are several column options you may be accustomed to from SQL databases that don't carry over to Cassandra, such as the following:

  • Cassandra doesn't have a concept of null values; columns either have data, or they don't. Primary key columns are always required to have a value; non-key columns are always optional. You will see the word null appear in the cqlsh output, but that simply means there is no data in this column and should not be confused with the concept of null in a relational database.
  • Cassandra doesn't support default values for columns. If a row is inserted without a value for a certain column, that column just doesn't have a value.
  • Cassandra doesn't provide data validations such as length limits or other more complex column constraints. As long as a value is of the right type for the column you're putting it in, it's valid.

Fortunately, most modern applications do not need to rely on the sorts of aforementioned constraints; domain modeling libraries and object mappers typically allow you to easily apply these constraints at the application level.

主站蜘蛛池模板: 阜康市| 龙里县| 长兴县| 阳春市| 揭阳市| 哈密市| 工布江达县| 吉木萨尔县| 海城市| 罗平县| 桃江县| 海阳市| 太谷县| 册亨县| 内黄县| 铁岭市| 宝应县| 宁强县| 辽中县| 太仓市| 揭东县| 湟源县| 车险| 胶州市| 龙里县| 边坝县| 宁城县| 桂阳县| 耒阳市| 廉江市| 郸城县| 永德县| 德钦县| 沅江市| 鹤峰县| 嘉鱼县| 奉化市| 玉田县| 镇坪县| 荔波县| 枞阳县|