Prevent serial column in postgresql from generating duplicate value.

ALTER SEQUENCE tablename_colname_seq RESTART WITH 52;
SELECT setval('tablename_colname_seq', (SELECT max(colname) FROM tablename));

--

--

--

System Administrator and Full stack web developer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Quick Tip: PWA, Manifest and Azure

Ktor — Setting up JWT

error

Speeding up development: a collection of tips

Turning off notifications for more focus

API 101 using Postman

Jenkins and Slack Integration

Chernobyl, Anatoly Dyatlov and Engineering Arrogance

Best of: Java 8

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Himanshu Pratap

Himanshu Pratap

System Administrator and Full stack web developer.

More from Medium

Existing In Opposites

Example of a Klever Validator in a Kubernetes Cluster

SSH : PORT 22 CONNECTION ISSUE SOLVED

Tea with Jimi Hendrix