BARTULA CODE

Refresh AutoIncrement value in PostgreSQL

Sometimes on import data to database, you have issue with not updated autoincement keys?

Use this, to generate scripts for update all tables to their max available entry.

SELECT 'SELECT SETVAL(' ||
       quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname)) ||
       ', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM ' ||
       quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';'
FROM pg_class AS S,
     pg_depend AS D,
     pg_class AS T,
     pg_attribute AS C,
     pg_tables AS PGT
WHERE S.relkind = 'S'
    AND S.oid = D.objid
    AND D.refobjid = T.oid
    AND D.refobjid = C.attrelid
    AND D.refobjsubid = C.attnum
    AND T.relname = PGT.tablename
ORDER BY S.relname;

Read more

Windows Use UTC Time

ctrl+R -> RegEdit -> enter Registry: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation Key: RealTimeIsUniversal Type: DWORD (32-bit) Value. Value: 1 Then restart PC

Extend »
HTTP 204 - No Content