Skip to content

[PostgreSQL] 如何更新 PostgreSQL 中的 auto increment 欄位值

Published: at 01:24 PM (1 min read)
SELECT column_name, column_default FROM information_schema.columns WHERE table_name = "table_name";
SELECT pg_get_serial_sequence('table_name', 'column_name');
SELECT last_value FROM sequence_name;
SELECT SETVAL('sequence_name', (SELECT MAX(column_name) FROM table_name));
ALTER SEQUENCE sequence_name RESTART WITH 1;

Next Post
[Algolia] 使用 removeWordsIfNoResults / optionalKeywords 放寬搜尋條件