Native Data Types
CQL support following native types that are below
Data Type
|
Constants
supported
|
Description
|
ascii
|
string
|
ASCII character
string
|
bigint
|
integer
|
64-bit signed
long
|
blob
|
blob
|
Arbitrary bytes
(no validation)
|
boolean
|
boolean
|
true or false
|
counter
|
integer
|
Counter column
(64-bit signed value)
|
date
|
integer, string
|
A date (with no
corresponding time value)
|
decimal
|
integer, float
|
Variable-precision
decimal
|
double
|
integer float
|
64-bit IEEE-754
floating point
|
float
|
integer, float
|
32-bit IEEE-754
floating point
|
inet
|
string
|
An IP address,
either IPv4 (4 bytes long) or IPv6 (16 bytes long). Note that there is
no inet constant,
IP address should be input as strings
|
int
|
integer
|
32-bit signed int
|
smallint
|
integer
|
16-bit signed int
|
text
|
string
|
UTF8 encoded
string
|
time
|
integer, string
|
A time with
nanosecond precision
|
timestamp
|
integer, string
|
A timestamp (date and time) with
millisecond precision
|
timeuuid
|
uuid
|
Version 1 UUID
|
tinyint
|
integer
|
8-bit signed int
|
uuid
|
uuid
|
A UUID
|
varchar
|
string
|
UTF8 encoded
string
|
varint
|
integer
|
Arbitrary-precision
integer
|
I am going to describe some native data type
Counters:-
The counter data type is used to define counter columns
whose value is a 64-bit signed integer and counter support operations i.e.
incrementing and decrementing.
Example:-
A= A+ 3 is used to increment/decrement counters. The column
name after the ‘=’ sign must be the same than the one before the ‘=’ sign.
UPDATE User SET total = total +200 WHERE userid = 1012
Important limitations
of Counters
- Counter cannot be used for PRIMARY KEY columns of a table.
- Either all the columns of a table outside the PRIMARY KEY have the counter type, or none of them have it.
- Counters do not support expiration.
- The deletion of counters is supported
- Counter updates are, by nature
Timestamps data type
Timestamp data type values are encoded as 64-bit signed
integers representing a number of milliseconds. Timestamps can be enter or
input in CQL either using their value as an integer, or using a string.
All of the values below are valid timestamp values for Mar
2, 2011, at 04:05:00 AM, GMT:
1299038700000 '2011-02-03 04:05+0000' '2011-02-03 04:05:00+0000' '2011-02-03 04:05:00.000+0000' '2011-02-03T04:05+0000' '2011-02-03T04:05:00+0000' '2011-02-03T04:05:00.000+0000'
Times data type
Times data type values are encoded as 64-bit signed integers
representing the number of nanoseconds since midnight. A time can be input either as an integer or using a string.
The format of times is hh:mm:ss[.fffffffff].
All of the values below are valid times values
'08:12:54' '08:12:54.123' '08:12:54.123456' '08:12:54.123456789'
No comments:
Post a comment