How to update Counters type?

Create a table with counter type

CREATE TABLE test_counter (
     page_id uuid,
     page_count counter,
     PRIMARY KEY (page_id)
);

Using SQL you can update counters with UPDATE statement, this UPDATE will insert a new row, you don’t need to insert any rows after create table:

UPDATE
    test_counter
SET
    page_count = page_count + 1
WHERE
    page_id = 8372cee6-1d04-41f7-a70d-98fdd9036448;
    

Noted You must edit counter with UPDATE and the value must be: counter = counter + delta with delta = new_value - old_value.

With TablePlus

  • Click open a table with counter.
  • Double click and edit the counter value.
  • Command + S to save.

Need a good GUI tool for Cassandra? Check out TablePlus, a modern, native tool for multiple databases including SQL Server, MySQL, PostgreSQL, SQLite, etc. And it’s free to use for as long as you need it to.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS

TablePlus GUI Tool PostgreSQL