Display the Number of Tablets for a YCQL Table

Yugabyte Cloud Query Language (YCQL) is a semi-relational SQL API that is best fit for internet-scale OLTP and HTAP applications needing massive data ingestion and blazing-fast queries. It supports strongly consistent secondary indexes, a native JSON column type, and distributed transactions.

The CREATE TABLE statement is used to create a new table in a keyspace. It defines the table name, column names and types, primary key, and table properties.

We can use the CREATE TABLE statement with the WITH tablets = <num> clause to specify the number of tablets for a table. This is useful to scale the table up or down based on requirements.

Example:

				
					cassandra@ycqlsh> CREATE KEYSPACE ks;

cassandra@ycqlsh> CREATE TABLE ks.t (c1 INT PRIMARY KEY, c2 VARCHAR) WITH TABLETS = 16;
				
			

Later, you might forget how many tablets you specified when creating the table.

No problem! Simply run the DESCRIBE command to see the number of a tablets for a given table…
				
					cassandra@ycqlsh> DESC ks.t;

CREATE TABLE ks.t (
    c1 int PRIMARY KEY,
    c2 text
) WITH default_time_to_live = 0
    AND tablets = 16
    AND transactions = {'enabled': 'false'};
				
			

Have Fun!

Lucy keeping warm on a chilly night