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:

    page_count = page_count + 1
    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 PostgreSQL? Check out TablePlus. It’s native, beautiful, and available for free.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

TablePlus GUI Tool PostgreSQL