Reputation: 1611
I have to run the following insert query 1000 times in BATCH just after loading a schema.
INSERT INTO keyspace.messages (messageid, message) VALUES
(uuid(), 'random');
My current implementation is a radom.cql
file, which has 1000 entries like the script below. And then I use SOURCE command to apply them after my schema upload.
BEGIN BATCH
INSERT INTO keyspace.messages (messageid, message) VALUES (uuid(), 'random');
INSERT INTO keyspace.messages (messageid, message) VALUES (uuid(), 'random');
INSERT INTO keyspace.messages (messageid, message) VALUES (uuid(), 'random');
...till 1000 times
APPLY BATCH;
Is there any better way to achieve the same result?
Upvotes: 2
Views: 2232
Reputation: 1015
Cassandra doesn't have any PL/SQL constructs or stored procedures yet, so it's impossible.
You have to do it from application side and batch doesn't help in this scenario and is a bad way of using it.
Upvotes: 1