Create Tables in YCQL with Distributed Transactions Enabled by Default

The transactions property of the CREATE TABLE command in YCQL specifies if distributed transactions are enabled in the table.

This property defaults to false.

Example:

				
					cassandra@ycqlsh> CREATE KEYSPACE k;

cassandra@ycqlsh> CREATE TABLE k.t1 (c1 INT PRIMARY KEY);

cassandra@ycqlsh> DESC TABLE k.t1;

CREATE TABLE k.t1 (
    c1 int PRIMARY KEY
) WITH default_time_to_live = 0
    AND transactions = {'enabled': 'false'};
				
			

To enable distributed transactions, use transactions = { 'enabled' : true } .

Example:

				
					cassandra@ycqlsh> CREATE TABLE k.t2 (c1 INT PRIMARY KEY) WITH transactions = {'enabled': 'true'};

cassandra@ycqlsh> DESC TABLE k.t2;

CREATE TABLE k.t2 (
    c1 int PRIMARY KEY
) WITH default_time_to_live = 0
    AND transactions = {'enabled': 'true'};
				
			
There is a T-Server gFlag named cql_table_is_transactional_by_default that can be turned on (set to true) to allow tables created in YCQL to support distrubuted transactions by default.

To check the current value of cql_table_is_transactional_by_default , I could curl the T-Server Web UI:

				
					[root@localhost ~]# curl -s yugabytedb.tech:9000/varz?raw | grep cql_table_is_transactional_by_default
--cql_table_is_transactional_by_default=false
				
			

After changing the gFlag to true,  tables that I create in YCQL will support distributed transactions without me having to manually specifying transactions = { 'enabled' : true } .

				
					cassandra@ycqlsh> CREATE TABLE k.t3 (c1 INT PRIMARY KEY);

cassandra@ycqlsh> DESC TABLE k.t3;

CREATE TABLE k.t3 (
    c1 int PRIMARY KEY
) WITH default_time_to_live = 0
    AND transactions = {'enabled': 'true'};
				
			

Have Fun!

Holmes Beach, Florida