0% found this document useful (0 votes)
8 views5 pages

Data Types

casandra datatypes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Data Types

casandra datatypes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

UUID DataType

CREATE TABLE books_by_author(


author_name TEXT,
publish_year INT,
book_id UUID,
book_name TEXT,
rating FLOAT,
PRIMARY KEY((author_name),publish_year,rating))
WITH CLUSTERING ORDER BY (publish_year DESC,rating ASC);

INSERT INTO books_by_author


(author_name, publish_year, book_id, book_name, rating)
VALUES('Michael Anderson',2017,uuid(),'Manning',4);

Time UUID DataType


ALTER TABLE books_by_author
ADD book_timeuuid TIMEUUID;

INSERT INTO books_by_author


(author_name, publish_year, book_id, book_timeuuid, book_name,
rating)
VALUES('Tony',2017,uuid(),now(), 'Crust',4);

Select * from books_by_author where author_name='Tony';

Set DataType
ALTER TABLE books_by_author
ADD emails SET<TEXT>;

DESCRIBE books_by_author;

UPDATE books_by_author
SET emails = {'michael@gmail.com', 'michael@yahoo.com'}
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET emails = emails + {'michael1234@yahoo.com',
'michael@gmail.com'}
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET emails = emails - {'michael1234@yahoo.com'}
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET emails = { }
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;
List DataType

ALTER TABLE books_by_author


ADD phone LIST<TEXT>;

UPDATE books_by_author
SET phone = ['1-180-11100']
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET phone = phone + ['1-180-11101']
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET phone[1] = '1-180-11102'
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET phone = phone - ['1-180-11101']
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET phone = []
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

Map DataType

ALTER TABLE books_by_author


ADD family MAP<TEXT,TEXT>;

UPDATE books_by_author
SET family = {'Wife': 'Sanya', 'Sibling': 'John'}
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET family = family + {'Son': 'Albert'}
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

UPDATE books_by_author
SET family = family - {'Wife'}
WHERE author_name='Michael Anderson'
AND publish_year=2017
AND rating=4;

You might also like