# Does Scylla reorder columns in newly created tables?

**URL:** https://forum.scylladb.com/t/does-scylla-reorder-columns-in-newly-created-tables/1257
**Category:** ScyllaDB
**Tags:** data-model
**Created:** [January 30, 2024, 6:34pm UTC](https://forum.scylladb.com/t/does-scylla-reorder-columns-in-newly-created-tables/1257 "2024-01-30T18:34:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gjjohnson](https://avatars.discourse-cdn.com/v4/letter/g/df705f/32.png) [@gjjohnson](https://forum.scylladb.com/u/gjjohnson)
#### Post date: [January 30, 2024, 6:34pm UTC](https://forum.scylladb.com/t/does-scylla-reorder-columns-in-newly-created-tables/1257/1 "2024-01-30T18:34:06Z")

</div>

I am creating tracking.tracking\_data as:  
CREATE TABLE tracking\_data (  
first\_name text,  
last\_name text,  
timestamp timestamp,  
location varchar,  
speed double,  
heat double,  
telepathy\_powers int,  
primary key((first\_name, last\_name), timestamp))  
WITH CLUSTERING ORDER BY (timestamp DESC)  
AND COMPACTION = {‘class’: ‘TimeWindowCompactionStrategy’,  
‘base\_time\_seconds’: 3600,  
‘max\_sstable\_age\_days’: 1};

But when I describe the table, the columns are in a different sequence:  
cqlsh:tracking\> describe keyspace tracking;

CREATE KEYSPACE tracking WITH replication = {‘class’: ‘NetworkTopologyStrategy’, ‘DC1’: ‘3’} AND durable\_writes = true;

CREATE TABLE tracking.tracking\_data (  
first\_name text,  
last\_name text,  
timestamp timestamp,  
heat double,  
location text,  
speed double,  
telepathy\_powers int,  
PRIMARY KEY ((first\_name, last\_name), timestamp)  
) WITH CLUSTERING ORDER BY (timestamp DESC)  
AND bloom\_filter\_fp\_chance = 0.01  
AND caching = {‘keys’: ‘ALL’, ‘rows\_per\_partition’: ‘ALL’}  
AND comment = ‘’  
AND compaction = {‘base\_time\_seconds’: ‘3600’, ‘class’: ‘TimeWindowCompactionStrategy’, ‘max\_sstable\_age\_days’: ‘1’}  
AND compression = {‘sstable\_compression’: ‘org.apache.cassandra.io.compress.LZ4Compressor’}  
AND crc\_check\_chance = 1.0  
AND dclocal\_read\_repair\_chance = 0.0  
AND default\_time\_to\_live = 0  
AND gc\_grace\_seconds = 864000  
AND max\_index\_interval = 2048  
AND memtable\_flush\_period\_in\_ms = 0  
AND min\_index\_interval = 128  
AND read\_repair\_chance = 0.0  
AND speculative\_retry = ‘99.0PERCENTILE’;

---

<div class="post-metadata">

### Author: ![Guy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/guy/32/9_2.png) [@Guy](https://forum.scylladb.com/u/Guy)
#### Post date: [January 31, 2024, 5:50am UTC](https://forum.scylladb.com/t/does-scylla-reorder-columns-in-newly-created-tables/1257/2 "2024-01-31T05:50:42Z")

</div>

Good question.  
AFAIK in ScyllaDB (and Apache Cassandra), there is no guarantee regarding the order of the columns unless they are part of the [Primary Key](https://university.scylladb.com/courses/data-modeling/lessons/basic-data-modeling-2/topic/primary-key-partition-key-clustering-key/).  
The logic behind this has to do with the way that data is represented under the hood. This is (at some level) explained in the Basic Data Modeling lesson in Scylla University (mostly in the [Importance of Primary Key Selection  
lesson](https://university.scylladb.com/courses/data-modeling/lessons/basic-data-modeling-2/topic/importance-of-primary-key-selection/) and the [Importance of the Clustering Key lesson](https://university.scylladb.com/courses/data-modeling/lessons/basic-data-modeling-2/topic/importance-of-clustering-key/)).  
That means you should not rely on a particular order for the storage.  
Instead, you can define how the data will be presented at the application level.

---

<div class="post-metadata">

### Author: ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)
#### Post date: [January 31, 2024, 7:10am UTC](https://forum.scylladb.com/t/does-scylla-reorder-columns-in-newly-created-tables/1257/3 "2024-01-31T07:10:33Z")

</div>

Internally, columns are ordered alphabetically, except primary key columns, those are ordered as they were specified in the initial table definition.

---

<div class="post-metadata">

### Author: ![gjjohnson](https://avatars.discourse-cdn.com/v4/letter/g/df705f/32.png) [@gjjohnson](https://forum.scylladb.com/u/gjjohnson)
#### Post date: [January 31, 2024, 9:15am UTC](https://forum.scylladb.com/t/does-scylla-reorder-columns-in-newly-created-tables/1257/4 "2024-01-31T09:15:49Z")

</div>

Ok, thanks for the clarification.
