{"id":11634,"date":"2020-08-14T16:32:32","date_gmt":"2020-08-14T07:32:32","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=11634"},"modified":"2023-05-28T08:30:24","modified_gmt":"2023-05-27T23:30:24","slug":"%e3%80%90db%e3%82%b9%e3%83%9a%e3%82%b7%e3%83%a3%e3%83%aa%e3%82%b9%e3%83%88%e3%80%91%e3%80%8c%e3%83%88%e3%83%aa%e3%82%ac%e3%80%8d%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=11634","title":{"rendered":"\u3010DB\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8\u3011\u300c\u30c8\u30ea\u30ac\u300d\u306b\u3064\u3044\u3066"},"content":{"rendered":"<h2>\u30c8\u30ea\u30ac\u3068\u306f\uff1f<\/h2>\n<p>\u7279\u5b9a\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3059\u308b\u64cd\u4f5c\uff08\u633f\u5165\u30fb\u66f4\u65b0\u30fb\u524a\u9664\uff09\u3092\u30c8\u30ea\u30ac\u30fc\u3068\u3057\u3066\u3001\u3042\u3089\u304b\u3058\u3081\u5b9a\u7fa9\u3055\u308c\u305f\u51e6\u7406\u3092\u81ea\u52d5\u7684\u306b\u5b9f\u884c\u3059\u308b\u6a5f\u80fd\u306e\u3053\u3068\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u304c\u66f4\u65b0\u3055\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u62c5\u5f53\u8005\u30c6\u30fc\u30d6\u30eb\u3082\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u305b\u308b\u3088\u3046\u306b\u3059\u308b\u7b49\u3067\u3059\u3002<\/p>\n<h2>\u30e1\u30ea\u30c3\u30c8<\/h2>\n<p>\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3092\u4fdd\u3064\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2>\u30c7\u30e1\u30ea\u30c3\u30c8<\/h2>\n<p>\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u304c\u30a2\u30d7\u30ea\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u5206\u6563\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u306a\u306e\u3067\u57fa\u672c\u7684\u306b<span style=\"color: #ff0000;\"><strong>\u30c8\u30ea\u30ac\u306f\u4f7f\u308f\u306a\u3044\u65b9\u304c\u826f\u3044<\/strong><\/span>\u3068\u8a00\u308f\u308c\u3066\u3044\u307e\u3059\u3002\u300c\u305d\u3053\u306b\u30ed\u30b8\u30c3\u30af\u304c\u3042\u3063\u305f\u306e\u304b\u3042\u300d\u3068\u30a2\u30d7\u30ea\u306e\u5b9f\u88c5\u30b3\u30fc\u30c9\u3060\u3051\u8aad\u3093\u3067\u3044\u3066\u3082\u6c17\u3065\u304f\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u3067\u3059\u304b\u3089\u306d\u3002<\/p>\n<p>\u305f\u3060\u3001\u6614\u304b\u3089\u306e\u30b7\u30b9\u30c6\u30e0\u3068\u304b\u3067\u3042\u308c\u3070\u30c8\u30ea\u30ac\u30fc\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3057\u3066\u3042\u308b\u3068\u3044\u3046\u30b1\u30fc\u30b9\u3082\u5c11\u306a\u304f\u306a\u3044\u306e\u3067\u5b58\u5728\u3060\u3051\u306f\u77e5\u3063\u3066\u304a\u3044\u3066\u3082\u3057\u5229\u7528\u3055\u308c\u3066\u3044\u305f\u5834\u5408\u306b\u3042\u308b\u7a0b\u5ea6\u306f\u8ffd\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u5fc3\u69cb\u3048\u306f\u91cd\u8981\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>\u7528\u9014<\/h2>\n<table>\n<tbody>\n<tr>\n<th>\u7528\u9014<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>\u30a4\u30d9\u30f3\u30c8\u30ed\u30ae\u30f3\u30b0<\/td>\n<td>\u76e3\u67fb\u3084\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u8981\u4ef6\u5b9f\u73fe\u306e\u305f\u3081<\/td>\n<\/tr>\n<tr>\n<td>\u30d3\u30b8\u30cd\u30b9\u30eb\u30fc\u30eb\u306e\u5b9f\u73fe<\/td>\n<td>\u4f55\u3089\u304b\u306e\u7406\u7531\u3067\u30a2\u30d7\u30ea\u5074\u3067\u306f\u306a\u304fRDBMS\u5074\u3067\u51e6\u7406\u3092\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u30bf\u30a4\u30df\u30f3\u30b0<\/h2>\n<p>\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u76f4\u524d\u3068\u76f4\u5f8c\u306b\u305d\u308c\u305e\u308c\u30c8\u30ea\u30ac\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2>\u69cb\u6587<\/h2>\n<pre class=\"lang:default decode:true\">CREATE\r\n    TRIGGER \u30c8\u30ea\u30ac\u30fc\u540d\r\n    (BEFORE | AFTER) (INSERT\/UPDATE\/DELETE) \r\n    OF \u5bfe\u8c61\u5217 ON \u5bfe\u8c61\u306e\u30c6\u30fc\u30d6\u30eb\r\n    REFERENCING (NEW\/OLD) ROW AS \u884c\u306e\u5225\u540d\r\n    FOR EACH (ROW\/STATEMENT)\r\n    WHEN (\u6761\u4ef6\u5f0f\uff1aREFERENCING\u3067\u5b9a\u7fa9\u3057\u305f\u5225\u540d\u3092\u4f7f\u3048\u308b\u3002)\r\n    BEGIN\r\n      \u30c8\u30ea\u30ac\u3067\u5b9f\u884c\u3057\u305f\u3044SQL\r\n    END<\/pre>\n<h3>OF \u5bfe\u8c61\u5217 ON \u5bfe\u8c61\u306e\u30c6\u30fc\u30d6\u30eb<\/h3>\n<p>\u5bfe\u8c61\u30c6\u30fc\u30d6\u30eb\u306e\u5bfe\u8c61\u5217\u304c\u66f4\u65b0\u3055\u308c\u305f\u969b\u306b\u30c8\u30ea\u30ac\u3092\u767a\u52d5\u3055\u305b\u308c\u307e\u3059\u3002OF\u3092\u7701\u3044\u305f\u3089\u5bfe\u8c61\u30c6\u30fc\u30d6\u30eb\u3060\u3051\u306b\u7bc4\u56f2\u3092\u5e83\u3052\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>REFERENCING (NEW\/OLD) ROW AS \u884c\u306e\u5225\u540d<\/h3>\n<p>NEW\u3067\u3042\u308c\u3070\u64cd\u4f5c\u5f8c\u306e\u884c\u3001OLD\u3067\u3042\u308c\u3070\u64cd\u4f5c\u524d\u306e\u884c\u306b\u5bfe\u3059\u308b\u5225\u540d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u5f8c\u7d9a\u306eWHEN\u7b49\u3067\u30c8\u30ea\u30ac\u3092\u5b9f\u884c\u3059\u308b\u969b\u306e\u6761\u4ef6\u7b49\u3092\u6307\u5b9a\u3059\u308b\u5834\u5408\u306f\u6d3b\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>FOR EACH (ROW\/STATEMENT)<\/h3>\n<h4>ROW<\/h4>\n<p>\u884c\u3054\u3068\u306b\u30c8\u30ea\u30ac \u3092\u5b9f\u884c\u3057\u307e\u3059\u30021\u56de\u306eSQL\u3067\u884c\u3054\u3068\u306b\u8907\u6570\u56de\u30c8\u30ea\u30ac \u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h4>STATEMENT<\/h4>\n<p>\u4e00\u56de\u306eSQL\u306b\u5bfe\u3057\u30661\u56de\u306e\u307f\u30c8\u30ea\u30ac \u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<h3>WHEN (\u6761\u4ef6\u5f0f\uff1aREFERENCING\u3067\u5b9a\u7fa9\u3057\u305f\u5225\u540d\u3092\u4f7f\u3048\u308b\u3002)<\/h3>\n<p>\u30c8\u30ea\u30ac\u3092\u5b9f\u884c\u3059\u308b\u6761\u4ef6\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u30c8\u30ea\u30ac\u3068\u306f\uff1f \u7279\u5b9a\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3059\u308b\u64cd\u4f5c\uff08\u633f\u5165\u30fb\u66f4\u65b0\u30fb\u524a\u9664\uff09\u3092\u30c8\u30ea\u30ac\u30fc\u3068\u3057\u3066\u3001\u3042\u3089\u304b\u3058\u3081\u5b9a\u7fa9\u3055\u308c\u305f\u51e6\u7406\u3092\u81ea\u52d5\u7684\u306b\u5b9f\u884c\u3059\u308b\u6a5f\u80fd\u306e\u3053\u3068\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u304c\u66f4\u65b0\u3055\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u62c5\u5f53\u8005\u30c6\u30fc\u30d6\u30eb\u3082\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u305b\u308b\u3088\u3046\u306b [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11634"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11634"}],"version-history":[{"count":6,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11634\/revisions"}],"predecessor-version":[{"id":20755,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/11634\/revisions\/20755"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11634"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}