How to create table with Single Column Primary Key in Cassandra
The table can be created with single column Primary Key ( Simple Primary Key). As the very first Column in Primary Key is Partition Key, your Primary Key is also the Partition Key. Cassandra use Partition Key to distribute the data across different nodes.
Syntax:
(
column1 DATATYPE PRIMARY KEY,
column2 DATATYPE,
column3 DATATYPE,
.............,
.............);
Or you can use below
(
column1 DATATYPE,
column2 DATATYPE,
column3 DATATYPE,
.............,
.............,
PRIMARY KEY (column1));
Example :
Let's create a Employee table with Simple Primary Key (EmployeeId of UUid data type) with below script and insert sample data.
(
employeeid UUID PRIMARY KEY,
fname TEXT,
lname TEXT,
address TEXT,
age TINYINT
);
Insret data into Employee table by using CQL Insert statement.
(
employeeid,
fname,
lname,
address,
age
)
VALUES
(
Uuid(),
'John',
'Doe',
' ABC Address',
23
);
Select the data from Employee table by using Select query.
Đặt vé máy bay tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ bao nhiêu tiền
vé máy bay hà nội về tphcm
vé máy bay từ tphcm đi hà nội
lịch bay hà nội đà lạt
giá vé máy bay từ mỹ về việt nam
đặt xe taxi sân bay
combo quy nhơn 3 ngày 2 đêm