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.
- 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.
Not on Mac? Download TablePlus for Windows.