A set is a CQL collection for multiple values of one type, with one important guarantee: each value appears only once. Declare its element type in angle brackets, such as SET<TEXT>. Sets suit small, bounded collections; move data expected to grow substantially or unpredictably into its own table so ScyllaDB can optimize it with partition or clustering keys. section 4.5
Unlike a list, a set has no position-based access. That smaller interface avoids ordering-dependent updates: adding an existing value changes nothing, and removing an absent value changes nothing. These operations are idempotent, so repeating them produces the same stored set and avoids client-side deduplication. section 4.5.2 section 4.5.1
Use a set when the requirement is “multiple distinct values” rather than ordered or keyed data:
- Choose SET<T> over LIST<T> when duplicates are unnecessary; list appends can create repeated entries when rerun. section 4.5.2
- Choose MAP<K,V> when values need named keys; maps provide unique keys and are sorted by key. section 4.5
- Use a user-defined type for one multi-field entity, then place frozen UDT values in a set when a collection of those entities is needed. section 4.5.6
Adding and removing distinct text values
Set literals use curly braces. Insert {'a', 'b', 'c'}, then add values with + or remove them with -. Reinserting 'c' does not raise an error or create a second copy. Adding {'d', 'e'} repeatedly still leaves one copy of each; subtracting {'d', 'e', 'f'} removes d and e while safely ignoring absent f. section 4.5.2
cqlsh:types> UPDATE collections
SET set_text = set_text + {'d', 'e'}
WHERE text = 'set';
This CQL update adds two values to an existing set; because set membership is unique, rerunning it does not duplicate them. section 4.5.2
An article image gallery can be modeled as SET<FROZEN<image>>: each image is a multi-field image UDT, and a gallery should not contain duplicate images. Freezing is required when a UDT is used inside a collection. section 4.5.6 section 5.3.1














