{"id":672,"date":"2006-08-10T01:00:00","date_gmt":"2006-08-09T16:00:00","guid":{"rendered":"https:\/\/ecoop.net\/memo\/2006-08-10-1.html"},"modified":"2006-08-10T01:00:00","modified_gmt":"2006-08-09T16:00:00","slug":"2006-08-10-1","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/2006-08-10-1.html","title":{"rendered":"\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3067\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u3055\u308c\u306a\u3044\u51e6\u7406"},"content":{"rendered":"<p>\n<\/p>\n<blockquote><p>BEGIN <br \/>\n&#8212; \u4efb\u610f\u306e\u51e6\u7406 ..(A)<br \/>\nROLLBACK \n<\/p><\/blockquote>\n<p>\u3068\u3059\u308c\u3070\u3001(A)\u3067\u4f55\u3092\u3057\u3066\u3082\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u3057\u3066\u304f\u308c\u308b\u3082\u306e\u3060\u3068\u601d\u3063\u3066\u3044\u305f\u3089\u305d\u308c\u306f\u52d8\u9055\u3044\u306e\u3088\u3046\u3067\u3059\u3002<br \/>\n&nbsp;<br \/>\n\u305f\u3068\u3048\u3070\u30b7\u30fc\u30b1\u30f3\u30b9\u306a\u3069\n<\/p>\n<blockquote><p>create sequence seq;<br \/>\n&nbsp;<br \/>\nBEGIN;<br \/>\nSELECT nextval(&#8216;seq&#8217;); &#8212; (B)<br \/>\nSELECT nextval(&#8216;seq&#8217;); &#8212; (C)<br \/>\nROLLBACK;<br \/>\nSELECT nextval(&#8216;seq&#8217;); &#8212; (D)\n<\/p><\/blockquote>\n<p>\u3068\u3057\u3066\u3082 (B) == (D) \u306b\u306f\u306a\u3089\u305a\u3001BEGIN, ROLLBACK \u3067\u56f2\u307e\u306a\u304b\u3063\u305f\u5834\u5408\u3068\u540c\u3058\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n&nbsp;<br \/>\nPGSQL-JP ML \u306b\u3088\u308b\u3068<br \/>\n&#8211; <a href=\"http:\/\/www.drive.ne.jp\/iMA\/showmail.pl?pgsql-jp=3098\">http:\/\/www.drive.ne.jp\/iMA\/showmail.pl?pgsql-jp=3098<\/a>\n<\/p>\n<blockquote><p>&nbsp;\n<\/p>\n<blockquote><p>\u7d20\u4eba\u7684\u306a\u8003\u3048\u3060\u3068\u3001transaction \u5185\u3067\u306e\u51e6\u7406\u306a\u3093\u3060\u304b\u3089\u3001\u5024\u3092\u623b\u3057\u3066<br \/>\n\u304f\u308c\u3066\u3082\u3088\u3055\u305d\u3046\u306a\u3082\u306e\u306a\u306e\u306b\u3001\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3002\u3002<\/p>\n<p>#Oracle \u3067\u3082 sequence \u306f\u623b\u3089\u306a\u3044\u3068\u805e\u3044\u305f\u306e\u3067\u3001\u51fa\u6765\u306a\u3044\u306e\u304c\u666e\u901a<br \/>\n#\u306a\u306e\u304b\u306a\u3042?\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n\u4ed6\u306b\u3082\u623b\u3089\u306a\u3044\u3082\u306e\u3068\u3057\u3066\u306f\u3001<br \/>\ncreate table<br \/>\ncreate index<br \/>\ncreate sequence<br \/>\n\u304c\u3042\u308a\u307e\u3059(\u4ed6\u306b\u3082\u3042\u308b\u304b\u3082)\u3002\u5546\u7528DB\u3067\u3082\u591a\u5206\u540c\u3058\u3067\u3059\u3002\n<\/p><\/blockquote>\n<p>\u516c\u5f0f PGSQL ML \u306e\u5f15\u7528\n<\/p>\n<blockquote><p>It&#8217;s normal behaviour.<br \/>\n&nbsp;<br \/>\nSequences are locked only for duration of nextval call, not for<br \/>\ntransaction! So, one sequence may be used simultaneously<br \/>\nby many transactions. No way to rollback sequence changes.<br \/>\n&nbsp;<br \/>\n\u610f\u8a33: \u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u30ed\u30c3\u30af\u306f nextval \u547c\u3073\u51fa\u3057\u306b\u3064\u3044\u3066\u306e\u30ed\u30c3\u30af\u3067\u3042\u308a\u3001\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306e\u305f\u3081\u306e\u30ed\u30c3\u30af\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u4e00\u3064\u306e\u30b7\u30fc\u30b1\u30f3\u30b9\u304c\u540c\u6642\u306b\u8907\u6570\u306e\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3067\u5229\u7528\u3055\u308c\u3046\u308b\u305f\u3081\u3001\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u5909\u66f4\u3092\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u3059\u308b\u65b9\u6cd5\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\n<\/p><\/blockquote>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u304c\u3001\u5358\u7d14\u306b\u3001\u4e00\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3067 serial (bigserial)\u3068\u3057\u3066\u5229\u7528\u3057\u3066\u3044\u3066\u3001\u4ed6\u3067 nextval \u304c\u547c\u3070\u308c\u306a\u3044\u3053\u3068\u3092\u30b7\u30b9\u30c6\u30e0\u7684\u306b\u4fdd\u8a3c\u3057\u3066\u3044\u308c\u3070\u3001<a href=\"http:\/\/www.postgresql.jp\/document\/pg803doc\/html\/sql-lock.html\">\u30c6\u30fc\u30d6\u30eb\u30ed\u30c3\u30af<\/a>\u3092\u4f7f\u3044\u3001ROLLBACK \u6642\u306b\u30b7\u30fc\u30b1\u30f3\u30b9\u3092\u5143\u306b\u623b\u3057\u3066\u3084\u308c\u3070\u3001\u4e00\u5fdc\u5b9f\u73fe\u306f\u53ef\u80fd\u304b\u306a\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>BEGIN &#8212; \u4efb\u610f\u306e\u51e6\u7406 ..(A) ROLLBACK \u3068\u3059\u308c\u3070\u3001(A)\u3067\u4f55\u3092\u3057\u3066\u3082\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u3057\u3066\u304f\u308c\u308b\u3082\u306e\u3060\u3068\u601d\u3063\u3066\u3044\u305f\u3089\u305d\u308c\u306f\u52d8\u9055\u3044\u306e\u3088\u3046\u3067\u3059\u3002 &nbsp; \u305f\u3068\u3048\u3070\u30b7\u30fc\u30b1\u30f3\u30b9\u306a\u3069 create s &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/2006-08-10-1.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3067\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u3055\u308c\u306a\u3044\u51e6\u7406<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[45],"class_list":["post-672","post","type-post","status-publish","format-standard","hentry","tag-postgresql"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=672"}],"version-history":[{"count":0,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/672\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}