Connecting to Cassandra:
cqlsh <host> <port> --user=<username> --password=<password>
Example:
cqlsh 127.0.0.1 9042 --user=cassandra --password=cassandra
A quick reference guide to Cassandra Query Language (CQL), covering essential commands, data types, and functions for efficient database management.
|
Connecting to Cassandra:
Example: |
|
Without Authentication:
Example: |
|
Create Keyspace: |
Example: |
|
Use Keyspace: |
Example: |
|
Alter Keyspace: |
Example: |
|
Drop Keyspace: |
Example: |
|
Create Table: |
Example: |
|
Alter Table (Add Column): |
Example: |
|
Drop Table: |
Example: |
|
Truncate Table: |
Example: |
|
Example: |
|
Example: |
|
Example: |
|
Example: |
|
text |
Variable-length UTF-8 string. |
|
ascii |
US-ASCII string. |
|
bigint |
64-bit signed long. |
|
blob |
Arbitrary sequence of bytes (up to 2GB). |
|
boolean |
True or False. |
|
decimal |
Variable-precision decimal. |
|
double |
64-bit IEEE-754 floating point. |
|
float |
32-bit IEEE-754 floating point. |
|
int |
32-bit signed integer. |
|
timestamp |
Date and time (stored as milliseconds since epoch). |
|
uuid |
Type 4 universally unique identifier. |
|
timeuuid |
Type 1 time-based universally unique identifier. |
|
inet |
IPv4 or IPv6 address. |
|
Creating an Index: |
Example: |
|
Dropping an Index: |
Example: |
|
Executing Multiple Statements Atomically:
Example: |
|
Built-in Functions: |
CQL provides various built-in functions for data manipulation. Examples: |
|
Example Usage: |
|