TOOGLE
Cassandra 20 cli - Database
In this post we will talk about the 20 most important commands in the SQL Cassandra database language:

-- 1. CREATE KEYSPACE CREATE KEYSPACE my_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}; 
-- 2. USE USE my_keyspace; 
-- 3. CREATE TABLE CREATE TABLE users ( user_id UUID PRIMARY KEY, name TEXT, age INT, email TEXT ); 
-- 4. ALTER TABLE ALTER TABLE users ADD city TEXT; 
-- 5. INSERT INSERT INTO users (user_id, name, age, email) VALUES (uuid(), 'John Doe', 30, 'john@example.com'); 
-- 6. SELECT SELECT * FROM users WHERE age > 25; 
-- 7. UPDATE UPDATE users SET email = 'john.doe@example.com' WHERE user_id = 12345; 
-- 8. DELETE DELETE FROM users WHERE age < 18; 
-- 9. TRUNCATE TRUNCATE users; 
-- 10. DESCRIBE KEYSPACES DESCRIBE KEYSPACES;
-- 11. DESCRIBE TABLE
DESCRIBE TABLE my_keyspace.users;
-- 12. DROP KEYSPACE
DROP KEYSPACE my_keyspace;
-- 13. DROP TABLE
DROP TABLE users;
-- 14. CREATE INDEX
CREATE INDEX ON users (name);
-- 15. DROP INDEX
DROP INDEX IF EXISTS idx_name ON users;
-- 16. GRANT
GRANT ALL PERMISSIONS ON KEYSPACE my_keyspace TO my_user;
-- 17. REVOKE
REVOKE ALL PERMISSIONS ON KEYSPACE my_keyspace FROM my_user;
-- 18. SHOW VERSION
SHOW VERSION;
-- 19. SHOW HOST
SHOW HOST;
-- 20. HELP
HELP;
You can copy the entire code block above and use it in your Cassandra client or CQL shell to execute the commands. Remember to adjust any specific values or identifiers, such as keyspace names, table names, user names, and index names, as needed for your setup.