Database Reference
In-Depth Information
The type system
Each column defined for a table has a defined type. In the users table, we used the text
and blob types, but those are only two of the many types built in to Cassandra.
Strings
Cassandra has two types that store string data:
• The text type stores UTF-8 encoded strings. It's also aliased as the varchar
type; you can use these interchangeably.
• The ascii type stores strings of ASCII characters (bytes 0-127).
Neither of the above string types has a limit on the length of strings that can be stored. In
CQL, string literals are surrounded in single quotes, 'like this' .
Integers
Cassandra has three types that store integers:
• The int type stores 32-bit integers, which can store values ranging from approx-
imately -2.1 billion to 2.1 billion
• The bigint type stores 64-bit integers, which can store values from about -9
quintillion to 9 quintillion
• The varint type stores integers of arbitrary size; it has no minimum or maxim-
um value
All integer types are signed, meaning they can hold positive or negative integers. There are
no unsigned numeric types in Cassandra. Integer literals in CQL, like in most languages,
consist of an optional minus sign followed by one or more digits, such as 3549 .
Floating point and decimal numbers
Cassandra has three types that store non-integer numbers:
• The float type stores 32-bit floating point numbers.
• The double type stores 64-bit floating point numbers.
• The decimal type stores variable-precision decimal numbers, with no upper
bound on size. Unlike a floating point number, a variable-precision decimal will
never suffer from base 10 rounding errors in the fractional part of the number.
Search WWH ::




Custom Search