In my previous post, I explained how to insert a uuid into a table using uuid() function. There are situations, where you have a uuid, and want to insert into a table.
How to insert hard coded uuid value?
Just insert as it is.
Example
INSERT INTO cassandratutorial.employee(id, first_name) VALUES (5987fd93-1783-4a14-a17a-5fc4fb191c2c, 'Krishna');
CQL Code snippet
CREATE KEYSPACE cassandratutorial WITH REPLICATION =
{
'class' : 'SimpleStrategy',
'replication_factor' : 1
};
CREATE TABLE IF NOT EXISTS cassandratutorial.employee (
id uuid PRIMARY KEY,
first_name VARCHAR
);
INSERT INTO cassandratutorial.employee(id, first_name) VALUES (5987fd93-1783-4a14-a17a-5fc4fb191c2c, 'Krishna');
Cqlsh console output
cqlsh> CREATE KEYSPACE cassandratutorial WITH REPLICATION =
... {
... 'class' : 'SimpleStrategy',
... 'replication_factor' : 1
... };
cqlsh>
cqlsh> CREATE TABLE IF NOT EXISTS cassandratutorial.employee (
... id uuid PRIMARY KEY,
... first_name VARCHAR
... );
cqlsh>
cqlsh> INSERT INTO cassandratutorial.employee(id, first_name) VALUES (5987fd93-1783-4a14-a17a-5fc4fb191c2c, 'Krishna');
cqlsh>
cqlsh> SELECT * FROM cassandratutorial.employee;
id | first_name
--------------------------------------+------------
5987fd93-1783-4a14-a17a-5fc4fb191c2c | Krishna
(1 rows)
No comments:
Post a Comment