{"id":4594,"date":"2024-02-23T16:14:21","date_gmt":"2024-02-23T07:14:21","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=4594"},"modified":"2024-02-23T18:47:05","modified_gmt":"2024-02-23T09:47:05","slug":"post-4594","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/4594","title":{"rendered":"MySQL\u3067\u4e00\u9023\u306e\u51e6\u7406\u3092\u95a2\u6570\u306e\u3088\u3046\u306b\u5b9f\u884c\u3067\u304d\u308b\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306e\u8a2d\u5b9a\u3068\u5229\u7528\u65b9\u6cd5"},"content":{"rendered":"<p>MySQL\u95a2\u9023\u306e\u30b5\u30a4\u30c8\u3092\u898b\u3066\u3044\u305f\u969b\u306b\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u304c\u4e91\u3005\u3068\u3044\u3046\u30da\u30fc\u30b8\u304c\u3042\u3063\u305f\u3002\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3068\u306f\u805e\u304d\u899a\u3048\u304c\u7121\u3044\u8a00\u8449\u306a\u306e\u3067\u8abf\u3079\u3066\u307f\u308b\u3068\u4e00\u9023\u306e\u51e6\u7406\u3092\u307e\u3068\u3081\u3066\u540d\u524d\u3092\u4ed8\u3051\u3066\u304a\u304d\u3001\u540d\u524d\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u5b9f\u884c\u3067\u304d\u308b\u3068\u3044\u3046\u95a2\u6570\u3063\u307d\u3044\u6a5f\u80fd\u306e\u6a21\u69d8\u3002\u4ee5\u4e0b\u306b\u8a2d\u5b9a\u3068\u5229\u7528\u65b9\u6cd5\u306e\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/h2>\n<p>\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u3092\u53c2\u7167\u3002<\/p>\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/ja\/stored-programs-defining.html\" target=\"_blank\" rel=\"noopener\">https:\/\/dev.mysql.com\/doc\/refman\/8.0\/ja\/stored-programs-defining.html<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u4e8b\u524d\u6e96\u5099<\/h2>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30c6\u30fc\u30d6\u30eb\u3092\u7528\u610f\u3057\u305f\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mysql&gt; SHOW COLUMNS FROM `test_table`;\r\n+------------+--------------+------+-----+---------+----------------+\r\n| Field      | Type         | Null | Key | Default | Extra          |\r\n+------------+--------------+------+-----+---------+----------------+\r\n| id         | int          | NO   | PRI | NULL    | auto_increment |\r\n| name       | varchar(255) | NO   |     | NULL    |                |\r\n| score      | int          | NO   |     | NULL    |                |\r\n| regist_ymd | datetime     | NO   |     | NULL    |                |\r\n+------------+--------------+------+-----+---------+----------------+<\/pre>\n<p>&nbsp;<\/p>\n<h2>\u8a2d\u5b9a\u65b9\u6cd5<\/h2>\n<h3>\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306e\u8ffd\u52a0<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELIMITER \/\/\r\nCREATE PROCEDURE test_procedure(IN name VARCHAR(255), IN score INT)\r\nBEGIN \r\n    INSERT INTO `test_table`\r\n    (\r\n        `name`,\r\n        `score`,\r\n        `regist_ymd`\r\n    ) \r\n    VALUES \r\n    (\r\n        name,\r\n        score,\r\n        now()\r\n    );\r\nEND\r\n\/\/\r\nDELIMITER ;<\/pre>\n<p>\u300ctest_procedure(\u540d\u524d,\u70b9\u6570)\u300d\u3092\u5b9f\u884c\u3059\u308b\u3068test_table\u30c6\u30fc\u30d6\u30eb\u306b\u300c\u540d\u524d,\u70b9\u6570,\u65e5\u6642\u300d\u304c\u683c\u7d0d\u3055\u308c\u308b\u3068\u3044\u3046\u5185\u5bb9\u306b\u306a\u308b\u3002<\/p>\n<h3>\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306e\u78ba\u8a8d<\/h3>\n<p>\u6b63\u5e38\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u306f\u4ee5\u4e0b\u3067\u78ba\u8a8d\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">SHOW CREATE PROCEDURE test_procedure;<\/pre>\n<h3>\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306e\u5b9f\u884c<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">CALL test_procedure('\u9234\u6728', 70);\r\n\r\nmysql&gt; select * from test_table;\r\n+----+-----------+-------+---------------------+\r\n| id | name      | score | regist_ymd          |\r\n+----+-----------+-------+---------------------+\r\n|  1 | \u4f50\u3005\u6728    |    80 | 2024-02-14 15:48:40 |\r\n+----+-----------+-------+---------------------+<\/pre>\n<p>\u6b63\u5e38\u306b\u30c7\u30fc\u30bf\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u70b9\u3092\u78ba\u8a8d\u3067\u304d\u308b\u3002\u5c1a\u3001\u5165\u529b\u5024\u306e\u30a8\u30b9\u30b1\u30fc\u30d7\u306fPHP\u5074\u3067\u3084\u308b\u5fc5\u8981\u304c\u3042\u308a\u305d\u3046(MySQL\u5074\u306e\u65b9\u6cd5\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f)\u3002<\/p>\n<h3>\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306e\u524a\u9664<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DROP PROCEDURE test_procedure;<\/pre>\n<p>&nbsp;<\/p>\n<h2>\u6240\u611f<\/h2>\n<p>\u901a\u5e38PHP\u304b\u3089MySQL\u306b\u5bfe\u3057\u3066\u8907\u6570\u306e\u51e6\u7406\u3092\u884c\u3046\u5834\u5408\u306f\u305d\u306e\u90fd\u5ea6\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u304c\u3001\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3092\u4f7f\u3046\u30681\u56de\u3067\u6e08\u3080\u306e\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u5411\u4e0a\u304c\u898b\u8fbc\u3081\u308b\u3002<\/p>\n<p>\u307e\u305f\u3001\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3068\u540c\u3058SQL\u6587\u3092PHP\u304b\u3089\u5b9f\u884c\u3059\u308b\u5834\u5408\u3001<a href=\"https:\/\/tech-begin.com\/computer-basic\/database\/stored-procedure\/#toc3\" target=\"_blank\" rel=\"noopener\">\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306e\u65b9\u304c\u5b9f\u884c\u901f\u5ea6\u306f\u901f\u3044\u3089\u3057\u3044<\/a>\u3002<\/p>\n<p>\u305f\u3060PHP\u5074\u3068\u306f\u5207\u308a\u96e2\u3055\u308c\u3066\u3057\u307e\u3046\u305f\u3081\u3001PHP\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u8aad\u3093\u3067\u3082\u3069\u306e\u3088\u3046\u306a\u51e6\u7406\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u306e\u304b\u5206\u304b\u3089\u306a\u3044\u3068\u3044\u3046\u306e\u306f\u3061\u3087\u3063\u3068\u6016\u3044(\u5f8c\u65e5\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u898b\u305f\u3068\u304d\u3068\u304b)\u3002<\/p>\n<p>\u4e0a\u8a18\u3092\u8af8\u3005\u8003\u616e\u3059\u308b\u3068\u4eca\u306e\u3068\u3053\u308d\u826f\u3055\u305d\u3046\u306a\u4f7f\u3044\u3069\u3053\u308d\u306f\u601d\u3044\u6d6e\u304b\u3070\u306a\u3044\u3068\u3053\u308d\u3002<\/p>\n<p>\u3042\u3068\u3001\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3068\u4f3c\u305f\u6a5f\u80fd\u3067\u30b9\u30c8\u30a2\u30c9\u30d5\u30a1\u30f3\u30af\u30b7\u30e7\u30f3\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308b\u307f\u305f\u3044\u306a\u306e\u3067\u5f8c\u65e5\u8a66\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u95a2\u9023\u306e\u30b5\u30a4\u30c8\u3092\u898b\u3066\u3044\u305f\u969b\u306b\u30b9\u30c8\u30a2\u30c9\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u304c\u4e91\u3005\u3068\u3044\u3046\u30da\u30fc\u30b8\u304c\u3042\u3063 ... <\/p>\n","protected":false},"author":1,"featured_media":1072,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5,66],"tags":[],"class_list":["post-4594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","category-database"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/4594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=4594"}],"version-history":[{"count":3,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/4594\/revisions"}],"predecessor-version":[{"id":4990,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/4594\/revisions\/4990"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/1072"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=4594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=4594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=4594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}