{"id":297185,"date":"2020-01-15T15:00:37","date_gmt":"2020-01-15T15:00:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=297185"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=297185","title":{"rendered":"\u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 SEQUENCE \u043c\u0435\u0436\u0434\u0443 \u0431\u0430\u0437\u0430\u043c\u0438 PostgreSQL"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483424\/\">\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e PostgreSQL-\u0431\u0430\u0437\u0443 <b>\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/b> \u00ab\u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u00bb-\u043f\u043e\u043b\u044f \u0442\u0438\u043f\u0430 serial, \u0435\u0441\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u0438 \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c max(pk)\u00bb \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442?<\/p>\n<p>  \u041c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0445\u043e\u0442\u044c PG \u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e \u0432\u0435\u0440\u0441\u0438\u0438 10 <a href=\"https:\/\/postgrespro.ru\/docs\/postgrespro\/12\/functions-sequence\" rel=\"nofollow\">\u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/a> \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044f <b>\u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0441\u0435\u0430\u043d\u0441\u0430<\/b>, \u044d\u0442\u043e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/2w\/b4\/1a\/2wb41aanxsejoysm3kvpyxdjfjk.png\"><br \/>  <a name=\"habracut\"><\/a><br \/>  PostgreSQL \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u00ab\u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u00bb-\u043f\u043e\u043b\u044f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0435 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/datatype-numeric#DATATYPE-SERIAL\" rel=\"nofollow\">\u043f\u0441\u0435\u0432\u0434\u043e\u0442\u0438\u043f\u043e\u043c serial<\/a>:  <\/p>\n<blockquote><p>\u0422\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 smallserial, serial \u0438 bigserial \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438, \u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438 (\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 AUTO_INCREMENT \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0421\u0423\u0411\u0414).<\/p><\/blockquote>\n<p>\u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438, \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0443\u0432\u044f\u0437\u043a\u0430 DEFAULT-\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u044f \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/sql-createsequence\" rel=\"nofollow\">SEQUENCE<\/a> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0418 \u0438\u043d\u043e\u0433\u0434\u0430 \u0432 \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <u>\u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0432 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0431\u0430\u0437\u0443<\/u>.<\/p>\n<p>  \u041d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e:  <\/p>\n<blockquote><p><b>currval<\/b><br \/>  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u044b\u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0435 nextval \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <b><i>\u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0441\u0435\u0430\u043d\u0441\u0435. (\u0415\u0441\u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u0435\u0430\u043d\u0441\u0435 nextval \u043d\u0438 \u0440\u0430\u0437\u0443 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430.)<\/i><\/b> \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u0441\u0435\u0430\u043d\u0441\u0430, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0434\u0430\u0451\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432\u044b\u0437\u0432\u0430\u043b\u0430\u0441\u044c \u043b\u0438 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 nextval \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0435\u0430\u043d\u0441\u0430\u0445 \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 pg_sequences<\/b><\/p>\n<div class=\"spoiler_text\">\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 PostgreSQL 10 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/10\/view-pg-sequences\" rel=\"nofollow\">\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 pg_sequences<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0443\u0436\u0435 \u0432\u0438\u0434\u043d\u0430 \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439.<\/div>\n<\/div>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c:  <\/p>\n<pre><code class=\"sql\">CREATE TABLE tst(   id     serial -- \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u043e\u0435 \u043f\u043e\u043b\u0435 , val     integer );  INSERT INTO tst(val) VALUES(1),(2),(4),(8); <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"sql\">TABLE tst;<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">id | val --------  1 |   1  2 |   2  3 |   4  4 |   8<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>id = 4<\/code> \u043c\u044b \u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c. \u041d\u043e \u043a\u0442\u043e-\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043b \u0447\u0430\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442:  <\/p>\n<pre><code class=\"sql\">DELETE FROM tst WHERE id &gt; 2;<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">id | val --------  1 |   1  2 |   2<\/code><\/pre>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u043e\u043b\u044e:  <\/p>\n<pre><code class=\"sql\">SELECT pg_get_serial_sequence('tst', 'id');<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">pg_get_serial_sequence ---------------------- public.tst_id_seq<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 <b>\u0438\u043c\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/b> \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435:  <\/p>\n<pre><code class=\"sql\">SELECT * FROM public.tst_id_seq;<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">last_value | log_cnt | is_called --------------------------------          4 |      29 | t<\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u043b\u0435 <b>last_value<\/b> \u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u00ab\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435\u00bb \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043f\u0435\u043b\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/postgrespro.ru\/docs\/postgresql\/12\/dblink\" rel=\"nofollow\">\u043c\u043e\u0434\u0443\u043b\u044f dblink<\/a>:  <\/p>\n<pre><code class=\"sql\">-- \u043f\u043e\u0442\u0430\u0431\u043b\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0438\u043a\u0432\u0435\u043d\u0441\u043e\u0432, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435 SELECT   (     SELECT       nlv     FROM       dblink(         'host=... port=5432 dbname=... user=... password=...'       , $q$           SELECT setval(pg_get_serial_sequence('$q$ || quote_ident(sequence_schema) || $q$.$q$ || quote_ident(sequence_table) || $q$', '$q$ || sequence_column || $q$'), $q$ || lv || $q$)         $q$       ) T(nlv bigint) -- \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435   ) nlv , * FROM   (     SELECT       (         SELECT           relname         FROM           pg_class         WHERE           oid = (dp).refobjid       ) sequence_table     , (         SELECT           attname         FROM           pg_attribute         WHERE           (attrelid, attnum) = ((dp).refobjid, (dp).refobjsubid)       ) sequence_column     , *     FROM       (         SELECT           -- \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u0430\u0437\u0435-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435           (             SELECT               lv             FROM               dblink(                 'dbname=' || current_database()               , $q$                   SELECT last_value FROM $q$ || quote_ident(sequence_schema) || $q$.$q$ || quote_ident(sequence_name) || $q$                 $q$               ) T(lv bigint) -- \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0438\u043c\u044f \"\u0442\u0430\u0431\u043b\u0438\u0446\u044b\"-\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438           ) lv         , (             SELECT               dp             FROM               pg_depend dp             WHERE               (classid, objid, refclassid, deptype) = ('pg_class'::regclass, (quote_ident(sequence_schema) || '.' || quote_ident(sequence_name))::regclass, 'pg_class'::regclass, 'a')             LIMIT 1           ) dp -- \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         , *         FROM           information_schema.sequences         WHERE           sequence_schema IN ('public') -- \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0441\u0445\u0435\u043c       ) T   ) T WHERE   sequence_table !~ '^_'; -- \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0435 \u0438\u0437 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <\/code><\/pre>\n<p>  \u041d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0431\u0430\u0437\u0435-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d!<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/483424\/\"> https:\/\/habr.com\/ru\/post\/483424\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483424\/\">\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e PostgreSQL-\u0431\u0430\u0437\u0443 <b>\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/b> \u00ab\u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u00bb-\u043f\u043e\u043b\u044f \u0442\u0438\u043f\u0430 serial, \u0435\u0441\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u0438 \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c max(pk)\u00bb \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442?<\/p>\n<p>  \u041c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0445\u043e\u0442\u044c PG \u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e \u0432\u0435\u0440\u0441\u0438\u0438 10 <a href=\"https:\/\/postgrespro.ru\/docs\/postgrespro\/12\/functions-sequence\" rel=\"nofollow\">\u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/a> \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044f <b>\u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0441\u0435\u0430\u043d\u0441\u0430<\/b>, \u044d\u0442\u043e \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/2w\/b4\/1a\/2wb41aanxsejoysm3kvpyxdjfjk.png\">  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-297185","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=297185"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297185\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}