Home:ALL Converter>PostgreSQL Restart Serial Primary Key

PostgreSQL Restart Serial Primary Key

Ask Time:2022-03-19T02:41:51         Author:Chicken Sandwich No Pickles

Json Formatter

I have a table created like this:

CREATE TABLE testing.table_comparison_summaries
(
  ID SERIAL
, reference_database_name varchar(255)
, reference_schema_name varchar(255)
, reference_table_name varchar(255)
, reference_deleted_row_count INT
, compare_database_name varchar(255)
, compare_schema_name varchar(255)
, compare_table_name varchar(255)
, compare_changed_row_count INT
, compare_new_row_count INT
, comparison_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP 
, CONSTRAINT pk_table_comparison_summaries PRIMARY KEY (id)
)
;

I want to restart the ID value as it's a table I'm doing a trunc/reload on.

I saw this thread: Reset PostgreSQL primary key to 1 , but it is not working for me.

The command I am using is this:

ALTER SEQUENCE
table_comparison_summaries id seq RESTART WITH 1;

What am I doing wrong?

Author:Chicken Sandwich No Pickles,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/71531795/postgresql-restart-serial-primary-key
yy