{"id":612,"date":"2014-05-01T11:28:52","date_gmt":"2014-05-01T02:28:52","guid":{"rendered":"http:\/\/astel-labs.net\/blog\/diary\/?p=612"},"modified":"2014-05-02T10:03:00","modified_gmt":"2014-05-02T01:03:00","slug":"01-1","status":"publish","type":"post","link":"https:\/\/astel-labs.net\/blog\/diary\/2014\/05\/01-1.html","title":{"rendered":"SQL Server &#8211; IDENTITY\u6307\u5b9a\u5217\u306eID\u30ea\u30bb\u30c3\u30c8"},"content":{"rendered":"<p>\u81ea\u5206\u7528\u30e1\u30e2\u3067\u3059\u3002<\/p>\n<p>SQL Server \u3067 IDENTITY \u6307\u5b9a\u306eID\u5217\u3092\u4f5c\u6210\u3057\u305f\u5834\u5408\u3001\u30c6\u30fc\u30d6\u30eb\u521d\u671f\u5316\u3068\u30c7\u30fc\u30bf\u306e\u5165\u308c\u306a\u304a\u3057\u3092\u884c\u3046\u3068\u540c\u6642\u306b\u30b7\u30fc\u30c9\u5024\u3082\u30ea\u30bb\u30c3\u30c8\u3059\u308b\u5834\u5408\u306b\u306f\u3001\u300cBCC CHECKIDENT\u300d\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<blockquote><p>DBCC CHECKIDENT ( <span class=\"parameter\">table_name<\/span>, RESEED, <span class=\"parameter\">new_reseed_value<\/span> )<br \/>\n\u30fb<span class=\"parameter\">table_name<\/span>\uff1a\u73fe\u5728\u306e ID \u5024\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3001ID\u5217\u304c\u542b\u307e\u308c\u305f\u30c6\u30fc\u30d6\u30eb\u306e\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/>\n\u30fb<span class=\"parameter\">new_reseed_value <\/span>\uff1aID \u5217\u306e\u73fe\u5728\u5024\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u65b0\u3057\u3044\u5024\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p><\/blockquote>\n<p><!--more--><\/p>\n<p>\u4e0a\u8a18\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u5b9f\u884c\u5f8c\u306b\u633f\u5165\u3055\u308c\u308b\u6700\u521d\u306e\u884c\u306e ID \u306b\u306f\u3001<br \/>\n\u25cb\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u4ee5\u964d\u306b\u884c\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3001\u307e\u305f\u306f TRUNCATE TABLE \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u306b\u3088\u3063\u3066\u3059\u3079\u3066\u306e\u884c\u304c\u524a\u9664\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u306f\u3001<span class=\"parameter\">new_reseed_value<\/span>\u00a0\u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<br \/>\n\u25cbDELETE \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u306b\u3088\u308a\u65e2\u5b58\u884c\u304c\u3059\u3079\u3066\u524a\u9664\u3055\u308c\u305f\u5834\u5408\u3092\u542b\u3080\u3001\u65e2\u306b\u884c\u304c\u633f\u5165\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u306f\u3001\u6b21\u306b\u633f\u5165\u3055\u308c\u308b\u884c\u306b\u306f <span class=\"parameter\">new_reseed_value<\/span>\u00a0+ \u5897\u5206\u5024 \u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u30c6\u30fc\u30d6\u30eb\u304c\u7a7a\u3067\u306a\u3044\u5834\u5408\u306b\u3001ID \u5024\u306b ID \u5217\u306e\u6700\u5927\u5024\u3088\u308a\u5c0f\u3055\u306a\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u3001<br \/>\n\u25cbID \u5217\u306b PRIMARY KEY \u5236\u7d04\u307e\u305f\u306f UNIQUE \u5236\u7d04\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u751f\u6210\u3055\u308c\u308b ID \u5024\u3068\u65e2\u5b58\u306e\u5024\u3068\u306e\u7af6\u5408\u304c\u539f\u56e0\u3067\u3001\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3059\u308b\u5f8c\u7d9a\u306e\u633f\u5165\u64cd\u4f5c\u3067\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<br \/>\n\u25cbPRIMARY KEY \u5236\u7d04\u307e\u305f\u306f UNIQUE \u5236\u7d04\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3001\u5f8c\u7d9a\u306e\u633f\u5165\u64cd\u4f5c\u3067\u91cd\u8907\u3057\u305f ID \u5024\u304c\u633f\u5165\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u610f\u5916\u3068\u5fd8\u308c\u304c\u3061\u3067\u3059\u304c\u3001CHECKIDENT\u00a0\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001<\/p>\n<blockquote><p>\u547c\u3073\u51fa\u3057\u5143\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u3092\u6240\u6709\u3057\u3066\u3044\u308b\u304b\u3001<span class=\"input\">sysadmin<\/span> \u56fa\u5b9a\u30b5\u30fc\u30d0\u30fc \u30ed\u30fc\u30eb\u3001<span class=\"input\">db_owner<\/span> \u56fa\u5b9a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9 \u30ed\u30fc\u30eb\u3001\u307e\u305f\u306f <span class=\"input\">db_ddladmin<\/span> \u56fa\u5b9a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9 \u30ed\u30fc\u30eb\u306e\u30e1\u30f3\u30d0\u30fc\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>\u53c2\u7167\u5143\uff1aMSDN<br \/>\n<a title=\"DBCC CHECKIDENT (Transact-SQL)\" href=\"http:\/\/technet.microsoft.com\/ja-jp\/library\/ms176057.aspx\" target=\"_blank\">DBCC CHECKIDENT (Transact-SQL)<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5206\u7528\u30e1\u30e2\u3067\u3059\u3002 SQL Server \u3067 IDENTITY \u6307\u5b9a\u306eID\u5217\u3092\u4f5c\u6210\u3057\u305f\u5834\u5408\u3001\u30c6\u30fc\u30d6\u30eb\u521d\u671f\u5316\u3068\u30c7\u30fc\u30bf\u306e\u5165\u308c\u306a\u304a\u3057\u3092\u884c\u3046\u3068\u540c\u6642\u306b\u30b7\u30fc\u30c9\u5024\u3082\u30ea\u30bb\u30c3\u30c8\u3059\u308b\u5834\u5408\u306b\u306f\u3001\u300cBCC CHECKIDENT\u300d\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-612","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"_links":{"self":[{"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/posts\/612","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/comments?post=612"}],"version-history":[{"count":3,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/posts\/612\/revisions"}],"predecessor-version":[{"id":615,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/posts\/612\/revisions\/615"}],"wp:attachment":[{"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/media?parent=612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/categories?post=612"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/astel-labs.net\/blog\/diary\/wp-json\/wp\/v2\/tags?post=612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}