{"id":5531,"date":"2025-07-31T20:38:53","date_gmt":"2025-07-31T11:38:53","guid":{"rendered":"https:\/\/sky-peace.net\/?p=5531"},"modified":"2025-07-31T20:38:53","modified_gmt":"2025-07-31T11:38:53","slug":"sql-not-select","status":"publish","type":"post","link":"https:\/\/sky-peace.net\/certified\/sql-not-select\/","title":{"rendered":"SELECT \u4ee5\u5916\u306e SQL \u5b8c\u5168\u30ac\u30a4\u30c9\uff5cCREATE\u30fbUPDATE\u30fb\u5236\u7d04\u30fbRESTRICT \u306e\u5348\u5f8c\u8a66\u9a13\u5bfe\u7b56"},"content":{"rendered":"<p>SQL \u3068\u3044\u3048\u3070 <code>SELECT<\/code> \u53e5\u3070\u304b\u308a\u306b\u76ee\u304c\u884c\u304d\u304c\u3061\u3067\u3059\u304c\u3001\u5b9f\u52d9\u3067\u672c\u5f53\u306b\u6c42\u3081\u3089\u308c\u308b\u306e\u306f\u300c\u30c6\u30fc\u30d6\u30eb\u3092\u8a2d\u8a08\u30fb\u64cd\u4f5c\u3067\u304d\u308b\u30b9\u30ad\u30eb\u300d\u3067\u3059\u3002<br \/>\n<code>CREATE TABLE<\/code> \u3067\u65b0\u305f\u306a\u30c6\u30fc\u30d6\u30eb\u3092\u5b9a\u7fa9\u3057\u3001<code>ALTER TABLE<\/code> \u3067\u5217\u3084\u5236\u7d04\u3092\u8ffd\u52a0\u30fb\u5909\u66f4\u3057\u3001<code>INSERT<\/code> \u3084 <code>UPDATE<\/code> \u3067\u30c7\u30fc\u30bf\u3092\u64cd\u4f5c\u3059\u308b\u2500\u2500\u3053\u308c\u3089\u306f\u3044\u305a\u308c\u3082\u3001<strong>\u300c\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u6271\u3046\u529b\u300d\u305d\u306e\u3082\u306e<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u7279\u306b IPA \u7cfb\u8a66\u9a13\uff08\u57fa\u672c\u60c5\u5831\u30fb\u5fdc\u7528\u60c5\u5831\u30fb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8\u306a\u3069\uff09\u306e\u5348\u5f8c\u554f\u984c\u3067\u306f\u3001\u300cSELECT \u4ee5\u5916\u300d\u306e SQL \u3092\u4f7f\u3063\u3066<strong>\u30c6\u30fc\u30d6\u30eb\u8a2d\u8a08\u306e\u77e5\u8b58\u3084\u30c7\u30fc\u30bf\u64cd\u4f5c\u306e\u6d41\u308c<\/strong>\u3092\u554f\u3046\u554f\u984c\u304c\u983b\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5358\u306b\u69cb\u6587\u3092\u899a\u3048\u308b\u3060\u3051\u3067\u306a\u304f\u3001\u300c\u3053\u306e\u5834\u9762\u3067\u306f\u3053\u306e\u547d\u4ee4\u3092\u3069\u3046\u4f7f\u3046\u3079\u304d\u304b\uff1f\u300d\u3068\u3044\u3046\u6587\u8108\u7406\u89e3\u304c\u554f\u308f\u308c\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001<code>CREATE<\/code>\u3001<code>ALTER<\/code>\u3001<code>DROP<\/code>\u3001<code>INSERT<\/code>\u3001<code>UPDATE<\/code>\u3001<code>DELETE<\/code> \u306a\u3069\u3001<strong>SELECT \u4ee5\u5916\u306e\u4e3b\u8981 SQL \u69cb\u6587<\/strong>\u3092\u5b9f\u52d9\u30fb\u8a66\u9a13\u306e\u4e21\u9762\u304b\u3089\u4f53\u7cfb\u7684\u306b\u6574\u7406\u3057\u3001\u305d\u308c\u305e\u308c\u306b<strong>\u73fe\u5834\u7684\u306a\u4f7f\u7528\u4f8b<\/strong>\u3082\u6dfb\u3048\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u7279\u306b\u300c\u5236\u7d04\uff08\u5236\u9650\uff09\u300d\u3084\u300c\u53c2\u7167\u6574\u5408\u6027\uff08FOREIGN KEY\uff09\u300d\u306a\u3069\u3001\u521d\u5fc3\u8005\u304c\u6df7\u4e71\u3057\u3084\u3059\u3044\u30dd\u30a4\u30f3\u30c8\u306f\u3001\u56f3\u3084\u5177\u4f53\u7684\u306a\u30c6\u30fc\u30d6\u30eb\u4f8b\u3067\u4e01\u5be7\u306b\u88dc\u8db3\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u69cb\u6587\u306e\u57fa\u672c\u2502CREATE TABLE\u30fbALTER TABLE\u30fbDROP \u306e\u4f7f\u3044\u65b9\u3068\u6ce8\u610f\u70b9<\/h2>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u304a\u3051\u308b\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u306f\u3001\u300c\u8a2d\u8a08\u56f3\u4f5c\u308a\u300d\u306b\u76f8\u5f53\u3057\u307e\u3059\u3002<br \/>\n\u3069\u3093\u306a\u9805\u76ee\uff08\u5217\uff09\u304c\u3042\u308b\u306e\u304b\u3001\u4e3b\u30ad\u30fc\u306f\u4f55\u304b\u3001\u4ed6\u306e\u30c6\u30fc\u30d6\u30eb\u3068\u3069\u3046\u95a2\u9023\u3059\u308b\u304b\u2500\u2500\u3053\u308c\u3089\u3092\u6b63\u3057\u304f\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3067\u3001\u5f8c\u7d9a\u306e\u30c7\u30fc\u30bf\u64cd\u4f5c\u3084\u691c\u7d22\u306e\u52b9\u7387\u30fb\u6574\u5408\u6027\u304c\u6c7a\u307e\u308a\u307e\u3059\u3002<\/p>\n<h3>&#x1f4d8; CREATE TABLE\uff1a\u65b0\u3057\u3044\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b<\/h3>\n<pre><code>CREATE TABLE \u793e\u54e1 (\n  \u793e\u54e1ID INT PRIMARY KEY,\n  \u6c0f\u540d VARCHAR(50),\n  \u90e8\u7f72ID INT,\n  \u5165\u793e\u65e5 DATE\n);<\/code><\/pre>\n<ul>\n<li><code>PRIMARY KEY<\/code> \u3067\u4e3b\u30ad\u30fc\u3092\u6307\u5b9a<\/li>\n<li>\u30c7\u30fc\u30bf\u578b\uff08INT, VARCHAR, DATE\u306a\u3069\uff09\u3092\u660e\u793a<\/li>\n<li>\u30c6\u30fc\u30d6\u30eb\u8a2d\u8a08\u306e\u6700\u521d\u306e\u30b9\u30c6\u30c3\u30d7<\/li>\n<\/ul>\n<h3>&#x1f4d8; ALTER TABLE\uff1a\u65e2\u5b58\u30c6\u30fc\u30d6\u30eb\u3092\u5909\u66f4\u3059\u308b<\/h3>\n<pre><code>ALTER TABLE \u793e\u54e1 ADD \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9 VARCHAR(100);<\/code><\/pre>\n<p>\u5236\u7d04\u8ffd\u52a0\u306e\u4f8b\uff1a<\/p>\n<pre><code>ALTER TABLE \u793e\u54e1 ADD CONSTRAINT fk_\u90e8\u7f72\nFOREIGN KEY (\u90e8\u7f72ID) REFERENCES \u90e8\u7f72(\u90e8\u7f72ID);<\/code><\/pre>\n<ul>\n<li>\u5217\u306e\u8ffd\u52a0\u3001\u524a\u9664\u3001\u5236\u7d04\u306e\u8ffd\u52a0\u306a\u3069\u306b\u4f7f\u7528<\/li>\n<li>\u8a66\u9a13\u3067\u306f\u300c\u5916\u90e8\u30ad\u30fc\u5236\u7d04\u3092\u5f8c\u304b\u3089\u8ffd\u52a0\u3059\u308b\u300d\u30b1\u30fc\u30b9\u304c\u983b\u51fa<\/li>\n<\/ul>\n<h3>&#x1f4d8; DROP TABLE\uff1a\u30c6\u30fc\u30d6\u30eb\u3092\u5b8c\u5168\u306b\u524a\u9664\u3059\u308b<\/h3>\n<pre><code>DROP TABLE \u793e\u54e1;<\/code><\/pre>\n<ul>\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\uff0b\u4e2d\u306e\u30c7\u30fc\u30bf\u3082\u3059\u3079\u3066\u524a\u9664<\/strong><\/li>\n<li>\u8aa4\u3063\u3066\u5b9f\u884c\u3059\u308b\u3068\u5fa9\u5143\u56f0\u96e3\u306a\u306e\u3067\u6ce8\u610f<\/li>\n<\/ul>\n<h3>&#x2705; \u8a66\u9a13\u3068\u5b9f\u52d9\u3067\u306e\u30dd\u30a4\u30f3\u30c8\u6574\u7406\uff08\u8868\uff09<\/h3>\n<table border=\"1\">\n<thead>\n<tr>\n<th>\u69cb\u6587<\/th>\n<th>\u4e3b\u306a\u7528\u9014<\/th>\n<th>\u8a66\u9a13\u3067\u306e\u6ce8\u610f\u70b9<\/th>\n<th>\u5b9f\u52d9\u3067\u306e\u6ce8\u610f\u70b9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>CREATE<\/td>\n<td>\u30c6\u30fc\u30d6\u30eb\u65b0\u898f\u4f5c\u6210<\/td>\n<td>\u4e3b\u30ad\u30fc\u30fb\u30c7\u30fc\u30bf\u578b\u306e\u6307\u5b9a<\/td>\n<td>\u8a2d\u8a08\u30df\u30b9\u306f\u5f8c\u304b\u3089\u4fee\u6b63\u56f0\u96e3<\/td>\n<\/tr>\n<tr>\n<td>ALTER<\/td>\n<td>\u30c6\u30fc\u30d6\u30eb\u5909\u66f4<\/td>\n<td>\u5916\u90e8\u30ad\u30fc\u8ffd\u52a0\u306a\u3069\u51fa\u984c\u591a<\/td>\n<td>\u65e2\u5b58\u30c7\u30fc\u30bf\u3078\u306e\u5f71\u97ff\u3092\u78ba\u8a8d<\/td>\n<\/tr>\n<tr>\n<td>DROP<\/td>\n<td>\u30c6\u30fc\u30d6\u30eb\u524a\u9664<\/td>\n<td>\u610f\u56f3\u78ba\u8a8d\u554f\u984c\u3067\u51fa\u984c<\/td>\n<td>\u5b9f\u52d9\u3067\u306f\u614e\u91cd\u306b\u6271\u3046\u3079\u304d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>SQL\u306e\u30c7\u30fc\u30bf\u64cd\u4f5c\u69cb\u6587\u2502INSERT\u30fbUPDATE\u30fbDELETE\u306e\u57fa\u672c\u3068\u5348\u5f8c\u8a66\u9a13\u3067\u306e\u51fa\u984c\u4f8b<\/h2>\n<p>\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u3063\u305f\u3060\u3051\u3067\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u6a5f\u80fd\u3057\u307e\u305b\u3093\u3002<br \/>\n\u305d\u3053\u306b\u300c\u30c7\u30fc\u30bf\u3092\u5165\u308c\u308b\u300d\u300c\u66f4\u65b0\u3059\u308b\u300d\u300c\u524a\u9664\u3059\u308b\u300d\u2500\u2500\u3053\u306e\u4e00\u9023\u306e\u6d41\u308c\u3092\u6271\u3046\u306e\u304c\u3001<code>INSERT<\/code>\u30fb<code>UPDATE<\/code>\u30fb<code>DELETE<\/code> \u3067\u3059\u3002<br \/>\n\u3053\u308c\u3089\u306f\u5b9f\u52d9\u3067\u3082\u983b\u7e41\u306b\u4f7f\u308f\u308c\u3001IPA \u8a66\u9a13\u306e\u5348\u5f8c\u554f\u984c\u3067\u306f\u3001<strong>\u30c7\u30fc\u30bf\u306e\u9077\u79fb\u3084\u5c65\u6b74\u306e\u8ffd\u8de1<\/strong>\u306a\u3069\u306e\u6587\u8108\u3067\u51fa\u984c\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>&#x1f4d8; INSERT\uff1a\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b<\/h3>\n<pre><code>INSERT INTO \u793e\u54e1 (\u793e\u54e1ID, \u6c0f\u540d, \u90e8\u7f72ID, \u5165\u793e\u65e5)\nVALUES (1001, '\u7530\u4e2d \u592a\u90ce', 2, '2023-04-01');<\/code><\/pre>\n<ul>\n<li>\u5fc5\u305a\u5217\u540d\u3068\u5024\u306e\u9806\u5e8f\u3092\u5408\u308f\u305b\u308b\u3053\u3068<\/li>\n<li><strong>NOT NULL \u5236\u7d04\u3084\u578b\u30df\u30b9\u30de\u30c3\u30c1<\/strong>\u3067\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3053\u3068\u3082<\/li>\n<\/ul>\n<h3>&#x1f4d8; UPDATE\uff1a\u65e2\u5b58\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b<\/h3>\n<pre><code>UPDATE \u793e\u54e1 SET \u90e8\u7f72ID = 3 WHERE \u793e\u54e1ID = 1001;<\/code><\/pre>\n<ul>\n<li><code>WHERE<\/code> \u304c\u629c\u3051\u308b\u3068<strong>\u5168\u884c\u66f4\u65b0<\/strong>\u3068\u3044\u3046\u81f4\u547d\u7684\u30df\u30b9\u306b<\/li>\n<li>\u8a66\u9a13\u3067\u306f\u300c\u4e00\u90e8\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3059\u30c7\u30fc\u30bf\u3060\u3051\u3092\u66f4\u65b0\u300d\u3059\u308b\u554f\u984c\u304c\u591a\u3044<\/li>\n<\/ul>\n<h3>&#x1f4d8; DELETE\uff1a\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b<\/h3>\n<pre><code>DELETE FROM \u793e\u54e1 WHERE \u793e\u54e1ID = 1001;<\/code><\/pre>\n<ul>\n<li><code>WHERE<\/code> \u3092\u5fd8\u308c\u308b\u3068<strong>\u30c6\u30fc\u30d6\u30eb\u5185\u3059\u3079\u3066\u524a\u9664<\/strong><\/li>\n<li>\u5916\u90e8\u30ad\u30fc\u5236\u7d04\u304c\u3042\u308b\u3068\u524a\u9664\u3067\u304d\u306a\u3044\u30b1\u30fc\u30b9\u3082\u3042\u308a\uff08\u5f8c\u8ff0\uff09<\/li>\n<\/ul>\n<h3>&#x2705; \u64cd\u4f5c\u7528\u69cb\u6587\u306e\u6bd4\u8f03\u8868<\/h3>\n<table border=\"1\">\n<thead>\n<tr>\n<th>\u69cb\u6587<\/th>\n<th>\u4e3b\u306a\u6a5f\u80fd<\/th>\n<th>\u8a66\u9a13\u3067\u306e\u6ce8\u610f\u70b9<\/th>\n<th>\u5b9f\u52d9\u3067\u306e\u6ce8\u610f\u70b9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>INSERT<\/td>\n<td>\u65b0\u898f\u30c7\u30fc\u30bf\u8ffd\u52a0<\/td>\n<td>\u5236\u7d04\u30fb\u578b\u30a8\u30e9\u30fc\u306e\u5224\u65ad<\/td>\n<td>\u81ea\u52d5\u63a1\u756a\u306e\u6271\u3044\u306b\u6ce8\u610f<\/td>\n<\/tr>\n<tr>\n<td>UPDATE<\/td>\n<td>\u4e00\u90e8\u30c7\u30fc\u30bf\u66f4\u65b0<\/td>\n<td>\u6761\u4ef6\u6307\u5b9a\u306e\u7cbe\u5ea6<\/td>\n<td>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u63a8\u5968<\/td>\n<\/tr>\n<tr>\n<td>DELETE<\/td>\n<td>\u30c7\u30fc\u30bf\u524a\u9664<\/td>\n<td>\u524a\u9664\u6761\u4ef6\u306e\u691c\u8a3c<\/td>\n<td>\u53c2\u7167\u6574\u5408\u6027\u306b\u5f71\u97ff\u3042\u308a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>SQL\u306e\u5236\u7d04\uff08\u5236\u9650\uff09\u69cb\u6587\u2502NOT NULL\u30fbUNIQUE\u30fb\u5916\u90e8\u30ad\u30fc\u306e\u610f\u5473\u3068\u5348\u5f8c\u8a66\u9a13\u3067\u306e\u6271\u3044<\/h2>\n<p>SQL \u306b\u304a\u3051\u308b\u300c\u5236\u7d04\uff08constraint\uff09\u300d\u306f\u3001<strong>\u30c7\u30fc\u30bf\u306e\u6b63\u3057\u3055\u3084\u6574\u5408\u6027\u3092\u4fdd\u8a3c\u3059\u308b\u305f\u3081\u306e\u30eb\u30fc\u30eb<\/strong>\u3067\u3059\u3002<br \/>\n\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u6642\u3084 ALTER TABLE \u3067\u8ffd\u52a0\u3057\u3001\u610f\u56f3\u3057\u306a\u3044\u91cd\u8907\u3084 NULL \u5024\u3001\u5916\u90e8\u30ad\u30fc\u9055\u53cd\u306a\u3069\u3092\u9632\u304e\u307e\u3059\u3002<\/p>\n<p>IPA \u8a66\u9a13\u3067\u306f\u300c\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u3067\u3069\u3093\u306a\u5165\u529b\u304c\u30a8\u30e9\u30fc\u306b\u306a\u308b\u304b\u300d\u300c\u53c2\u7167\u6574\u5408\u6027\u304c\u3069\u3046\u5f71\u97ff\u3059\u308b\u304b\u300d\u306a\u3069\u3001<strong>\u5236\u7d04\u306e\u610f\u5473\u3092\u6b63\u3057\u304f\u7406\u89e3\u3057\u3066\u3044\u308b\u304b<\/strong>\u304c\u3088\u304f\u554f\u308f\u308c\u307e\u3059\u3002<\/p>\n<h3>&#x1f4d8; NOT NULL\uff1aNULL\uff08\u7a7a\uff09\u3092\u7981\u6b62\u3059\u308b<\/h3>\n<pre><code>\u6c0f\u540d VARCHAR(50) NOT NULL<\/code><\/pre>\n<ul>\n<li>\u3053\u306e\u5217\u306b\u306f <strong>\u5fc5\u305a\u5024\u304c\u5fc5\u8981<\/strong><\/li>\n<li><code>INSERT<\/code> \u6642\u306b\u5024\u3092\u7701\u7565\u3059\u308b\u3068\u30a8\u30e9\u30fc<\/li>\n<li>\u8a66\u9a13\u3067\u306f\u300cNOT NULL \u5236\u7d04\u304c\u3042\u308b\u306e\u3067\u3053\u306e\u64cd\u4f5c\u306f\u5931\u6557\u3059\u308b\u300d\u306a\u3069\u306e\u51fa\u984c\u3042\u308a<\/li>\n<\/ul>\n<h3>&#x1f4d8; UNIQUE\uff1a\u91cd\u8907\u7981\u6b62<\/h3>\n<pre><code>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9 VARCHAR(100) UNIQUE<\/code><\/pre>\n<ul>\n<li>\u540c\u3058\u5024\u304c\u4ed6\u306e\u884c\u306b\u5b58\u5728\u3057\u3066\u306f\u3044\u3051\u306a\u3044<\/li>\n<li>\u4e3b\u30ad\u30fc\u307b\u3069\u53b3\u5bc6\u3067\u306f\u306a\u3044\u304c\u300c\u5019\u88dc\u30ad\u30fc\u300d\u6271\u3044\u3055\u308c\u308b\u3053\u3068\u3082<\/li>\n<\/ul>\n<h3>&#x1f4d8; CHECK\uff1a\u5024\u306b\u6761\u4ef6\u3092\u3064\u3051\u308b<\/h3>\n<pre><code>\u7d66\u4e0e INT CHECK (\u7d66\u4e0e > 0)<\/code><\/pre>\n<ul>\n<li>\u7279\u5b9a\u5217\u306b\u300c\u6b63\u306e\u5024\u306e\u307f\u300d\u306a\u3069\u306e\u30eb\u30fc\u30eb\u3092\u8ab2\u3059<\/li>\n<li>\u5b9f\u52d9\u3067\u306f\u3042\u307e\u308a\u4f7f\u308f\u308c\u306a\u3044\u304c\u3001\u8a66\u9a13\u3067\u306f\u5236\u7d04\u306b\u3088\u308b\u30a8\u30e9\u30fc\u5224\u65ad\u3067\u51fa\u984c\u3055\u308c\u308b<\/li>\n<\/ul>\n<h3>&#x1f4d8; PRIMARY KEY\uff1a\u884c\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u5217\uff08\u307e\u305f\u306f\u5217\u306e\u7d44\uff09<\/h3>\n<pre><code>\u793e\u54e1ID INT PRIMARY KEY<\/code><\/pre>\n<ul>\n<li><code>NOT NULL<\/code> \uff0b <code>UNIQUE<\/code> \u306e\u7d44\u307f\u5408\u308f\u305b<\/li>\n<li>\u30c6\u30fc\u30d6\u30eb\u3054\u3068\u306b <strong>1\u3064\u306e\u307f<\/strong> \u6307\u5b9a\u53ef\u80fd<\/li>\n<\/ul>\n<h3>&#x1f4d8; FOREIGN KEY\uff1a\u4ed6\u30c6\u30fc\u30d6\u30eb\u3068\u306e\u53c2\u7167\u6574\u5408\u6027\u3092\u4fdd\u3064<\/h3>\n<pre><code>\u90e8\u7f72ID INT,\nFOREIGN KEY (\u90e8\u7f72ID) REFERENCES \u90e8\u7f72(\u90e8\u7f72ID)<\/code><\/pre>\n<ul>\n<li>\u300c\u89aa\u30c6\u30fc\u30d6\u30eb\u306b\u5b58\u5728\u3057\u306a\u3044\u5024\u306f\u767b\u9332\u3067\u304d\u306a\u3044\u300d<\/li>\n<li><code>DELETE<\/code> \u3067\u304d\u306a\u3044\u30fb<code>UPDATE<\/code> \u306b\u5236\u9650\u304c\u304b\u304b\u308b\u306a\u3069\u3001<strong>\u9023\u52d5\u5236\u5fa1<\/strong>\u306e\u51fa\u984c\u304c\u591a\u3044<\/li>\n<\/ul>\n<h3>&#x2705; \u5236\u7d04\u69cb\u6587\u306e\u6bd4\u8f03\u8868<\/h3>\n<table border=\"1\">\n<thead>\n<tr>\n<th>\u5236\u7d04<\/th>\n<th>\u6a5f\u80fd<\/th>\n<th>\u4e3b\u306a\u7528\u9014<\/th>\n<th>\u8a66\u9a13\u3067\u306e\u51fa\u984c\u50be\u5411<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>NOT NULL<\/td>\n<td>NULL\u7981\u6b62<\/td>\n<td>\u5fc5\u9808\u5165\u529b\u6b04\u306e\u6307\u5b9a<\/td>\n<td>\u5165\u529b\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u3068\u3057\u3066\u51fa\u984c<\/td>\n<\/tr>\n<tr>\n<td>UNIQUE<\/td>\n<td>\u91cd\u8907\u7981\u6b62<\/td>\n<td>\u5019\u88dc\u30ad\u30fc\u306e\u5236\u7d04<\/td>\n<td>\u540c\u4e00\u30c7\u30fc\u30bf\u306e\u5236\u9650\u5224\u65ad<\/td>\n<\/tr>\n<tr>\n<td>CHECK<\/td>\n<td>\u6761\u4ef6\u4ed8\u304d\u5236\u9650<\/td>\n<td>\u6570\u5024\u5236\u9650\u3084\u7bc4\u56f2<\/td>\n<td>\u300c\u3053\u306e\u30c7\u30fc\u30bf\u306f\u633f\u5165\u3067\u304d\u308b\u304b\uff1f\u300d\u5224\u65ad\u554f\u984c<\/td>\n<\/tr>\n<tr>\n<td>PRIMARY KEY<\/td>\n<td>\u4e3b\u30ad\u30fc\u6307\u5b9a<\/td>\n<td>\u884c\u306e\u4e00\u610f\u6027\u4fdd\u8a3c<\/td>\n<td>\u8907\u5408\u30ad\u30fc\u30fb\u4e3b\u30ad\u30fc\u5224\u5b9a\u554f\u984c<\/td>\n<\/tr>\n<tr>\n<td>FOREIGN KEY<\/td>\n<td>\u5916\u90e8\u30ad\u30fc\u53c2\u7167<\/td>\n<td>\u4ed6\u30c6\u30fc\u30d6\u30eb\u3068\u306e\u6574\u5408\u6027<\/td>\n<td>\u524a\u9664\u30fb\u66f4\u65b0\u6642\u306e\u5f71\u97ff\u5206\u6790\u554f\u984c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>RESTRICT\u30fbCASCADE\u30fbSET NULL\u3068\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u5236\u5fa1\u2502\u5348\u5f8c\u8a66\u9a13\u3067\u983b\u51fa\u306e\u6574\u5408\u6027\u30aa\u30d7\u30b7\u30e7\u30f3<\/h2>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306b\u5916\u90e8\u30ad\u30fc\u5236\u7d04\u304c\u3042\u308b\u5834\u5408\u3001<strong>\u95a2\u9023\u3059\u308b\u30c7\u30fc\u30bf\u3092\u524a\u9664\u30fb\u66f4\u65b0\u3057\u305f\u969b\u306b\u3069\u3046\u53cd\u5fdc\u3059\u308b\u304b<\/strong>\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u305d\u308c\u304c <code>ON DELETE<\/code> \u3084 <code>ON UPDATE<\/code> \u306b\u6307\u5b9a\u3055\u308c\u308b\u300cRESTRICT\u300d\u300cCASCADE\u300d\u300cSET NULL\u300d\u306a\u3069\u306e<strong>\u6574\u5408\u6027\u30aa\u30d7\u30b7\u30e7\u30f3<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001<code>COMMIT<\/code> \u3084 <code>ROLLBACK<\/code> \u3092\u7528\u3044\u305f\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u5236\u5fa1\u3082\u8a66\u9a13\u3067\u306f\u983b\u51fa\u3067\u3059\u3002<br \/>\n\u3053\u3053\u3067\u306f\u3001<strong>\u30c7\u30fc\u30bf\u6574\u5408\u6027\u306e\u78ba\u4fdd<\/strong>\u3068\u3044\u3046\u89b3\u70b9\u304b\u3089\u3001\u3053\u308c\u3089\u306e\u6a5f\u80fd\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h3>&#x1f4d8; RESTRICT\uff1a\u5236\u9650\uff08\u524a\u9664\u30fb\u66f4\u65b0\u3092\u7981\u6b62\uff09<\/h3>\n<pre><code>FOREIGN KEY (\u90e8\u7f72ID)\nREFERENCES \u90e8\u7f72(\u90e8\u7f72ID)\nON DELETE RESTRICT<\/code><\/pre>\n<ul>\n<li><strong>\u89aa\u30c6\u30fc\u30d6\u30eb\u306e\u8a72\u5f53\u884c\u3092\u524a\u9664\u30fb\u66f4\u65b0\u3067\u304d\u306a\u3044<\/strong><\/li>\n<li>\u5b50\u30c6\u30fc\u30d6\u30eb\u306b\u95a2\u9023\u30c7\u30fc\u30bf\u304c\u3042\u308b\u3068\u30a8\u30e9\u30fc<\/li>\n<li>\u8a66\u9a13\u3067\u306f\u300c\u30a8\u30e9\u30fc\u306b\u306a\u308b\u64cd\u4f5c\u306f\u3069\u308c\u304b\u300d\u3067\u3088\u304f\u554f\u308f\u308c\u308b<\/li>\n<\/ul>\n<h3>&#x1f4d8; CASCADE\uff1a\u9023\u52d5\u3057\u3066\u524a\u9664\u30fb\u66f4\u65b0<\/h3>\n<pre><code>ON DELETE CASCADE<\/code><\/pre>\n<ul>\n<li>\u89aa\u304c\u524a\u9664\u3055\u308c\u308b\u3068\u3001<strong>\u5b50\u3082\u81ea\u52d5\u3067\u524a\u9664\u3055\u308c\u308b<\/strong><\/li>\n<li>UPDATE \u3067\u3082\u9023\u52d5\u53ef\uff08<code>ON UPDATE CASCADE<\/code>\uff09<\/li>\n<li>\u5b9f\u52d9\u3067\u306f\u4f7f\u3044\u6240\u3092\u8aa4\u308b\u3068\u300c\u4e88\u671f\u3057\u306a\u3044\u5927\u91cf\u524a\u9664\u300d\u306e\u539f\u56e0\u306b<\/li>\n<\/ul>\n<h3>&#x1f4d8; SET NULL\uff1a\u5b50\u3092 NULL \u306b\u3059\u308b<\/h3>\n<pre><code>ON DELETE SET NULL<\/code><\/pre>\n<ul>\n<li>\u89aa\u304c\u524a\u9664\u3055\u308c\u308b\u3068\u3001\u5b50\u306e\u5916\u90e8\u30ad\u30fc\u5217\u3092 NULL \u306b<\/li>\n<li>\u5b50\u30c6\u30fc\u30d6\u30eb\u5074\u304c <code>NOT NULL<\/code> \u5236\u7d04\u3092\u6301\u3063\u3066\u3044\u308b\u3068\u30a8\u30e9\u30fc<\/li>\n<\/ul>\n<h3>&#x2705; \u6574\u5408\u6027\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u6bd4\u8f03\u8868<\/h3>\n<table border=\"1\">\n<thead>\n<tr>\n<th>\u30aa\u30d7\u30b7\u30e7\u30f3<\/th>\n<th>\u52d5\u4f5c<\/th>\n<th>\u5b89\u5168\u6027<\/th>\n<th>\u8a66\u9a13\u306e\u51fa\u984c\u30dd\u30a4\u30f3\u30c8<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>RESTRICT<\/td>\n<td>\u5b50\u304c\u5b58\u5728 \u2192 \u89aa\u3092\u524a\u9664\u4e0d\u53ef<\/td>\n<td>\u9ad8\u3044<\/td>\n<td>\u300c\u30a8\u30e9\u30fc\u3068\u306a\u308b\u64cd\u4f5c\u306f\u3069\u308c\u304b\u300d\u7cfb<\/td>\n<\/tr>\n<tr>\n<td>CASCADE<\/td>\n<td>\u89aa\u524a\u9664 \u2192 \u5b50\u3082\u524a\u9664<\/td>\n<td>\u4f4e\u3044\uff08\u8aa4\u64cd\u4f5c\u306b\u6ce8\u610f\uff09<\/td>\n<td>\u9023\u52d5\u524a\u9664\u30fb\u66f4\u65b0\u306e\u53ef\u5426<\/td>\n<\/tr>\n<tr>\n<td>SET NULL<\/td>\n<td>\u5b50\u306e\u5916\u90e8\u30ad\u30fc\u3092NULL\u306b<\/td>\n<td>\u4e2d\uff08NULL\u8a31\u5bb9\u304c\u6761\u4ef6\uff09<\/td>\n<td>NOT NULL\u5236\u7d04\u3068\u306e\u7d44\u307f\u5408\u308f\u305b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>&#x1f4d8; \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u5236\u5fa1\uff1a\u51e6\u7406\u306e\u300c\u3072\u3068\u307e\u3068\u307e\u308a\u300d\u3092\u4fdd\u8a3c<\/h3>\n<pre><code>BEGIN;\nUPDATE \u53e3\u5ea7 SET \u6b8b\u9ad8 = \u6b8b\u9ad8 - 10000 WHERE \u53e3\u5ea7ID = 1;\nUPDATE \u53e3\u5ea7 SET \u6b8b\u9ad8 = \u6b8b\u9ad8 + 10000 WHERE \u53e3\u5ea7ID = 2;\nCOMMIT;<\/code><\/pre>\n<ul>\n<li>\u8907\u6570\u306e\u64cd\u4f5c\u3092\u300c\u4e00\u62ec\u51e6\u7406\u300d\u3059\u308b\u67a0\u7d44\u307f<\/li>\n<li>\u4e00\u90e8\u5931\u6557\u3057\u305f\u5834\u5408\u306b\u5168\u4f53\u3092\u7121\u52b9\u306b\u3059\u308b\u306b\u306f <code>ROLLBACK<\/code> \u3092\u4f7f\u3046<\/li>\n<li>\u8a66\u9a13\u3067\u306f\u300c\u9014\u4e2d\u3067\u30a8\u30e9\u30fc \u2192 ROLLBACK\u3055\u308c\u308b\uff1f\u300d\u3068\u3044\u3046\u5f62\u5f0f\u3067\u554f\u308f\u308c\u308b<\/li>\n<\/ul>\n<h2>\u307e\u3068\u3081\u2502\u5348\u5f8c\u8a66\u9a13\u3067\u554f\u308f\u308c\u308bSQL\u69cb\u6587\u3092\u5b9f\u52d9\u76ee\u7dda\u3067\u6574\u7406<\/h2>\n<p>SQL \u3092\u4f7f\u3044\u3053\u306a\u3059\u306b\u306f\u3001<code>SELECT<\/code> \u53e5\u3060\u3051\u3067\u306a\u304f\u3001<strong>\u30c6\u30fc\u30d6\u30eb\u3084\u30c7\u30fc\u30bf\u306e\u8a2d\u8a08\u30fb\u64cd\u4f5c\u306b\u95a2\u308f\u308b\u69cb\u6587\u7fa4<\/strong>\u3092\u6b63\u3057\u304f\u7406\u89e3\u3057\u3066\u304a\u304f\u3053\u3068\u304c\u4e0d\u53ef\u6b20\u3067\u3059\u3002<br \/>\n\u7279\u306b IPA \u306e\u5348\u5f8c\u8a66\u9a13\u3067\u306f\u3001\u300c\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u30fb\u5236\u7d04\u30fb\u30c7\u30fc\u30bf\u64cd\u4f5c\u30fb\u6574\u5408\u6027\u306e\u4fdd\u8a3c\u300d\u306b\u95a2\u3059\u308b\u77e5\u8b58\u304c\u3001<strong>\u5b9f\u88c5\u306e\u6b63\u3057\u3055\u3084\u30c7\u30fc\u30bf\u54c1\u8cea\u306e\u7dad\u6301\u306b\u76f4\u7d50\u3059\u308b\u30b9\u30ad\u30eb<\/strong>\u3068\u3057\u3066\u8a55\u4fa1\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>&#x2705; \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8\u307e\u3068\u3081<\/h3>\n<ul>\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\uff1a<\/strong> <code>CREATE TABLE<\/code> \u3084 <code>ALTER TABLE<\/code> \u3092\u4f7f\u3063\u3066\u3001\u5217\u30fb\u4e3b\u30ad\u30fc\u30fb\u5236\u7d04\u3092\u5b9a\u7fa9<\/li>\n<li><strong>\u30c7\u30fc\u30bf\u64cd\u4f5c\uff1a<\/strong> <code>INSERT<\/code>\u3001<code>UPDATE<\/code>\u3001<code>DELETE<\/code> \u3067\u884c\u5358\u4f4d\u306e\u30c7\u30fc\u30bf\u3092\u5b89\u5168\u306b\u5909\u66f4<\/li>\n<li><strong>\u5236\u7d04\u306e\u6d3b\u7528\uff1a<\/strong> <code>NOT NULL<\/code>\u3001<code>UNIQUE<\/code>\u3001<code>PRIMARY KEY<\/code>\u3001<code>FOREIGN KEY<\/code> \u306a\u3069\u3067\u6574\u5408\u6027\u3092\u62c5\u4fdd<\/li>\n<li><strong>\u6574\u5408\u6027\u30aa\u30d7\u30b7\u30e7\u30f3\uff1a<\/strong> <code>RESTRICT<\/code>\u3001<code>CASCADE<\/code>\u3001<code>SET NULL<\/code> \u306b\u3088\u308a\u3001\u53c2\u7167\u95a2\u4fc2\u306e\u52d5\u4f5c\u3092\u660e\u793a<\/li>\n<li><strong>\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\uff1a<\/strong> <code>BEGIN<\/code>\uff5e<code>COMMIT<\/code> \/ <code>ROLLBACK<\/code> \u306b\u3088\u308b\u4e00\u62ec\u51e6\u7406\u3067\u5b89\u5168\u6027\u3092\u78ba\u4fdd<\/li>\n<\/ul>\n<p>\u5348\u5f8c\u8a66\u9a13\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u69cb\u6587\u306e\u300c\u610f\u5473\u300d\u3084\u300c\u5236\u7d04\u306b\u3088\u308b\u30a8\u30e9\u30fc\u306e\u6709\u7121\u300d\u300c\u64cd\u4f5c\u7d50\u679c\u300d\u306a\u3069\u3092\u3001<strong>\u6587\u8108\u306b\u5fdc\u3058\u3066\u5224\u65ad\u3059\u308b\u529b<\/strong>\u304c\u554f\u308f\u308c\u307e\u3059\u3002<br \/>\n\u69cb\u6587\u3092\u6697\u8a18\u3059\u308b\u3060\u3051\u3067\u306a\u304f\u3001<strong>\u306a\u305c\u305d\u306e\u5236\u7d04\u304c\u5fc5\u8981\u304b\u3001\u5b9f\u52d9\u3067\u3069\u3046\u4f7f\u3046\u304b<\/strong>\u307e\u3067\u610f\u8b58\u3059\u308b\u3053\u3068\u3067\u3001\u5fdc\u7528\u529b\u306e\u3042\u308b SQL \u30b9\u30ad\u30eb\u304c\u8eab\u306b\u3064\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL \u3068\u3044\u3048\u3070 SELECT \u53e5\u3070\u304b\u308a\u306b\u76ee\u304c\u884c\u304d\u304c\u3061\u3067\u3059\u304c\u3001\u5b9f\u52d9\u3067\u672c\u5f53\u306b\u6c42\u3081\u3089\u308c\u308b\u306e\u306f\u300c\u30c6\u30fc\u30d6\u30eb\u3092\u8a2d\u8a08\u30fb\u64cd\u4f5c\u3067\u304d\u308b\u30b9\u30ad\u30eb\u300d\u3067\u3059\u3002 CREATE TABLE \u3067\u65b0\u305f\u306a\u30c6\u30fc\u30d6\u30eb\u3092\u5b9a\u7fa9\u3057\u3001ALTER TA &#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","columnck":"","stmeta_robots":"index, follow","st_titlewords":"","st_title_extra":"","st_keywords":"","st_description":"","st_display_ad_mark":"","st_display_ad_mark_hide":"","textcopyck":"","st_copyright":"","st_copyurl":"","eyecatch_set":"","st_youtube_url":"","st_youtube_eyecatch":"","headerwidget_set":"","updatewidget_set":"","kanrenwidget_set":"","ikkatuwidget_set":"","koukoku_set":"","auto_adsense_koukoku_set":"","st_redirect":"","st_redirect_url_as_canonical":"","st_redirect_pvm_do_not_track":"","post_data_updatewidget_set":"","st_post_header_under_bg":"","st_twitter_tag":"","affinger_note":"","rankdisplayck":"","st_head_code":"","st_footer_code":"","st_post_header_under_code":"","_st_toc_override":false,"_st_toc_settings":[]},"categories":[3],"tags":[6],"class_list":["post-5531","post","type-post","status-publish","format-standard","hentry","category-ipa","tag-6"],"_links":{"self":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts\/5531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/comments?post=5531"}],"version-history":[{"count":0,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts\/5531\/revisions"}],"wp:attachment":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/media?parent=5531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/categories?post=5531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/tags?post=5531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}