<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>データベース | gungiiのなるほどHack&amp;Tips</title>
	<atom:link href="https://gungii.com/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>https://gungii.com</link>
	<description>「なるほど」と納得できる経験(実例)と知識(手順)を提供します。</description>
	<lastBuildDate>Wed, 24 Jul 2024 23:31:53 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://gungii.com/wp/wp-content/uploads/2022/02/cropped-favicon-32x32.png</url>
	<title>データベース | gungiiのなるほどHack&amp;Tips</title>
	<link>https://gungii.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>phpMyAdminの使い方_ SQL(便利機能)</title>
		<link>https://gungii.com/admin-uinfo/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Fri, 11 Sep 2020 08:11:24 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[データベース]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=8898</guid>

					<description><![CDATA[phpMyadminの使い方として、phpMyadminを実際に動かしながらSQLをご紹介してきました。INSERT,UPDATE,DELETE,SELECT等の構文を実際のデータベースを使って、動きを確認しました。そこ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>phpMyadminの使い方として、phpMyadminを実際に動かしながらSQLをご紹介してきました。INSERT,UPDATE,DELETE,SELECT等の構文を実際のデータベースを使って、動きを確認しました。そこで゛phpMyadminの使い方゛として最後に、SELECTの条件指定や集計方法で便利な機能をご紹介します。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">XAMPPの起動</a><ol><li><a href="#toc2" tabindex="0">ApacheとMySQLの起動</a></li><li><a href="#toc3" tabindex="0">MySQLのAdminの起動</a></li></ol></li><li><a href="#toc4" tabindex="0">便利な機能</a><ol><li><a href="#toc5" tabindex="0">条件指定</a></li><li><a href="#toc6" tabindex="0">集計</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">XAMPPの起動</span></h2>



<h3 class="wp-block-heading"><span id="toc2">ApacheとMySQLの起動</span></h3>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a.jpg" alt="xamppの起動画面" class="wp-image-13823" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<h3 class="wp-block-heading"><span id="toc3">MySQLのAdminの起動</span></h3>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="581" height="299" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a.jpg" alt="phpMyAdminの初期画面" class="wp-image-13825" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a.jpg 581w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a-500x257.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a-300x154.jpg 300w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<h2 class="wp-block-heading"><span id="toc4">便利な機能</span></h2>



<h3 class="wp-block-heading"><span id="toc5">条件指定</span></h3>



<h4 class="wp-block-heading">idが1又は3のレコードの抜き出し</h4>



<p>次の①と②は同じ結果となります。</p>



<p>①id=1 OR id=3</p>



<figure class="wp-block-image size-full"><img decoding="async" width="556" height="681" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u03a.jpg" alt="idが1又は3のレコードを抜き出したstaff_list" class="wp-image-13826" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u03a.jpg 556w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u03a-500x612.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u03a-300x367.jpg 300w" sizes="(max-width: 556px) 100vw, 556px" /></figure>



<p></p>



<p>②IN(1,3)</p>



<p>INの中に一致させたいものをカンマで区切って、入力できます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="556" height="378" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u04a.jpg" alt="idが1又は3のレコードを抜き出したstaff_list" class="wp-image-13827" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u04a.jpg 556w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u04a-500x340.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u04a-300x204.jpg 300w" sizes="(max-width: 556px) 100vw, 556px" /></figure>



<p></p>



<h4 class="wp-block-heading">年齢が35歳以上60歳未満のレコードの抜き出し</h4>



<p>次の①と②は同じ結果となります。</p>



<p>①age &gt;=35 AND age &lt; 60</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="558" height="405" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u05a.jpg" alt="年齢が35歳以上60歳未満のレコードを抜き出したstaff_list" class="wp-image-13828" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u05a.jpg 558w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u05a-500x363.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u05a-300x218.jpg 300w" sizes="(max-width: 558px) 100vw, 558px" /></figure>



<p></p>



<p>②age BETWEEN 35 AND 59</p>



<p>BETWEENは、59以下なので、35から59の間に収まっているかとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="558" height="404" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u06a.jpg" alt="年齢が35歳以上60歳未満のレコードを抜き出したstaff_list" class="wp-image-13829" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u06a.jpg 558w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u06a-500x362.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u06a-300x217.jpg 300w" sizes="(max-width: 558px) 100vw, 558px" /></figure>



<p></p>



<h4 class="wp-block-heading">レコードを絞る</h4>



<p>大量のデータを絞って抜き出す。</p>



<p>①LIMIT 3</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="430" height="685" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u07a.jpg" alt="3レコードを抜き出したstaff_list" class="wp-image-13830" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u07a.jpg 430w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u07a-300x478.jpg 300w" sizes="(max-width: 430px) 100vw, 430px" /></figure>



<p></p>



<p>②LIMIT　3,2</p>



<p>3レコード目の次レコードから2レコード抜き出します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="432" height="359" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u08a.jpg" alt="3レコード目から2レコードを抜き出したstaff_list" class="wp-image-13831" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u08a.jpg 432w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u08a-300x249.jpg 300w" sizes="(max-width: 432px) 100vw, 432px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc6">集計</span></h3>



<h4 class="wp-block-heading">重複を無くす。</h4>



<p>以下のsyukyakuテーブルの集計では、item_id=1が重複していますので、重複をなくして集計します。DISTINCTを使います。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="423" height="836" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u09a.jpg" alt="idの重複をなくしたsyukyakuテーブル" class="wp-image-13832" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u09a.jpg 423w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u09a-300x593.jpg 300w" sizes="(max-width: 423px) 100vw, 423px" /></figure>



<p></p>



<h4 class="wp-block-heading">合計を求める。</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="631" height="790" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u10a.jpg" alt="合計を算出したsyukyakuテーブル" class="wp-image-13833" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u10a.jpg 631w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u10a-500x626.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u10a-300x376.jpg 300w" sizes="(max-width: 631px) 100vw, 631px" /></figure>



<p></p>



<h4 class="wp-block-heading">ショートカット(別名の付与)</h4>



<p>毎回テーブル名を指定するのは大変です。そこでテーブルにショートカットを割り当てます。FROMの後のテーブル名の後に半角開けて、別名を付けます。(よく行うのは、そのテーブルの特徴として、1文字を与えます。)<br>例：staff_list→sl、syukyaku→sk</p>



<p>①FROMの後のテーブル名の後に半角開けて、別名を付けます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="628" height="70" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u11a.jpg" alt="ショートカットの記述例1" class="wp-image-13834" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u11a.jpg 628w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u11a-500x56.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u11a-300x33.jpg 300w" sizes="(max-width: 628px) 100vw, 628px" /></figure>



<p></p>



<p>②その他を別名に変えます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="625" height="70" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u12a.jpg" alt="ショートカットの記述例2" class="wp-image-13835" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u12a.jpg 625w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u12a-500x56.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u12a-300x34.jpg 300w" sizes="(max-width: 625px) 100vw, 625px" /></figure>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="512" height="408" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u13a.jpg" alt="ショートカットを記載したselect文と
実行結果の画面" class="wp-image-13836" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u13a.jpg 512w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u13a-500x398.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u13a-300x239.jpg 300w" sizes="(max-width: 512px) 100vw, 512px" /></figure>



<p></p>



<p>結果は同じですが、非常にコンパクトになります。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>phpMyAdminの使い方_ リレーショナル</title>
		<link>https://gungii.com/admin-rinfo/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Fri, 17 Jul 2020 13:06:08 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[データベース]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=8731</guid>

					<description><![CDATA[リレーショナルデータベース(RDB)とは、「テーブル」という表形式の構造で管理するエクセルの表のイメージです。行をレコードと呼び、列をフィールドと呼びます。1行に1件のデータが格納され、1レコードとなります。が、各レコー [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>リレーショナルデータベース(RDB)とは、「テーブル」という表形式の構造で管理するエクセルの表のイメージです。行をレコードと呼び、列をフィールドと呼びます。1行に1件のデータが格納され、1レコードとなります。が、各レコードのデータは必ず&#8221;一意&#8221;であることが条件となります。データの重複を避けることで、検索スピードを上げることができるのです。ここでは、複数のテーブルにリレーションを貼り、リレーショナルデータベースを実践してみます。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="417" height="222" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r00a.jpg" alt="リレーショナルデータベースのイメージ図" class="wp-image-13839" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r00a.jpg 417w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r00a-300x160.jpg 300w" sizes="(max-width: 417px) 100vw, 417px" /></figure>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-4" checked><label class="toc-title" for="toc-checkbox-4">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">所属の追加</a><ol><li><a href="#toc2" tabindex="0">Xamppの起動</a></li><li><a href="#toc3" tabindex="0">対象ファイルの選択</a></li><li><a href="#toc4" tabindex="0">所属カラムの追加</a></li><li><a href="#toc5" tabindex="0">所属カラムの削除</a></li></ol></li><li><a href="#toc6" tabindex="0">所属テーブルの作成</a><ol><li><a href="#toc7" tabindex="0">Xamppの起動</a></li><li><a href="#toc8" tabindex="0">テーブルの作成</a></li><li><a href="#toc9" tabindex="0">データの入力</a></li><li><a href="#toc10" tabindex="0">staff_listと、syozokuの結びつけ</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">所属の追加</span></h2>



<p>現在、データベース(jinji)のテーブル(staff_list)では、所属という項目がない為、どこの部署なのかを識別することができません。そこで、所属という項目を追加して、それが識別できるようにしてみます。</p>



<h3 class="wp-block-heading"><span id="toc2">Xamppの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a.jpg" alt="xamppの起動画面" class="wp-image-13823" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="581" height="299" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a.jpg" alt="phpMyAdminの初期画面" class="wp-image-13825" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a.jpg 581w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a-500x257.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a-300x154.jpg 300w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc3">対象ファイルの選択</span></h3>



<h4 class="wp-block-heading">データベース(jinji)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="229" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r01a.jpg" alt="データベースjinjiを選択して表示されたテーブル一覧" class="wp-image-13846" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r01a.jpg 600w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r01a-500x191.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r01a-300x115.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブル(staff_list)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="276" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r02a.jpg" alt="テーブルstaff_listを選択して表示されたスタッフ一覧" class="wp-image-13848" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r02a.jpg 600w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r02a-500x230.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r02a-300x138.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc4">所属カラムの追加</span></h3>



<p>ここでテーブル(staff_list)に、どこの部署なのかを識別するための「所属」という項目を追加します。</p>



<h4 class="wp-block-heading">「構造」タブをクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="299" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r03a.jpg" alt="構造タブを選択されたstaff_list" class="wp-image-13849" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r03a.jpg 600w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r03a-500x249.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r03a-300x150.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p></p>



<h4 class="wp-block-heading">カラムの追加</h4>



<p>staff_nameの後に、「syozoku」という名前でカラムを1つ追加します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="490" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r04a.jpg" alt="syozokuというカラムを追加したstaff_list" class="wp-image-13850" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r04a.jpg 600w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r04a-500x408.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r04a-300x245.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p></p>



<h4 class="wp-block-heading">「所属データ」の入力</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="597" height="256" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r05a.jpg" alt="syozokuを入力したstaff_list" class="wp-image-13851" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r05a.jpg 597w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r05a-500x214.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r05a-300x129.jpg 300w" sizes="(max-width: 597px) 100vw, 597px" /></figure>



<p></p>



<p>所属カラムを追加したことで、どこの部署なのかを識別することができるようになりました。ここでは、相田さんと山内さんが同じ1号館の所属であることがわかります。そこで、さらに1号館等の所属の電話番号も一緒に管理したい等という場合は、カラムを追加しなければなりません。すると、どんどんとテーブルが肥大化してしまいます。また、相田さんが異動で1号館から2号館に移動した場合には、syozokuの項目を変更しなければならなくなり、非常に効率がわるくなります。そこで、このような場合は、テーブルを分けることをします。折角、部署カラムを追加したのですが、この方法ではメンテナンスも大変ですので、staff_listとは別に、新たな所属テーブルを作成して、2つのテーブルを関連付けて管理することとします。</p>



<h3 class="wp-block-heading"><span id="toc5">所属カラムの削除</span></h3>



<p>そこで、テーブルを分ければ、syozokuのカラムは不要となりますので削除しておきます。</p>



<h4 class="wp-block-heading">カラムの削除</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="632" height="254" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r06a.jpg" alt="構造タブからsyozokuカラムの削除を選択したstaff_list" class="wp-image-13852" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r06a.jpg 632w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r06a-500x201.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r06a-300x121.jpg 300w" sizes="(max-width: 632px) 100vw, 632px" /></figure>



<p></p>



<p>syozokuにチェックを入れて、「削除」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="636" height="135" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r07a.jpg" alt="カラム削除の実行確認画面" class="wp-image-13853" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r07a.jpg 636w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r07a-500x106.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r07a-300x64.jpg 300w" sizes="(max-width: 636px) 100vw, 636px" /></figure>



<p></p>



<h4 class="wp-block-heading">カラム削除結果</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="631" height="580" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r08a.jpg" alt="syozokuカラムを削除したstaff_list" class="wp-image-13854" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r08a.jpg 631w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r08a-500x460.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r08a-300x276.jpg 300w" sizes="(max-width: 631px) 100vw, 631px" /></figure>



<p></p>



<h2 class="wp-block-heading"><span id="toc6">所属テーブルの作成</span></h2>



<h3 class="wp-block-heading"><span id="toc7">Xamppの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a.jpg" alt="xamppの起動画面" class="wp-image-13823" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="581" height="299" src="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a.jpg" alt="phpMyAdminの初期画面" class="wp-image-13825" srcset="https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a.jpg 581w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a-500x257.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/09/admin-u02a-300x154.jpg 300w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc8">テーブルの作成</span></h3>



<p>所属を管理する新たなテーブル(syozoku)を作成します。</p>



<h4 class="wp-block-heading">データベース(jinji)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="229" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r01a.jpg" alt="データベースjinjiを選択して表示されたテーブル一覧" class="wp-image-13846" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r01a.jpg 600w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r01a-500x191.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r01a-300x115.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブル(syozoku)の作成</h4>



<p>①テーブル名、カラム数の入力</p>



<p>テーブル名、カラム数を入力して「実行」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="390" height="124" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r11a.jpg" alt="テーブルsyozokuの追加画面" class="wp-image-13855" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r11a.jpg 390w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r11a-300x95.jpg 300w" sizes="(max-width: 390px) 100vw, 390px" /></figure>



<p></p>



<p>②カラム名、データ型の入力</p>



<p>名前は、id,name,tel、データ型は、INT,TEXT,TEXTとします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="570" height="186" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r12a.jpg" alt="カラム名、データ型の入力画面" class="wp-image-13856" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r12a.jpg 570w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r12a-500x163.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r12a-300x98.jpg 300w" sizes="(max-width: 570px) 100vw, 570px" /></figure>



<p></p>



<p>③プライマリーキーの設定</p>



<p>idのカラムをプライマリーキーに設定します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="545" height="430" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r13a.jpg" alt="プマリーキーの設定画面" class="wp-image-13857" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r13a.jpg 545w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r13a-500x394.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r13a-300x237.jpg 300w" sizes="(max-width: 545px) 100vw, 545px" /></figure>



<p></p>



<p>④オートインクリメントの設定</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="547" height="209" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r14a.jpg" alt="オートインクリメントの設定画面" class="wp-image-13858" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r14a.jpg 547w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r14a-500x191.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r14a-300x115.jpg 300w" sizes="(max-width: 547px) 100vw, 547px" /></figure>



<p></p>



<p>これでテーブルの設定が終わりましたので、「保存」をクリックします。</p>



<h4 class="wp-block-heading">テーブル作成完了</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="553" height="193" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r15a.jpg" alt="テーブルsyozokuの設定完了画面" class="wp-image-13859" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r15a.jpg 553w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r15a-500x175.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r15a-300x105.jpg 300w" sizes="(max-width: 553px) 100vw, 553px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc9">データの入力</span></h3>



<h4 class="wp-block-heading">「挿入」タブのクリック</h4>



<p>作成したテーブル(syozoku)にデータを入力します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="579" height="351" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r16a.jpg" alt="テーブルsyozokuのデータ入力画面" class="wp-image-13860" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r16a.jpg 579w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r16a-500x303.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r16a-300x182.jpg 300w" sizes="(max-width: 579px) 100vw, 579px" /></figure>



<p></p>



<p>同様にして、以下を追加します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="301" height="131" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r17a.jpg" alt="テーブルsyozokuに入力する項目表" class="wp-image-13861"/></figure>



<p></p>



<h4 class="wp-block-heading">「表示」タブのクリック</h4>



<p>入力された内容を確認します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="593" height="280" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r18a.jpg" alt="表示タブで表示されたsyozokuの入力データ" class="wp-image-13862" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r18a.jpg 593w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r18a-500x236.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r18a-300x142.jpg 300w" sizes="(max-width: 593px) 100vw, 593px" /></figure>



<p></p>



<p>これで、syozokuというテーブルには3つの部署の情報が格納されました。</p>



<h3 class="wp-block-heading"><span id="toc10">staff_listと、syozokuの結びつけ</span></h3>



<p>作成した所属テーブル(syozoku)と、スタッフリスト(staff_list)テーブルを結びつける為、スタッフリスト(staff_list)に、所属コード(syozoku_id)を設定するカラムを追加します。</p>



<h4 class="wp-block-heading">カラムの追加</h4>



<p>staff_listにカラムを追加します。</p>



<p>①「構造」タブのクリック</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="541" height="264" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r19a.jpg" alt="構造タブで表示されたsyozokuのテーブル構造" class="wp-image-13863" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r19a.jpg 541w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r19a-500x244.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r19a-300x146.jpg 300w" sizes="(max-width: 541px) 100vw, 541px" /></figure>



<p></p>



<p>②カラムの設定</p>



<p>名前を「syozoku_id」、データ型を「INT」として、「保存」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="541" height="132" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r20a.jpg" alt="カラムの設定画面" class="wp-image-13864" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r20a.jpg 541w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r20a-500x122.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r20a-300x73.jpg 300w" sizes="(max-width: 541px) 100vw, 541px" /></figure>



<p></p>



<p>③追加の確認</p>



<p>syozoku_idのカラムが追加されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="547" height="230" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r21a.jpg" alt="syozoku-idというカラムを追加したstaff_list" class="wp-image-13865" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r21a.jpg 547w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r21a-500x210.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r21a-300x126.jpg 300w" sizes="(max-width: 547px) 100vw, 547px" /></figure>



<p></p>



<p>このsyozoku_idに、syozokuテーブルのidを入力することで、結びつけることができます。</p>



<h4 class="wp-block-heading">カラムへのデータの挿入</h4>



<p>追加したカラム(syozoku_id)ヘ、所属コードを入力します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="301" height="131" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r22a.jpg" alt="テーブルsyozokuに入力する項目表" class="wp-image-13866"/></figure>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="609" height="295" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r23a.jpg" alt="syozoku-idの入力されたstaff_list" class="wp-image-13867" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r23a.jpg 609w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r23a-500x242.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r23a-300x145.jpg 300w" sizes="(max-width: 609px) 100vw, 609px" /></figure>



<p></p>



<p>このままでは、syozoku_idはセットされましたが、syozoku_id=11が1号館であるという事は、syozokuテーブルを検索しなければわかりません。データベースでは、リレーションを使って2つのデータベースがあたかも1つのデータベースであるかの如くふるまうことができます。</p>



<h4 class="wp-block-heading">SQLの入力</h4>



<p>①特定レコードのみ紐づけ</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="567" height="314" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r24a.jpg" alt="所属レコードを追加するSQLと実行画面" class="wp-image-13868" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r24a.jpg 567w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r24a-500x277.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r24a-300x166.jpg 300w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r24a-160x90.jpg 160w" sizes="(max-width: 567px) 100vw, 567px" /></figure>



<p></p>



<p>「実行」をクリックすると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="570" height="232" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r25a.jpg" alt="所属レコードが追加されたSQL実行結果" class="wp-image-13869" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r25a.jpg 570w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r25a-500x204.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r25a-300x122.jpg 300w" sizes="(max-width: 570px) 100vw, 570px" /></figure>



<p></p>



<p>staff_listのid=1の相田さんの情報が表示されますが、その前にsyozokuの情報が付属して表示されます。</p>



<p>②全レコードの紐づけ</p>



<p>WHERE句を無くして、「実行」をクリックすると、全てに対してsyozokuを紐づけることができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="572" height="458" src="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r26a.jpg" alt="syozokuテーブルとstaff_listの紐づけのSQL" class="wp-image-13870" srcset="https://gungii.com/wp/wp-content/uploads/2020/07/admin-r26a.jpg 572w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r26a-500x400.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/07/admin-r26a-300x240.jpg 300w" sizes="(max-width: 572px) 100vw, 572px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>phpMyAdminの使い方_プライマリーキーの設定</title>
		<link>https://gungii.com/admin-pinfo/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Fri, 05 Jun 2020 14:33:24 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[データベース]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=8510</guid>

					<description><![CDATA[テーブルには多くのデータが格納されています。格納されたすべてのデータの中から1つのデータを特定したいときには、そのデータが一意に識別できなくてはなりません。つまり他のデータの値と重複しないことが前提です。この仕組みとして [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>テーブルには多くのデータが格納されています。格納されたすべてのデータの中から1つのデータを特定したいときには、そのデータが一意に識別できなくてはなりません。つまり他のデータの値と重複しないことが前提です。この仕組みとして、データベースにはユニークカラムという仕組みがあります。このユニークカラムの中で最も大切なキーとしてプライマリーキー(主キー)という仕組みがあります。<br>カラムにプライマリーキー制約を設定すると、カラムには他のデータの値と重複することのない値しか格納することができなくなります。またNULLも格納することができません。その結果、プライマリーキー制約が設定されたカラムの値を検索することで、テーブルの中でただ一つのデータを特定することができるのです。プライマリーキーはテーブルに1つしか設定することができませんが、対象となるカラムは１つだけではなく 複数のカラムの組み合わせに対して設定することができます。例えば2つのカラムの組み合わせに対して設定した場合、 2つのカラムに格納されている値の組み合わせが他のデータと重複することはできなくなります。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-6" checked><label class="toc-title" for="toc-checkbox-6">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">プライマリーキーの設定</a><ol><li><a href="#toc2" tabindex="0">プライマリーキーの設定がない場合</a></li><li><a href="#toc3" tabindex="0">プライマリーキーの設定がある場合</a></li><li><a href="#toc4" tabindex="0">プライマリーキーの設定のタイミング</a></li></ol></li><li><a href="#toc5" tabindex="0">オートインクリメントの設定</a><ol><li><a href="#toc6" tabindex="0">設定</a></li><li><a href="#toc7" tabindex="0">データの挿入</a></li><li><a href="#toc8" tabindex="0">データを削除後、データの挿入</a></li></ol></li><li><a href="#toc9" tabindex="0">タイムスタンプの設定</a><ol><li><a href="#toc10" tabindex="0">カラム(タイムスタンプ)の追加</a></li><li><a href="#toc11" tabindex="0">データの追加</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">プライマリーキーの設定</span></h2>



<h3 class="wp-block-heading"><span id="toc2">プライマリーキーの設定がない場合</span></h3>



<p>プライマリーキーの設定がない状態で、テーブルにデータをセットしてみます。</p>



<h4 class="wp-block-heading">データの挿入(新規)</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="550" height="837" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p01a.jpg" alt="1レコード追加したjinjiデータベースのstaff_list" class="wp-image-13929" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p01a.jpg 550w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p01a-500x761.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p01a-300x457.jpg 300w" sizes="(max-width: 550px) 100vw, 550px" /></figure>



<p></p>



<p>表示タブをクリックすると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="551" height="270" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p02a.jpg" alt="表示タブを選択されたjinjiデータベースのstaff_list" class="wp-image-13931" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p02a.jpg 551w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p02a-500x245.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p02a-300x147.jpg 300w" sizes="(max-width: 551px) 100vw, 551px" /></figure>



<p></p>



<h4 class="wp-block-heading">データの挿入(追加)</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="546" height="303" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p03a.jpg" alt="同じidを登録したstaff_list" class="wp-image-13932" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p03a.jpg 546w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p03a-500x277.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p03a-300x166.jpg 300w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p03a-120x68.jpg 120w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p03a-160x90.jpg 160w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p></p>



<p>IDにどのような数字を入れるかは、何らのチェックもありませんので、間違って同じ数字をidとして入力することができます。そのため、2番が「安藤なつ」なのか?「浅田哲也」なのかの識別がつかず、idとして意味をなさなくなります。</p>



<h3 class="wp-block-heading"><span id="toc3">プライマリーキーの設定がある場合</span></h3>



<h4 class="wp-block-heading">プライマリーキーの設定</h4>



<p>①テーブルを空にする。</p>



<p>プライマリーキーの設定は空の状態でおこないますので、既に入っている場合は、「操作」というタブをクリックして、「テーブルを空にする」を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="550" height="823" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p04a.jpg" alt="「テーブルを空にする」を選択したstaff_list" class="wp-image-13933" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p04a.jpg 550w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p04a-500x748.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p04a-300x449.jpg 300w" sizes="(max-width: 550px) 100vw, 550px" /></figure>



<p></p>



<p>②「構造」タブのクリック</p>



<p>プライマリーキーを設定する為に、「構造」タブをクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="583" height="190" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p05a.jpg" alt="構造タブを表示したstaff_list" class="wp-image-13934" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p05a.jpg 583w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p05a-500x163.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p05a-300x98.jpg 300w" sizes="(max-width: 583px) 100vw, 583px" /></figure>



<p></p>



<p>③「主」のクリック</p>



<p>idの右端のその他の「主」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="588" height="622" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p06a.jpg" alt="プライマリーキーの設定画面" class="wp-image-13935" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p06a.jpg 588w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p06a-500x529.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p06a-300x317.jpg 300w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<p></p>



<p>④プライマリーキーの設定完了</p>



<p>正常に実行されると、「主」がグレーとなり、リンクではなくなっています。idのとなりに鍵のマーク、そして、インデックスとしてidがプライマリーになっていることを示す表が表示されています。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="553" height="189" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p07a.jpg" alt="プライマリーキーの設定完了を確認する画面" class="wp-image-13936" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p07a.jpg 553w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p07a-500x171.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p07a-300x103.jpg 300w" sizes="(max-width: 553px) 100vw, 553px" /></figure>



<p></p>



<p>これで、プライマリーkeyの設定が有効となりました。</p>



<h4 class="wp-block-heading">データの挿入(新規)</h4>



<p>プライマリーキーが設定されている状態でデータを入力してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="603" height="575" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p08a.jpg" alt="挿入タブが表示されたstaff_list" class="wp-image-13937" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p08a.jpg 603w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p08a-500x477.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p08a-300x286.jpg 300w" sizes="(max-width: 603px) 100vw, 603px" /></figure>



<p></p>



<h4 class="wp-block-heading">データの挿入(追加)</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="597" height="315" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p09a.jpg" alt="同一のidを入力してエラーが表示されたstaff_list" class="wp-image-13938" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p09a.jpg 597w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p09a-500x264.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p09a-300x158.jpg 300w" sizes="(max-width: 597px) 100vw, 597px" /></figure>



<p></p>



<p>このようにエラー表示されますので、idを重複して入力することができなくなります。id=2に変えれば、正しく追加されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="612" height="562" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p10a.jpg" alt="idを変えて入力できたstaff_list" class="wp-image-13939" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p10a.jpg 612w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p10a-500x459.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p10a-300x275.jpg 300w" sizes="(max-width: 612px) 100vw, 612px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc4">プライマリーキーの設定のタイミング</span></h3>



<p>プライマリーキーはテーブルを作成する時に設定できます。</p>



<h4 class="wp-block-heading">新規作成のクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="633" height="507" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p11a.jpg" alt="新規テーブルを追加したjinjiデータベース" class="wp-image-13940" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p11a.jpg 633w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p11a-500x400.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p11a-300x240.jpg 300w" sizes="(max-width: 633px) 100vw, 633px" /></figure>



<p></p>



<h4 class="wp-block-heading">プライマリーキーの設定</h4>



<p>カラムの右のインデックスでpraimaryをクリックすると、最初から、このカラムをプライマリーとすることができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="636" height="237" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p12a.jpg" alt="インデックスで「primary」を選択した新規テーブル" class="wp-image-13941" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p12a.jpg 636w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p12a-500x186.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p12a-300x112.jpg 300w" sizes="(max-width: 636px) 100vw, 636px" /></figure>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="461" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p13a.jpg" alt="インデックスにprimaryを選択して実行ボタンを押下する新規テーブル" class="wp-image-13942" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p13a.jpg 591w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p13a-500x390.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p13a-300x234.jpg 300w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<p></p>



<h2 class="wp-block-heading"><span id="toc5">オートインクリメントの設定</span></h2>



<p>オートインクリメントとは、テーブルにレコードが追加された際に自動的に連番をつけてくれる機能です。インクリメントとは、加算するという意味の英語で、つまり自動で加算するという事です。消したレコードは永久欠番となり、最後の一番大きい値に続けて連番がつくられます。</p>



<h3 class="wp-block-heading"><span id="toc6">設定</span></h3>



<h4 class="wp-block-heading">「構造」タブのクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="567" height="226" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p21a.jpg" alt="構造タブを表示したtables" class="wp-image-13943" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p21a.jpg 567w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p21a-500x199.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p21a-300x120.jpg 300w" sizes="(max-width: 567px) 100vw, 567px" /></figure>



<p></p>



<h4 class="wp-block-heading">「操作」タブをクリック</h4>



<p>「操作」タブをクリックして、idの「変更」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="567" height="548" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p22a.jpg" alt="構造タブの変更を選択したtables" class="wp-image-13944" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p22a.jpg 567w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p22a-500x483.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p22a-300x290.jpg 300w" sizes="(max-width: 567px) 100vw, 567px" /></figure>



<p></p>



<p>するとidというカラムの内容を変更する画面が表示されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="585" height="112" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p23a.jpg" alt="idのカラム内容変更画面" class="wp-image-13945" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p23a.jpg 585w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p23a-500x96.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p23a-300x57.jpg 300w" sizes="(max-width: 585px) 100vw, 585px" /></figure>



<p></p>



<h4 class="wp-block-heading">Ａ_Iにチェックを入れて「保存」をクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="585" height="143" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p24a.jpg" alt="オートインクリメント(A_I)にチェックを入れたカラム内容変更画面" class="wp-image-13946" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p24a.jpg 585w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p24a-500x122.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p24a-300x73.jpg 300w" sizes="(max-width: 585px) 100vw, 585px" /></figure>



<p></p>



<p>これでオートインクリメントが設定されました。idカラムのその他欄に「AUTO_INCREMENT」と表示されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="582" height="215" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p25a.jpg" alt="「AUTO_INCREMENT」と表示されたidカラムのその他欄" class="wp-image-13947" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p25a.jpg 582w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p25a-500x185.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p25a-300x111.jpg 300w" sizes="(max-width: 582px) 100vw, 582px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc7">データの挿入</span></h3>



<p>オートインクリメントを設定した状態で、データを挿入してみます。</p>



<h4 class="wp-block-heading">「挿入」タブのクリック</h4>



<p>①id,nameの入力</p>



<p>これまではidのところに数字を入力していましたが、今回は必要ありません。<br>nameを入力して「実行」をクリックすると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="476" height="257" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p26a.jpg" alt="オートインクリメント設定済みの挿入タブの画面" class="wp-image-13948" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p26a.jpg 476w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p26a-300x162.jpg 300w" sizes="(max-width: 476px) 100vw, 476px" /></figure>



<p></p>



<p>②入力結果</p>



<p>「id 3の行を挿入しました」と表示されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="476" height="298" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p27a.jpg" alt="挿入確認画面" class="wp-image-13949" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p27a.jpg 476w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p27a-300x188.jpg 300w" sizes="(max-width: 476px) 100vw, 476px" /></figure>



<p></p>



<p>③「表示」タブのクリック</p>



<p>「表示」をクリックすると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="521" height="223" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p28a.jpg" alt="表示タブを選択したtables" class="wp-image-13950" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p28a.jpg 521w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p28a-500x214.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p28a-300x128.jpg 300w" sizes="(max-width: 521px) 100vw, 521px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc8">データを削除後、データの挿入</span></h3>



<p>オートインクリメントで採番されたデータを削除してみます。<br>id=2を削除した後、データを追加するとidは何番がふられるか?というと、id=2は永久欠番となり、4番が採番されます。</p>



<h4 class="wp-block-heading">データの削除</h4>



<p>①id=2のレコード削除</p>



<p>id=2、name=小野妹子さんのレコードを削除してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="534" height="380" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p29a.jpg" alt="レコード削除を実行したtables" class="wp-image-13951" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p29a.jpg 534w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p29a-500x356.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p29a-300x213.jpg 300w" sizes="(max-width: 534px) 100vw, 534px" /></figure>



<p></p>



<p>②削除結果</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="472" height="216" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p30a.jpg" alt="実行結果が表示されたtables" class="wp-image-13952" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p30a.jpg 472w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p30a-300x137.jpg 300w" sizes="(max-width: 472px) 100vw, 472px" /></figure>



<p></p>



<h4 class="wp-block-heading">データの挿入</h4>



<p>①「挿入」タブをクリック</p>



<p>nameを入力して、「実行」をクリック</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="472" height="253" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p31a.jpg" alt="オートインクリメント設定済みの挿入タブの画面" class="wp-image-13953" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p31a.jpg 472w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p31a-300x161.jpg 300w" sizes="(max-width: 472px) 100vw, 472px" /></figure>



<p></p>



<p>②入力結果</p>



<p>「id 4の行を挿入しました」と表示されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="471" height="298" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p32a.jpg" alt="挿入確認画面" class="wp-image-13954" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p32a.jpg 471w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p32a-300x190.jpg 300w" sizes="(max-width: 471px) 100vw, 471px" /></figure>



<p></p>



<p>③「表示」タブのクリック</p>



<p>「表示」をクリックすると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="473" height="201" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p33a.jpg" alt="表示タブを選択したtables" class="wp-image-13955" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p33a.jpg 473w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p33a-300x127.jpg 300w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<p></p>



<p>id=4が採番されて、id=2は欠番となっています。</p>



<h2 class="wp-block-heading"><span id="toc9">タイムスタンプの設定</span></h2>



<h3 class="wp-block-heading"><span id="toc10">カラム(タイムスタンプ)の追加</span></h3>



<p>コンピューターが内蔵している時計を使いtimestampとして登録することで、データベースにその時点の日付と時刻を記録することができます。</p>



<h4 class="wp-block-heading">データベース(jinji)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="635" height="213" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p41a.jpg" alt="jinjiデータベースのテーブル一覧" class="wp-image-13956" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p41a.jpg 635w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p41a-500x168.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p41a-300x101.jpg 300w" sizes="(max-width: 635px) 100vw, 635px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブル(staff_list)の選択</h4>



<p>staff_listの構造をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="625" height="238" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p42a.jpg" alt="構造タブを表示したstaff_list" class="wp-image-13957" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p42a.jpg 625w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p42a-500x190.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p42a-300x114.jpg 300w" sizes="(max-width: 625px) 100vw, 625px" /></figure>



<p></p>



<h4 class="wp-block-heading">カラム数と位置の指定</h4>



<p>追加するカラムの数と位置を指定して、実行をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="541" height="52" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p43a.jpg" alt="カラム数と位置の指定画面" class="wp-image-13958" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p43a.jpg 541w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p43a-500x48.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p43a-300x29.jpg 300w" sizes="(max-width: 541px) 100vw, 541px" /></figure>



<p></p>



<h4 class="wp-block-heading">カラム設定画面の表示</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="583" height="141" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p44a.jpg" alt="カラム設定画面" class="wp-image-13959" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p44a.jpg 583w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p44a-500x121.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p44a-300x73.jpg 300w" sizes="(max-width: 583px) 100vw, 583px" /></figure>



<p></p>



<h4 class="wp-block-heading">タイムスタンプの設定</h4>



<p>名前=stampとして、データ型=TIMESTAMPとして「保存する」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="583" height="476" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p45a.jpg" alt="データ型=TIMESTAMPを設定したstaff_list" class="wp-image-13960" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p45a.jpg 583w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p45a-500x408.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p45a-300x245.jpg 300w" sizes="(max-width: 583px) 100vw, 583px" /></figure>



<p></p>



<h4 class="wp-block-heading">「表示」タブのクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="582" height="251" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p46a.jpg" alt="タイムスタンプが表示されたstaff_list" class="wp-image-13961" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p46a.jpg 582w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p46a-500x216.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p46a-300x129.jpg 300w" sizes="(max-width: 582px) 100vw, 582px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc11">データの追加</span></h3>



<p>データを1件追加してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="395" height="337" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p47a.jpg" alt="レコードを追加したstaff_list" class="wp-image-13962" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p47a.jpg 395w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p47a-300x256.jpg 300w" sizes="(max-width: 395px) 100vw, 395px" /></figure>



<p>timestampのところは、何も変更せず「実行」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="599" height="280" src="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p48a.jpg" alt="追加したレコードの表示されたstaff_list" class="wp-image-13963" srcset="https://gungii.com/wp/wp-content/uploads/2020/06/admin-p48a.jpg 599w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p48a-500x234.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/06/admin-p48a-300x140.jpg 300w" sizes="(max-width: 599px) 100vw, 599px" /></figure>



<p>データを挿入した日時が、オートインクリメントと同じ様に格納されます。</p>



<p>留意:<br>timestamp型は、日付と時刻の両方を含む型で、表現できる範囲は「1970-01-01 00:00:01」から「2038-01-19 03:14:07」までです。これはtimestampの2038年問題と言われ、MySQLのtimestampが1970年1月1日を0として32ビットの整数で計算している為、2038年になると32ビットを使い切って時計が1970年に戻ってしまうという現象です。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>phpMyAdminの使い方_ DBのバックアップとリストア</title>
		<link>https://gungii.com/admin-binfo/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Sun, 24 May 2020 08:24:23 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[データベース]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=8454</guid>

					<description><![CDATA[phpMyAdminを使ってMySQL(MariaDB)のデータをバックアップする方法を説明します。データベース単位やテーブル単位でデータをエクスポートすることができ、またエクスポートしたデータをインポートすることが可能 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>phpMyAdminを使ってMySQL(MariaDB)のデータをバックアップする方法を説明します。<br>データベース単位やテーブル単位でデータをエクスポートすることができ、またエクスポートしたデータをインポートすることが可能です。データベースのバックアップは、エクスプローラでファイルをコピーすれば良いというものではありません。必ずバックアップ手順に従ってバックアップする必要があります。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-8" checked><label class="toc-title" for="toc-checkbox-8">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">phpMyAdmin DBのバックアップ</a><ol><li><a href="#toc2" tabindex="0">バックアップ</a></li></ol></li><li><a href="#toc3" tabindex="0">phpMyAdmin DBのリストア</a><ol><li><a href="#toc4" tabindex="0">リストア</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">phpMyAdmin DBのバックアップ</span></h2>



<h3 class="wp-block-heading"><span id="toc2">バックアップ</span></h3>



<p>バックアップを取得する場合は、どのデータベースをバックアップするかを指定します。デフォルトでは全データベースを選択した状態になります。データベースからのバックアップはテーブル単位、テーブルからのバックアップはレコード単位になります。</p>



<h4 class="wp-block-heading">「エクスポート」の種類</h4>



<p>「エクスポート」タブをクリックする際には、バックアップする対象が正しいかを確認することが必要です。</p>



<p>①テーブルのバックアップ</p>



<p>staff_listというテーブルを表示している状態で、「エクスポート」タブをクリックすると、staff_listというテーブルのエクスポートとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="565" height="492" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b01a.jpg" alt="テーブルstaff_listのエクスポート画面" class="wp-image-14321" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b01a.jpg 565w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b01a-500x435.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b01a-300x261.jpg 300w" sizes="(max-width: 565px) 100vw, 565px" /></figure>



<p></p>



<p>②データベースのバックアップ</p>



<p>jinjiというデータベースを表示している状態で、「エクスポート」タブをクリックすると、jinjiというデータベースのエクスポートとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="454" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b02a.jpg" alt="データベースjinjiのエクスポート画面" class="wp-image-14323" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b02a-500x393.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b02a-300x236.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<p>③全てのデータベースのバックアップ</p>



<p>家のマークをクリックした状態で、「エクスポート」タブをクリックすると、全てのデータベースのエクスポートとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="567" height="578" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b03a.jpg" alt="全てのデータベースのエクスポート画面" class="wp-image-14325" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b03a.jpg 567w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b03a-500x510.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b03a-300x306.jpg 300w" sizes="(max-width: 567px) 100vw, 567px" /></figure>



<p></p>



<h4 class="wp-block-heading">データベース(jinji)のバックアップ</h4>



<p>ここでは、jinjiというデータベースをエクスポートしてみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="454" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b04a.jpg" alt="データベースjinjiのエクスポート画面" class="wp-image-14326" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b04a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b04a-500x393.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b04a-300x236.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<p>①エクスポートの設定</p>



<p>「簡易」と「詳細」がありますが、「簡易」のままでOKです。<br>注意:<br>詳細の場合、バックアップするテーブルの数やデータだけをバックアップしたり、構造だけをバックアップすることができますが、データのバックアップが目的であれば、簡易で構いません。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="167" height="163" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b05a.jpg" alt="エクスポートの設定画面" class="wp-image-14327"/></figure>



<p></p>



<p>②フォーマット</p>



<p>SQLのままでOK</p>



<p>③エンコーディングへの変換</p>



<p>「なし」でOK</p>



<h4 class="wp-block-heading">エクスポートの実行</h4>



<p>「実行」をクリックすると、Webブラウザがダウンロードしてファイルが1つできます。これを大切に保管しておきます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="334" height="199" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b06a.jpg" alt="エクスポートの実行画面" class="wp-image-14328" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b06a.jpg 334w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b06a-300x179.jpg 300w" sizes="(max-width: 334px) 100vw, 334px" /></figure>



<p></p>



<h4 class="wp-block-heading">エクスポートファイルの確認</h4>



<p>このファイルは中身を確認することができ、エディターで開くことができます。</p>



<p>①ファイルの選択</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="589" height="509" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b07a.jpg" alt="エディターで確認するエクスポートファイル" class="wp-image-14329" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b07a.jpg 589w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b07a-500x432.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b07a-300x259.jpg 300w" sizes="(max-width: 589px) 100vw, 589px" /></figure>



<p></p>



<p>②「Codeで開く」をクリック</p>



<p>VisualStudioCodeで開きます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="585" height="848" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b08a.jpg" alt="VSCで確認するエクスポートファイル" class="wp-image-14330" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b08a.jpg 585w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b08a-500x725.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b08a-300x435.jpg 300w" sizes="(max-width: 585px) 100vw, 585px" /></figure>



<p></p>



<p>中身を確認すると、いくつか特殊な記述はありますが、基本的には、SQLの集まりです。そこで、必要に応じて手で加工することも可能です。</p>



<h2 class="wp-block-heading"><span id="toc3">phpMyAdmin DBのリストア</span></h2>



<h3 class="wp-block-heading"><span id="toc4">リストア</span></h3>



<p>今回は、データベースが全て壊れてしまって、jinjiというデータベース自体が無くなったと仮定します。</p>



<h4 class="wp-block-heading">jinjiというデータベースの削除</h4>



<p>「操作」タブのクリックして、「データベースを削除する」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="554" height="816" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b11a.jpg" alt="データベースjinjiの削除画面" class="wp-image-14331" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b11a.jpg 554w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b11a-500x736.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b11a-300x442.jpg 300w" sizes="(max-width: 554px) 100vw, 554px" /></figure>



<p></p>



<p>「OK」をクリックすると、jinjiというデータベースが無くなりました。</p>



<h4 class="wp-block-heading">バックアップから復元</h4>



<p>①復元先のデータベースの作成</p>



<p>データベース名=jinji、照合順序=utf8mb4_general_ciを選択して「作成」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="553" height="564" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b12a.jpg" alt="データベースjinjiの作成画面" class="wp-image-14332" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b12a.jpg 553w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b12a-500x510.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b12a-300x306.jpg 300w" sizes="(max-width: 553px) 100vw, 553px" /></figure>



<p></p>



<p>新しいデータベースにバックアップしたデータを挿入していきます。</p>



<p>②「インポート」タブのクリック</p>



<p>アップロードファイルを選び、ダウンロードしたファイルを選択します。<br>注意:インポートボタンも押す場所によって動きが変わってきます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="555" height="687" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b13a.jpg" alt="エクスポートファイルをインポートして復元するデータベースjinji" class="wp-image-14333" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b13a.jpg 555w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b13a-500x619.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b13a-300x371.jpg 300w" sizes="(max-width: 555px) 100vw, 555px" /></figure>



<p></p>



<p>いろいろと設定項目はありますが、何も変更することなく、実行でOK</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="469" height="297" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b14a.jpg" alt="復元の実行ボタン" class="wp-image-14334" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b14a.jpg 469w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b14a-300x190.jpg 300w" sizes="(max-width: 469px) 100vw, 469px" /></figure>



<p></p>



<p>③インポート結果の確認</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="473" height="313" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b15a.jpg" alt="復元結果が表示されたデータベースjinjiの画面" class="wp-image-14335" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b15a.jpg 473w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b15a-300x199.jpg 300w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<p></p>



<p>データベースが復元できていることがわかります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="473" height="198" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b16a.jpg" alt="復元の確認できたjinjiの各テーブル画面" class="wp-image-14336" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-b16a.jpg 473w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-b16a-300x126.jpg 300w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>phpMyAdminの使い方_ SQL(SELECT)の実行</title>
		<link>https://gungii.com/admin-sinfo/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Tue, 12 May 2020 14:02:54 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[データベース]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=8261</guid>

					<description><![CDATA[SELECTはテーブルからレコードを抽出するための命令文で、SQL命令文の中で最も使用頻度が高く、数多くのキーワードが用意されています。今回は、その中でも特に重要なGROUP BY、ORDER BY、WHEREについて説 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>SELECTはテーブルからレコードを抽出するための命令文で、SQL命令文の中で最も使用頻度が高く、数多くのキーワードが用意されています。今回は、その中でも特に重要なGROUP BY、ORDER BY、WHEREについて説明します。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-10" checked><label class="toc-title" for="toc-checkbox-10">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">SELECT-WHERE</a><ol><li><a href="#toc2" tabindex="0">XAMPPの起動</a></li><li><a href="#toc3" tabindex="0">特定レコードの選択</a></li></ol></li><li><a href="#toc4" tabindex="0">SELECT-GROUP BY</a><ol><li><a href="#toc5" tabindex="0">XAMPPの起動</a></li><li><a href="#toc6" tabindex="0">テーブルの作成</a></li><li><a href="#toc7" tabindex="0">データの挿入</a></li><li><a href="#toc8" tabindex="0">データの集計</a></li><li><a href="#toc9" tabindex="0">LEFTJOIN、RIGHTJOIN</a></li></ol></li><li><a href="#toc10" tabindex="0">SELECT-ORDER BY</a><ol><li><a href="#toc11" tabindex="0">XAMPPの起動</a></li><li><a href="#toc12" tabindex="0">レコードの並び替え</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">SELECT-WHERE</span></h2>



<h3 class="wp-block-heading"><span id="toc2">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14067" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="307" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14069" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-500x266.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-300x160.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc3">特定レコードの選択</span></h3>



<h4 class="wp-block-heading">データベース(jinji)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="574" height="219" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s01a.jpg" alt="選択されたデータベースjinjiのテーブル一覧" class="wp-image-14139" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s01a.jpg 574w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s01a-500x191.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s01a-300x114.jpg 300w" sizes="(max-width: 574px) 100vw, 574px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブル(staff_list)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="249" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s02a.jpg" alt="選択されたテーブルstaff_listのデータ一覧" class="wp-image-14140" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s02a.jpg 569w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s02a-500x219.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s02a-300x131.jpg 300w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<p><span class="bold-red"></span></p>



<h4 class="wp-block-heading">SQL構文の入力</h4>



<p>「表示」タブでSQLが表示されていますので、これを変更します。<br>注意:<br>「SQL」タブをクリックして、テキストエリアで入力しますが、「インラインを編集する」をクリックして直接編集もできます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="581" height="47" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s03a.jpg" alt="SELECT構文の記載方法" class="wp-image-14141" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s03a.jpg 581w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s03a-500x40.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s03a-300x24.jpg 300w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<p></p>



<p>①id=2のレコードのみを取り出します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="495" height="490" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s04a.jpg" alt="staff_listよりid=2のレコードのみを取り出すSQL構文と実行結果" class="wp-image-14142" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s04a.jpg 495w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s04a-300x297.jpg 300w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s04a-100x100.jpg 100w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p></p>



<p>※検索の対象となっているカラムにはオレンジ色の枠が付きます。</p>



<p>②年齢≧36の方のみを取り出してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="495" height="541" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s05a.jpg" alt="staff_listより年齢が36歳以上の方のみを取り出すSQL構文と実行結果" class="wp-image-14143" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s05a.jpg 495w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s05a-300x328.jpg 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p></p>



<p>③「看護師」の方のみを抜き出してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="503" height="499" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s06a.jpg" alt="staff_listよりskillがi看護師の方のみを取り出すSQL構文と実行結果" class="wp-image-14144" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s06a.jpg 503w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s06a-500x496.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s06a-300x298.jpg 300w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s06a-150x150.jpg 150w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s06a-100x100.jpg 100w" sizes="(max-width: 503px) 100vw, 503px" /></figure>



<p></p>



<p>④前方一致検索</p>



<p>前から゛介護゛という文字列が一致したレコードを抜き出してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="503" height="527" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s07a.jpg" alt="staff_listよりskillの前から介護という文字列が一致したレコードのみを取り出すSQL構文と実行結果" class="wp-image-14145" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s07a.jpg 503w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s07a-500x524.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s07a-300x314.jpg 300w" sizes="(max-width: 503px) 100vw, 503px" /></figure>



<p></p>



<p>⑤後方一致検索</p>



<p>後ろから゛福祉士゛という文字列が一致したレコードを抜き出してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="502" height="297" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s08a.jpg" alt="staff_listよりskillの後ろから福祉士という文字列が一致したレコードのみを取り出すSQL構文と実行結果" class="wp-image-14146" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s08a.jpg 502w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s08a-500x296.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s08a-300x177.jpg 300w" sizes="(max-width: 502px) 100vw, 502px" /></figure>



<p></p>



<p>⑥複数条件の指定</p>



<p>年齢≦36で、゛ヘルパー゛という文字列と一致した方を抜き出してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="503" height="550" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s09a.jpg" alt="staff_listより年齢が36歳以下で、ヘルパーという文字列が一致した方のみを取り出すSQL構文と実行結果" class="wp-image-14147" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s09a.jpg 503w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s09a-500x547.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s09a-300x328.jpg 300w" sizes="(max-width: 503px) 100vw, 503px" /></figure>



<p></p>



<h2 class="wp-block-heading"><span id="toc4">SELECT-GROUP BY</span></h2>



<p>業務で良く利用する「集計」について説明します。例えば、一日の売上合計や商品別の売上実績等いろいろな集計が行われています。ここでは、介護施設として、どのスタッフが、何人利用者を集めたかの集客履歴をとっていくとします。そのため、「syukyaku」というテーブルを作成して、「syukyaku」テーブルを使って、「GROUP BY」を説明します。現在のスタッフは、以下の4名とします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="574" height="263" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s11a.jpg" alt="選択されたstaff_listのデータ一覧" class="wp-image-14148" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s11a.jpg 574w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s11a-500x229.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s11a-300x137.jpg 300w" sizes="(max-width: 574px) 100vw, 574px" /></figure>



<h3 class="wp-block-heading"><span id="toc5">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14067" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="307" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14069" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-500x266.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-300x160.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc6">テーブルの作成</span></h3>



<p>データベース「jinji」をクリックして、syukyakuという名前のテーブルを作成します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="639" height="257" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s12a.jpg" alt="選択したjinjiのテーブル一覧" class="wp-image-14149" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s12a.jpg 639w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s12a-500x201.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s12a-300x121.jpg 300w" sizes="(max-width: 639px) 100vw, 639px" /></figure>



<h4 class="wp-block-heading">テーブル名、カラム数の入力</h4>



<p>カラム数=3の「syukaku」という名前のテーブルを作成します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="580" height="81" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s13a.jpg" alt="テーブル名とカラム数の入力画面" class="wp-image-14150" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s13a.jpg 580w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s13a-500x70.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s13a-300x42.jpg 300w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<p></p>



<h4 class="wp-block-heading">カラム名、データ型の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="589" height="300" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s14a.jpg" alt="テーブルsyukyakuのカラム名、データ型の選択画面" class="wp-image-14151" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s14a.jpg 589w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s14a-500x255.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s14a-300x153.jpg 300w" sizes="(max-width: 589px) 100vw, 589px" /></figure>



<p></p>



<p>「保存する」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="589" height="272" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s15a.jpg" alt="追加されたテーブルsyukyakuのテーブル構造" class="wp-image-14152" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s15a.jpg 589w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s15a-500x231.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s15a-300x139.jpg 300w" sizes="(max-width: 589px) 100vw, 589px" /></figure>



<p></p>



<p>このsyukyakuというテーブルでは、どのスタッフが何人集客したかを記録していくものとなります。</p>



<h3 class="wp-block-heading"><span id="toc7">データの挿入</span></h3>



<p>それでは、データを入れていきますが、折角なのでSQLを使ってデータを入れていきます。次のように入力します。<br></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="580" height="46" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s16a.jpg" alt="INSERT INTOのSQL構文の記載方法" class="wp-image-14153" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s16a.jpg 580w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s16a-500x40.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s16a-300x24.jpg 300w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<h4 class="wp-block-heading">SQL構文の入力</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="390" height="493" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s17a.jpg" alt="SQL構文の入力と実行結果の画面" class="wp-image-14154" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s17a.jpg 390w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s17a-300x379.jpg 300w" sizes="(max-width: 390px) 100vw, 390px" /></figure>



<p></p>



<h4 class="wp-block-heading">「表示」タブのクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="423" height="227" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s18a.jpg" alt="選択したsyukyakuのデータ一覧" class="wp-image-14155" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s18a.jpg 423w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s18a-300x161.jpg 300w" sizes="(max-width: 423px) 100vw, 423px" /></figure>



<p></p>



<h4 class="wp-block-heading">リレーションを貼る</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="610" height="46" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s19a.jpg" alt="リレーションを貼ったSQL構文" class="wp-image-14156" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s19a.jpg 610w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s19a-500x38.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s19a-300x23.jpg 300w" sizes="(max-width: 610px) 100vw, 610px" /></figure>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="513" height="622" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s20a.jpg" alt="リレーションを貼ったSQL構文と実行結果の画面" class="wp-image-14157" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s20a.jpg 513w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s20a-500x606.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s20a-300x364.jpg 300w" sizes="(max-width: 513px) 100vw, 513px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc8">データの集計</span></h3>



<h4 class="wp-block-heading">SUM(count)</h4>



<p>それでは、syukyakuの中の数字、全体でどのくらい集客できたのか?を見ると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="568" height="46" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s21a.jpg" alt="SUMのSQL構文" class="wp-image-14158" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s21a.jpg 568w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s21a-500x40.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s21a-300x24.jpg 300w" sizes="(max-width: 568px) 100vw, 568px" /></figure>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="427" height="665" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s22a.jpg" alt="SUMのSQL構文と実行結果の画面" class="wp-image-14159" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s22a.jpg 427w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s22a-300x467.jpg 300w" sizes="(max-width: 427px) 100vw, 427px" /></figure>



<p></p>



<p>全体では、集客は、7名でした。</p>



<h4 class="wp-block-heading">GROUP BY</h4>



<p>全体の合計ではなく、スタッフ毎の合計を出したい時は、GROUP BY句を使います。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="568" height="46" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s23a.jpg" alt="GROUP BYのSQL構文" class="wp-image-14160" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s23a.jpg 568w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s23a-500x40.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s23a-300x24.jpg 300w" sizes="(max-width: 568px) 100vw, 568px" /></figure>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="461" height="521" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s24a.jpg" alt="BROUP BYのSQL構文と実行結果の画面" class="wp-image-14161" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s24a.jpg 461w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s24a-300x339.jpg 300w" sizes="(max-width: 461px) 100vw, 461px" /></figure>



<p></p>



<p>※GROUP BY句を使う場合は、GROUP BY句で指定したカラムがSELECTの中にも入っていないと正しく動作しませんので注意が必要です。</p>



<p>item_idではわかりにくい場合は、リレーションを貼ると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="443" height="176" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s25a.jpg" alt="リレーションを貼ったSQLと実行結果の画面" class="wp-image-14162" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s25a.jpg 443w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s25a-300x119.jpg 300w" sizes="(max-width: 443px) 100vw, 443px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc9">LEFTJOIN、RIGHTJOIN</span></h3>



<p>GROUP BY句で、スタッフ毎の集客数を集計することができました。が、この集計では&#8217;紀貫之さんの実績は、どこにも表示されていません。実績がなくても紀貫之さんの実績は0として表示したいという場合があります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="610" height="442" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s26a.jpg" alt="LEFTJOIN、RIGHTJOINのSQL構文と実行結果の画面" class="wp-image-14163" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s26a.jpg 610w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s26a-500x362.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s26a-300x217.jpg 300w" sizes="(max-width: 610px) 100vw, 610px" /></figure>



<h4 class="wp-block-heading">内部結合</h4>



<p>カンマ(,)で区切ってテーブルを並べる方法を「内部結合」と言い、2つのテーブルを比較して、結合条件に一致したレコードだけを返します。従ってどちらかのテーブルにデータがなければ返しません。<br>注意:JOIN、カンマ( , )、INNER JOINはどれも意味は同じです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="421" height="63" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s27a.jpg" alt="内部結合のSQLの記載方法" class="wp-image-14164" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s27a.jpg 421w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s27a-300x45.jpg 300w" sizes="(max-width: 421px) 100vw, 421px" /></figure>



<p></p>



<h4 class="wp-block-heading">外部結合</h4>



<p>外部結合には、LEFT JOINとRIGHT JOINがあります。JOINの前に記述したテーブルを左、JOINの後に記述したテーブルを右として、LEFT JOINは左側のテーブルが結合条件に一致しなくてもレコードを返し、RIGHTJOINは右側のテーブルが結合条件に一致しなくてもレコードを返します。全部のデータを見たいテーブル(staff_list)を先に書き、LEFT JOIN ONと書き、その後にリレーションを記述します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="421" height="74" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s271a.jpg" alt="外部結合のSQLの記載方法" class="wp-image-14165" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s271a.jpg 421w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s271a-300x53.jpg 300w" sizes="(max-width: 421px) 100vw, 421px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQL構文の入力</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="581" height="70" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s28a.jpg" alt="SQLの記載方法" class="wp-image-14166" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s28a.jpg 581w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s28a-500x60.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s28a-300x36.jpg 300w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="579" height="384" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s29a.jpg" alt="SQL構文と実行結果の画面" class="wp-image-14167" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s29a.jpg 579w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s29a-500x332.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s29a-300x199.jpg 300w" sizes="(max-width: 579px) 100vw, 579px" /></figure>



<p></p>



<p>これで、紀貫之さんが表示されました。</p>



<h2 class="wp-block-heading"><span id="toc10">SELECT-ORDER BY</span></h2>



<h3 class="wp-block-heading"><span id="toc11">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14067" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="307" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14069" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-500x266.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-300x160.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc12">レコードの並び替え</span></h3>



<h4 class="wp-block-heading">データベース(jinji)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="574" height="216" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s31a.jpg" alt="選択したjinjiのテーブル一覧" class="wp-image-14168" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s31a.jpg 574w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s31a-500x188.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s31a-300x113.jpg 300w" sizes="(max-width: 574px) 100vw, 574px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブル(staff_list)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="574" height="263" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s32a.jpg" alt="選択したstaff_listのデータ一覧" class="wp-image-14169" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s32a.jpg 574w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s32a-500x229.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s32a-300x137.jpg 300w" sizes="(max-width: 574px) 100vw, 574px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQL構文の入力</h4>



<p>「インラインを編集する。」をクリックして、SQLを発行します。<br>idの若い順に並んでいるように見えますが、実際は登録の順ですので、これをidの昇順に並び替えます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="580" height="46" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s33a.jpg" alt="idの昇順または降順に並び替えるSQL構文" class="wp-image-14170" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s33a.jpg 580w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s33a-500x40.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s33a-300x24.jpg 300w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<p></p>



<p>①idの昇順に並び替え</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="557" height="422" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s34a.jpg" alt="idの昇順に並び替えるSQL構文と、実行結果の画面" class="wp-image-14171" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s34a.jpg 557w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s34a-500x379.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s34a-300x227.jpg 300w" sizes="(max-width: 557px) 100vw, 557px" /></figure>



<p></p>



<p>見た目はかわりませんが、今回は確実にid順に並んでいます。ORDER BYは並び順を指定するという意味で、ASCはAscending(アセンディング)の略で、英語で上昇という意味がありますが、ここでは「昇順」という意味となります。Ascendingの反対がDescendingといい「降順」となります。(DESC)ORDER BYはデフォルトはASCですので、実際はASCを省略することができます。<br>例:SELECT * FROM staff_list ORDER BY id</p>



<p>②idの降順に並び替え</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="555" height="422" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s35a.jpg" alt="idの降順に並び替えるSQL構文と、実行結果の画面" class="wp-image-14172" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s35a.jpg 555w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s35a-500x380.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s35a-300x228.jpg 300w" sizes="(max-width: 555px) 100vw, 555px" /></figure>



<p></p>



<p>③WHERE句と組み合わせる</p>



<p>年齢≧36の者を年齢の若い順に並べます。<br>注意:WHERE句が先で、ORDER BY句が後となりますので注意が必要です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="554" height="408" src="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s36a.jpg" alt="WHERE句と組み合わせたSQL構文と実行結果の画面" class="wp-image-14173" srcset="https://gungii.com/wp/wp-content/uploads/2020/05/admin-s36a.jpg 554w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s36a-500x368.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/05/admin-s36a-300x221.jpg 300w" sizes="(max-width: 554px) 100vw, 554px" /></figure>



<p></p>



<p>留意:<br>並び替えで、textの場合、ひらがな→カタカナ→漢字となるため、ふりがな順にならない場合があります。例えば、コンピーターは漢字は漢字コード順に並ぶだけで、ふりがなは読めません。そこで、フリガナというカラムを1つ追加して、フリガナを入力しておくと、そのフリカナで並び替えることができます。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>phpMyAdminの使い方_SQL(CRUD)の実行</title>
		<link>https://gungii.com/admin-cinfo/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Sat, 25 Apr 2020 14:56:14 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[データベース]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=8209</guid>

					<description><![CDATA[SQL(Structured Query Language)は、リレーショナルデータベース管理システム (RDBMS) において、データの操作や定義を行うためのデータベース言語(問い合わせ言語)です。SQLは国際標準化さ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>SQL(Structured Query Language)は、リレーショナルデータベース管理システム (RDBMS) において、データの操作や定義を行うためのデータベース言語(問い合わせ言語)です。SQLは国際標準化されているので、MySQLやOracleなどのデータベースが変わったとしても、同じSQLで操作することが可能です。</p>



<p>[ リレーショナルデータベース ]<br>リレーショナルデータベースでは、データをExcelのように表形式のイメージでデータを保存しています。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="417" height="222" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c01a.jpg" alt="リレーショナルデータベースのイメージ図" class="wp-image-14108" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c01a.jpg 417w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c01a-300x160.jpg 300w" sizes="(max-width: 417px) 100vw, 417px" /></figure>



<p>RDBMSはデータベース内の「テーブル」に入っているデータを「SQL」という言語を使って操作します。主に以下のようなデータ操作が可能です。</p>



<p>・Create・・・データの生成(INSERT命令で追加)<br>・Read・・・・データの読み取りと表示(SELECT命令で実現)<br>・Update・・・データの更新(UPDATE命令で実行)<br>・Delete・・・データの削除(DELETE命令で実行)</p>



<p>※上記の４つの機能をCRUD(クラッド)「Create(生成)、Read(読み取り),Update(更新),Delete(削除)」といい、基本的にデータベースを使ったWebアプリはこれらの機能が前提になっています。</p>



<p>[ SQLの実行 ]<br>SQLは基本的はコマンドラインと言われるもので利用します。Macの場合はターミナルというソフトウェア、Windowsの場合はコマンドプロンプトというソフトウェアで利用しますが、ここではソフトを利用せずに、phpMyAdminのツールを使ってSQLを利用する方法をご紹介します。「SQL」というタブをクリックすると、大きなテキストエリアが表示されます。ここにSQLを記述することで、データベースにそのSQLの指示を与えることができます</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="469" height="212" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c02a.jpg" alt="データベースjinjiのSQLタブのテキストエリア" class="wp-image-14110" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c02a.jpg 469w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c02a-300x136.jpg 300w" sizes="(max-width: 469px) 100vw, 469px" /></figure>



<p>SQLを記述する際には、次のような基本的なルールがあります。</p>



<ul class="wp-block-list"><li>SQL文の最後にセミコロン「;」を付ける<br>PHPと同じ、SQLでも命令の終わりには;(セミコロン)を付けます。例:SELECT * FROM tables;</li><li>大文字/小文字は区別しない<br>SQLでは命令部の大文字/小文字は区別しません。このため「SELECT」でも「select」でも構いませんが、キーワードは大文字で記述するのが慣例です。但し、データベース名やテーブル名、カラム名等は区別されます。</li><li>文字列はシングルクォーテーション「’」で囲む<br>例:INSERT INTO staff_list SET id=1, staff_name=&#8217;中村&#8217;, age=67;<br>※数値は何かで囲む必要はなく、そのまま記述します。</li><li>カラムの設定文字数を超えない<br>カラムに設定した文字数を超える値を指定すると、その値は切り捨てられます。</li></ul>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-12" checked><label class="toc-title" for="toc-checkbox-12">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">テーブルの作成とデータの挿入(C)</a><ol><li><a href="#toc2" tabindex="0">XAMPPの起動</a></li><li><a href="#toc3" tabindex="0">データベースの選択</a></li><li><a href="#toc4" tabindex="0">テーブルの作成</a></li><li><a href="#toc5" tabindex="0">データの挿入</a></li></ol></li><li><a href="#toc6" tabindex="0">データの検索(R)</a><ol><li><a href="#toc7" tabindex="0">XAMPPの起動</a></li><li><a href="#toc8" tabindex="0">データベースの選択</a></li><li><a href="#toc9" tabindex="0">データの検索</a></li></ol></li><li><a href="#toc10" tabindex="0">データの変更・削除(UD)</a><ol><li><a href="#toc11" tabindex="0">データの変更</a></li><li><a href="#toc12" tabindex="0">データの削除</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">テーブルの作成とデータの挿入(C)</span></h2>



<h3 class="wp-block-heading"><span id="toc2">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="467" height="302" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c11a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14111" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c11a.jpg 467w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c11a-300x194.jpg 300w" sizes="(max-width: 467px) 100vw, 467px" /></figure>



<p></p>



<h4 class="wp-block-heading">phpMyAdminの起動</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="470" height="241" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c12a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14112" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c12a.jpg 470w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c12a-300x154.jpg 300w" sizes="(max-width: 470px) 100vw, 470px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc3">データベースの選択</span></h3>



<p>jinjiを選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="463" height="242" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c13a.jpg" alt="データベースjinjiのテーブル一覧" class="wp-image-14113" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c13a.jpg 463w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c13a-300x157.jpg 300w" sizes="(max-width: 463px) 100vw, 463px" /></figure>



<h3 class="wp-block-heading"><span id="toc4">テーブルの作成</span></h3>



<h4 class="wp-block-heading">SQLタブのクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="469" height="212" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c14a.jpg" alt="SQLタブをクリックしたデータベースjinji" class="wp-image-14114" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c14a.jpg 469w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c14a-300x136.jpg 300w" sizes="(max-width: 469px) 100vw, 469px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQL構文の入力(CREATE TABLE)</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="468" height="249" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c15a.jpg" alt="入力されたSQL構文" class="wp-image-14115" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c15a.jpg 468w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c15a-300x160.jpg 300w" sizes="(max-width: 468px) 100vw, 468px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQL実行結果</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="469" height="213" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c16a.jpg" alt="SQLの実行で追加されたテーブルstaff_list" class="wp-image-14116" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c16a.jpg 469w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c16a-300x136.jpg 300w" sizes="(max-width: 469px) 100vw, 469px" /></figure>



<p></p>



<p>staff_listというテーブルができました。<br>注意:「返り値が空でした」と表示されますが、これは正常な動作です。<br>staff_listをクリックすると、idとstaff_nameとageという3つのカラムがあります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="473" height="236" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c17a.jpg" alt="「返り値が空でした」と表示されたstaff_list" class="wp-image-14117" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c17a.jpg 473w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c17a-300x150.jpg 300w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc5">データの挿入</span></h3>



<h4 class="wp-block-heading">SQLタブのクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="552" height="234" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c18a.jpg" alt="表示されたstaff_listのSQL入力画面" class="wp-image-14118" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c18a.jpg 552w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c18a-500x212.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c18a-300x127.jpg 300w" sizes="(max-width: 552px) 100vw, 552px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQL構文の入力(INSERT)</h4>



<p>中身を消して、次のように入力します。</p>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="551" height="234" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c19a.jpg" alt="SQL構文を入力したstaff_list" class="wp-image-14120" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c19a.jpg 551w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c19a-500x212.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c19a-300x127.jpg 300w" sizes="(max-width: 551px) 100vw, 551px" /></figure>



<h4 class="wp-block-heading">SQL実行結果</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="551" height="266" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c20aa.jpg" alt="SQLを実行したstaff_list" class="wp-image-14121" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c20aa.jpg 551w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c20aa-500x241.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c20aa-300x145.jpg 300w" sizes="(max-width: 551px) 100vw, 551px" /></figure>



<p></p>



<p>表示タブをクリックすると、</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="547" height="237" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c20ba.jpg" alt="SQL実行結果が表示されたstaff_listの表示タブ" class="wp-image-14122" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c20ba.jpg 547w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c20ba-500x217.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c20ba-300x130.jpg 300w" sizes="(max-width: 547px) 100vw, 547px" /></figure>



<p></p>



<h2 class="wp-block-heading"><span id="toc6">データの検索(R)</span></h2>



<h3 class="wp-block-heading"><span id="toc7">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="467" height="302" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c11a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14111" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c11a.jpg 467w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c11a-300x194.jpg 300w" sizes="(max-width: 467px) 100vw, 467px" /></figure>



<p></p>



<h4 class="wp-block-heading">phpMyAdminの起動</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="470" height="241" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c12a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14112" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c12a.jpg 470w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c12a-300x154.jpg 300w" sizes="(max-width: 470px) 100vw, 470px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc8">データベースの選択</span></h3>



<p>jinjiを選択</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="431" height="242" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c31a.jpg" alt="選択されたデータベースjinji" class="wp-image-14123" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c31a.jpg 431w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c31a-300x168.jpg 300w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c31a-120x68.jpg 120w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c31a-160x90.jpg 160w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c31a-320x180.jpg 320w" sizes="(max-width: 431px) 100vw, 431px" /></figure>



<h3 class="wp-block-heading"><span id="toc9">データの検索</span></h3>



<h4 class="wp-block-heading">SQLタブのクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="430" height="257" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c32a.jpg" alt="SQL入力エリアの表示されたデータベースjinji" class="wp-image-14124" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c32a.jpg 430w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c32a-300x179.jpg 300w" sizes="(max-width: 430px) 100vw, 430px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQL構文の入力(SELECT)</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="468" height="228" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c33a.jpg" alt="SQL構文が入力されたSQL入力エリア" class="wp-image-14125" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c33a.jpg 468w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c33a-300x146.jpg 300w" sizes="(max-width: 468px) 100vw, 468px" /></figure>



<p></p>



<p>※SQLは、大文字で記述するのが慣例的です。<br>SELECTとは、テーブルの内容を見るという意味のSQLで、※は全て、FROMはどこから、tablesというのは、テーブルの名前となります。</p>



<h4 class="wp-block-heading">SQL実行結果</h4>



<p>テーブル(tables)の内容が表示されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="470" height="294" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c34a.jpg" alt="実行結果が表示されたtables" class="wp-image-14126" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c34a.jpg 470w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c34a-300x188.jpg 300w" sizes="(max-width: 470px) 100vw, 470px" /></figure>



<p></p>



<p>「表示」タブをクリックすると<br>ここで表示タブをクリックすると同じSQLが発行されていることがわかります。つまり、表示タブをクリックした時と同じ動きをSQLで記述したのです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="469" height="267" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c35a.jpg" alt="実行結果が表示されたtables" class="wp-image-14127" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c35a.jpg 469w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c35a-300x171.jpg 300w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c35a-120x68.jpg 120w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c35a-160x90.jpg 160w" sizes="(max-width: 469px) 100vw, 469px" /></figure>



<p></p>



<h2 class="wp-block-heading"><span id="toc10">データの変更・削除(UD)</span></h2>



<h3 class="wp-block-heading"><span id="toc11">データの変更</span></h3>



<h4 class="wp-block-heading">テーブルの選択</h4>



<p>staff_listを選択します。現在、id=1、staff_name=中村、age=67のレコードが1件登録されています。この中村さんのage(年齢)を65に変更します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="547" height="236" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c41a.jpg" alt="データが表示されたstaff_listの表示タブ" class="wp-image-14128" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c41a.jpg 547w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c41a-500x216.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c41a-300x129.jpg 300w" sizes="(max-width: 547px) 100vw, 547px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQLタブのクリック</h4>



<p>SQLタブをクリックして、UPDATE構文を入力して、「実行」します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="546" height="264" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c42a.jpg" alt="SQL構文の記載されたstaff_list" class="wp-image-14129" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c42a.jpg 546w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c42a-500x242.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c42a-300x145.jpg 300w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p></p>



<p>※WHERE構文がなければ、全てのデータが対象となります。</p>



<h4 class="wp-block-heading">SQL実行結果</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="546" height="264" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c43a.jpg" alt="SQL実行結果が表示されたstaff_list" class="wp-image-14130" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c43a.jpg 546w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c43a-500x242.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c43a-300x145.jpg 300w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p></p>



<p>表示タブをクリックすると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="546" height="267" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c44a.jpg" alt="データが表示されたstaff_listの表示タブ" class="wp-image-14131" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c44a.jpg 546w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c44a-500x245.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c44a-300x147.jpg 300w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc12">データの削除</span></h3>



<h4 class="wp-block-heading">テーブルの選択</h4>



<p>staff_listを選択します。現在、id=1、staff_name=中村、age=67のレコードが1件登録されています。これを削除してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="547" height="236" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c45a.jpg" alt="データが表示されたstaff_listの表示タブ" class="wp-image-14132" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c45a.jpg 547w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c45a-500x216.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c45a-300x129.jpg 300w" sizes="(max-width: 547px) 100vw, 547px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQLタブのクリック</h4>



<p>SQLタブのクリックして、DELETE構文を入力して、「実行」します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="545" height="455" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c46a.jpg" alt="SQL構文の入力されたstaff_listのSQLテキストエリア" class="wp-image-14133" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c46a.jpg 545w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c46a-500x417.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c46a-300x250.jpg 300w" sizes="(max-width: 545px) 100vw, 545px" /></figure>



<p></p>



<h4 class="wp-block-heading">SQL実行結果</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="546" height="264" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c47a.jpg" alt="SQL実行結果が表示されたstaff_list" class="wp-image-14134" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c47a.jpg 546w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c47a-500x242.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c47a-300x145.jpg 300w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p></p>



<p>表示タブをクリックすると</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="546" height="273" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c48a.jpg" alt="データが表示されたstaff_listの表示タブ" class="wp-image-14135" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-c48a.jpg 546w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c48a-500x250.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-c48a-300x150.jpg 300w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>phpMyAdminの使い方_データベースの作成</title>
		<link>https://gungii.com/admin-dinfo/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Mon, 20 Apr 2020 01:20:56 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[データベース]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=8165</guid>

					<description><![CDATA[phpを学習するにあたり、データベースの操作は必須となりますが、データベースを操作するにはSQL(StructuredQueryLanguage)という言語でコマンド入力する必要があり、かなりの言語知識と経験が必要となり [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>phpを学習するにあたり、データベースの操作は必須となりますが、データベースを操作するにはSQL(StructuredQueryLanguage)という言語でコマンド入力する必要があり、かなりの言語知識と経験が必要となります。が、SQLは国際標準化されているので、MySQLやOracleなどのデータベースが変わったとしても、同じSQLで操作できますので、覚えていて損はありません。<br>phpMyAdminは、SQLを使わなくてもデータベースをブラウザ経由で簡単に操作できますが、同時にSQLを発行することもできます。今回は、XAMPPのphpMyAdminを使ってSQLを使わずにデータベースの作成やテーブルの作成をやっていますが、最終的にはSQLを発行してデータベースを操作していこうと思います。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-14" checked><label class="toc-title" for="toc-checkbox-14">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">データベースの作成</a><ol><li><a href="#toc2" tabindex="0">XAMPPの起動</a></li><li><a href="#toc3" tabindex="0">データベース(jinji)の作成</a></li></ol></li><li><a href="#toc4" tabindex="0">データベースの削除</a><ol><li><a href="#toc5" tabindex="0">XAMPPの起動</a></li><li><a href="#toc6" tabindex="0">データベース(jinji)の削除</a></li></ol></li><li><a href="#toc7" tabindex="0">テーブルの作成とデータの挿入</a><ol><li><a href="#toc8" tabindex="0">XAMPPの起動</a></li><li><a href="#toc9" tabindex="0">テーブルの作成</a></li><li><a href="#toc10" tabindex="0">テーブルへのデータ入力</a></li></ol></li><li><a href="#toc11" tabindex="0">テーブルの削除とデータの削除</a><ol><li><a href="#toc12" tabindex="0">XAMPPの起動</a></li><li><a href="#toc13" tabindex="0">データの削除</a></li><li><a href="#toc14" tabindex="0">テーブルの削除</a></li></ol></li><li><a href="#toc15" tabindex="0">カラムの追加とデータの挿入</a><ol><li><a href="#toc16" tabindex="0">XAMPPの起動</a></li><li><a href="#toc17" tabindex="0">カラムの追加</a></li><li><a href="#toc18" tabindex="0">カラムへのデータの挿入</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">データベースの作成</span></h2>



<h3 class="wp-block-heading"><span id="toc2">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14067" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="307" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14069" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-500x266.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-300x160.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc3">データベース(jinji)の作成</span></h3>



<h4 class="wp-block-heading">「データベース」タブのクリック</h4>



<p>「jinji」と入力、つづいて照合順序(文字コードの事)のutf8mb4のgeneral_ciを選択して「作成」ボタンをクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="348" height="270" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d03a.jpg" alt="選択されたデータベースタブの画面" class="wp-image-14070" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d03a.jpg 348w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d03a-300x233.jpg 300w" sizes="(max-width: 348px) 100vw, 348px" /></figure>



<p></p>



<h4 class="wp-block-heading">データベース名の入力</h4>



<p>「jinji」と入力、つづいて照合順序(文字コードの事)のutf8mb4のgeneral_ciを選択して「作成」ボタンをクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="349" height="492" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d04a.jpg" alt="データベース名の入力と照合順序の選択がされたデータベース" class="wp-image-14071" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d04a.jpg 349w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d04a-300x423.jpg 300w" sizes="(max-width: 349px) 100vw, 349px" /></figure>



<p></p>



<p>留意：<br>データベースにおける照合順序とは文字と文字の比較や並び順における重み付けで使われるルールのことです。</p>



<p>[ MariaDB(MySQL)の照合順序 ]</p>



<ul class="wp-block-list"><li>MariaDBで日本語を扱う際に選ぶ照合順序は基本的に以下の3つです。</li><li>utf8mb4_general_ci:英字の大文字小文字を区別しない。ほかは区別する。</li><li>utf8mb4_unicode_ci:英字の大文字小文字を区別せず、半角全角もひらがなカタカナも区別しない</li><li>utf8mb4_bin:全部区別する。文字コードがすべて。</li></ul>



<p>※前半の utf8mb4 が文字セットで、後半の general_ci/unicode_ci/bin が照合順序です。</p>



<h2 class="wp-block-heading"><span id="toc4">データベースの削除</span></h2>



<h3 class="wp-block-heading"><span id="toc5">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14067" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="307" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14069" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-500x266.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-300x160.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc6">データベース(jinji)の削除</span></h3>



<h4 class="wp-block-heading">データベース(jinji)のクリック</h4>



<p>削除するデータベースを選択します。ここでは、jinjiを選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="259" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d11a.jpg" alt="表示されたデータベースjinjiの構造タブ" class="wp-image-14072" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d11a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d11a-500x224.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d11a-300x135.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h4 class="wp-block-heading">「操作」タブのクリック</h4>



<p>「操作」タブのクリックして、「データベースを削除する」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="580" height="409" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d12a.jpg" alt="データベースの「削除」ボタンを押下されたデータベースjinji" class="wp-image-14073" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d12a.jpg 580w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d12a-500x353.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d12a-300x212.jpg 300w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<p></p>



<h4 class="wp-block-heading">データベース(jinji)の削除</h4>



<p>データベース(jinji)が削除されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="551" height="341" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d13a.jpg" alt="データベースjinjiの削除されたデータベースタブ" class="wp-image-14074" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d13a.jpg 551w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d13a-500x309.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d13a-300x186.jpg 300w" sizes="(max-width: 551px) 100vw, 551px" /></figure>



<p></p>



<h2 class="wp-block-heading"><span id="toc7">テーブルの作成とデータの挿入</span></h2>



<h3 class="wp-block-heading"><span id="toc8">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14067" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="307" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14069" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-500x266.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-300x160.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc9">テーブルの作成</span></h3>



<h4 class="wp-block-heading">テータベース(jinji)の選択</h4>



<p>データベースの作成の直後は、テーブル作成画面となりますので、続けてデータベースにテーブルを作成します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="567" height="226" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d21a.jpg" alt="テーブル作成画面が表示されたデータベースjinji" class="wp-image-14075" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d21a.jpg 567w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d21a-500x199.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d21a-300x120.jpg 300w" sizes="(max-width: 567px) 100vw, 567px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブルの作成</h4>



<p>①テーブル名、カラム数の入力</p>



<p>テーブルを作成するには、テーブル名とカラム数を入力して「実行」をクリックします。(ここでは、名前=tables、カラム数=2と入力)</p>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="495" height="192" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d22a.jpg" alt="テーブル名とカラム数を入力したjinjiのテーブル" class="wp-image-14077" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d22a.jpg 495w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d22a-300x116.jpg 300w" sizes="(max-width: 495px) 100vw, 495px" /></figure>



<p>すると、カラムを設定する画面が表示されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="496" height="247" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d23a.jpg" alt="表示されたtablesのカラム設定画面" class="wp-image-14078" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d23a.jpg 496w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d23a-300x149.jpg 300w" sizes="(max-width: 496px) 100vw, 496px" /></figure>



<p></p>



<p>②カラム名、データ型の入力</p>



<p>名前はid、name、データ型はint、textを選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="549" height="253" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d24a.jpg" alt="tablesのカラム名、データ型の入力画面" class="wp-image-14079" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d24a.jpg 549w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d24a-500x230.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d24a-300x138.jpg 300w" sizes="(max-width: 549px) 100vw, 549px" /></figure>



<p></p>



<p>③プライマリーキーの設定</p>



<p>idのカラムを右にスクロールすると、インデックスの設定項目がありますので、PRIMARYを選択します。また、同時にAI(オートインクリメント)もチェックしておきます。<br>注意：ここではプライマリーキー、及びオートインクリメントについての説明は省略します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="548" height="447" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d25a.jpg" alt="tablesのプライマリーキーの設定画面" class="wp-image-14080" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d25a.jpg 548w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d25a-500x408.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d25a-300x245.jpg 300w" sizes="(max-width: 548px) 100vw, 548px" /></figure>



<p></p>



<p>他にも、設定する項目がありますが、ここではこのまま「保存する」をクリックします。</p>



<p>④テーブルの完成</p>



<p>これでテーブルが出来上がりました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="563" height="263" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d26a.jpg" alt="完成したtablesのテーブル構造" class="wp-image-14081" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d26a.jpg 563w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d26a-500x234.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d26a-300x140.jpg 300w" sizes="(max-width: 563px) 100vw, 563px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc10">テーブルへのデータ入力</span></h3>



<p>それでは、出来上がったテーブル(id,name)にデータを挿入していきます。</p>



<h4 class="wp-block-heading">「挿入」タブのクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="476" height="430" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d27a.jpg" alt="tablesのデータ入力画面" class="wp-image-14082" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d27a.jpg 476w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d27a-300x271.jpg 300w" sizes="(max-width: 476px) 100vw, 476px" /></figure>



<p></p>



<h4 class="wp-block-heading">値の入力</h4>



<p>値に、id=1、name=小野小町と入力して「実行」ボタンをクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="486" height="576" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d28a.jpg" alt="id=1、name=小野小町と入力されたtablesのデータ入力画面" class="wp-image-14083" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d28a.jpg 486w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d28a-300x356.jpg 300w" sizes="(max-width: 486px) 100vw, 486px" /></figure>



<p></p>



<h4 class="wp-block-heading">入力内容の確認</h4>



<p>「表示」タブをクリックして、データが入力されたことを確認します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="533" height="225" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d29a.jpg" alt="入力されているデータが表示されたtablesの表示タブ" class="wp-image-14084" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d29a.jpg 533w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d29a-500x211.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d29a-300x127.jpg 300w" sizes="(max-width: 533px) 100vw, 533px" /></figure>



<p></p>



<h4 class="wp-block-heading">値の追加</h4>



<p>続けて、id=2,3を登録します。<br>注意：続けて登録する場合は、横の「実行」ではなく、最終行の「実行」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="469" height="757" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d30a.jpg" alt="データを追加入力したtablesの入力画面" class="wp-image-14085" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d30a.jpg 469w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d30a-300x484.jpg 300w" sizes="(max-width: 469px) 100vw, 469px" /></figure>



<p></p>



<p>「2行挿入されました。」と表示されます。</p>



<h4 class="wp-block-heading">入力内容の確認</h4>



<p>「表示」タブをクリックして、データが入力されたことを確認します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="532" height="259" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d31a.jpg" alt="追加データの表示されたtablesの表示タブ" class="wp-image-14086" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d31a.jpg 532w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d31a-500x243.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d31a-300x146.jpg 300w" sizes="(max-width: 532px) 100vw, 532px" /></figure>



<p></p>



<h2 class="wp-block-heading"><span id="toc11">テーブルの削除とデータの削除</span></h2>



<h3 class="wp-block-heading"><span id="toc12">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14067" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="307" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14069" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-500x266.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-300x160.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc13">データの削除</span></h3>



<h4 class="wp-block-heading">テータベース(jinji)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="179" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d41a.jpg" alt="テーブル一覧の表示されたデータベースjinjiの構造タブ" class="wp-image-14087" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d41a.jpg 591w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d41a-500x151.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d41a-300x91.jpg 300w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブルの選択</h4>



<p>jinjiのデータベースの中のtablesというテーブルを選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="534" height="259" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d42a.jpg" alt="データが表示されたtablesの表示タブ" class="wp-image-14088" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d42a.jpg 534w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d42a-500x243.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d42a-300x146.jpg 300w" sizes="(max-width: 534px) 100vw, 534px" /></figure>



<p></p>



<h4 class="wp-block-heading">データの選択</h4>



<p>3件のレコードがありますが、ここでは、id=2、name=小野妹子,age=37のレコードを削除します。削除するレコードを&#x2611;して、「削除」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="535" height="260" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d43a.jpg" alt="削除データを指定したtablesの表示タブ" class="wp-image-14090" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d43a.jpg 535w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d43a-500x243.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d43a-300x146.jpg 300w" sizes="(max-width: 535px) 100vw, 535px" /></figure>



<p></p>



<p>削除の確認メッセージが表示されますので、「はい」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="539" height="107" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d44a.jpg" alt="削除の確認メッセージ" class="wp-image-14091" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d44a.jpg 539w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d44a-500x99.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d44a-300x60.jpg 300w" sizes="(max-width: 539px) 100vw, 539px" /></figure>



<p></p>



<p>削除されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="549" height="249" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d45a.jpg" alt="指定したデータが削除されたtablesの表示タブ" class="wp-image-14092" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d45a.jpg 549w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d45a-500x227.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d45a-300x136.jpg 300w" sizes="(max-width: 549px) 100vw, 549px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc14">テーブルの削除</span></h3>



<h4 class="wp-block-heading">データベースの選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="179" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d46a.jpg" alt="テーブル一覧が表示されたデータベースjinji" class="wp-image-14093" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d46a.jpg 591w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d46a-500x151.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d46a-300x91.jpg 300w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブルの削除</h4>



<p>jinjiの中のテーブル一覧が表示されますので、削除するテーブルを&#x2611;して、「削除」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="598" height="406" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d47a.jpg" alt="削除が選択されたjinjiのtables" class="wp-image-14094" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d47a.jpg 598w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d47a-500x339.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d47a-300x204.jpg 300w" sizes="(max-width: 598px) 100vw, 598px" /></figure>



<p></p>



<p>削除されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="610" height="213" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d48a.jpg" alt="tablesが削除されたjinjiの構造タブ" class="wp-image-14095" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d48a.jpg 610w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d48a-500x175.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d48a-300x105.jpg 300w" sizes="(max-width: 610px) 100vw, 610px" /></figure>



<p></p>



<h2 class="wp-block-heading"><span id="toc15">カラムの追加とデータの挿入</span></h2>



<h3 class="wp-block-heading"><span id="toc16">XAMPPの起動</span></h3>



<h4 class="wp-block-heading">ApacheとMySQLの起動</h4>



<p>MySQLを使うためには、Apacheも必要となりますので、両方起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="364" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14067" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a.jpg 540w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d01a-300x202.jpg 300w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<p></p>



<h4 class="wp-block-heading">MySQLのAdminの起動</h4>



<p>Adminをクリックすると、phpMyAdminというツールが開きます。このphpMyAdminを通してMySQL(MariaDB)にアクセスすることとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="307" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg" alt="起動したphpMyAdminの初期画面" class="wp-image-14069" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a.jpg 577w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-500x266.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d02a-300x160.jpg 300w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc17">カラムの追加</span></h3>



<p>ここでは、既存のテーブルにカラムを追加する方法について説明します。idとnameという2つのカラムを持つテーブル(tables)に、ageというカラムを追加します。</p>



<h4 class="wp-block-heading">データベース(jinji)の選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="629" height="187" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d51a.jpg" alt="テーブル一覧が表示されたデータベースjinji" class="wp-image-14096" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d51a.jpg 629w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d51a-500x149.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d51a-300x89.jpg 300w" sizes="(max-width: 629px) 100vw, 629px" /></figure>



<p></p>



<h4 class="wp-block-heading">テーブル(tables)の選択</h4>



<p>tablesの「構造」タブをクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="633" height="203" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d52a.jpg" alt="表示されたtablesの構造タブ" class="wp-image-14097" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d52a.jpg 633w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d52a-500x160.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d52a-300x96.jpg 300w" sizes="(max-width: 633px) 100vw, 633px" /></figure>



<p></p>



<h4 class="wp-block-heading">カラム数と位置の指定</h4>



<p>追加するカラムの数と位置を指定して、実行をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="391" height="129" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d53a.jpg" alt="tablesのカラム数と位置の設定画面" class="wp-image-14098" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d53a.jpg 391w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d53a-300x99.jpg 300w" sizes="(max-width: 391px) 100vw, 391px" /></figure>



<p></p>



<h4 class="wp-block-heading">カラム設定画面の表示</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="583" height="143" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d54a.jpg" alt="tablesのカラム設定画面" class="wp-image-14099" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d54a.jpg 583w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d54a-500x123.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d54a-300x74.jpg 300w" sizes="(max-width: 583px) 100vw, 583px" /></figure>



<p></p>



<h4 class="wp-block-heading">追加するカラムの設定</h4>



<p>ここでは、age(年齢)を追加します。Ageと入力して「保存する」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="581" height="267" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d55a.jpg" alt="「age」というカラムを追加したtablesのカラム設定画面" class="wp-image-14100" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d55a.jpg 581w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d55a-500x230.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d55a-300x138.jpg 300w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<p></p>



<h4 class="wp-block-heading">追加の確認</h4>



<p>「表示」タブをクリックすると、ageというカラムが追加されているのがわかります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="491" height="260" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d56a.jpg" alt="「age」というカラムが追加されたtablesの表示タブ" class="wp-image-14101" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d56a.jpg 491w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d56a-300x159.jpg 300w" sizes="(max-width: 491px) 100vw, 491px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc18">カラムへのデータの挿入</span></h3>



<h4 class="wp-block-heading">データ入力</h4>



<p>追加したカラムにデータを入力します。レコードを選択して、「編集」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="269" height="234" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d57a.jpg" alt="編集を押下したtablesのデータ" class="wp-image-14102"/></figure>



<p></p>



<p>ageを入力して、「実行」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="472" height="279" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d58a.jpg" alt="「age」のデータを入力したtablesの入力画面" class="wp-image-14103" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d58a.jpg 472w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d58a-300x177.jpg 300w" sizes="(max-width: 472px) 100vw, 472px" /></figure>



<p></p>



<p>同様に、2つのレコードのageカラムを入力します。</p>



<h4 class="wp-block-heading">入力内容の確認</h4>



<p>「表示」タブをクリックすると、3つのレコードのageカラムが入力されていることがわかります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="488" height="352" src="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d59a.jpg" alt="「age」が入力されたtablesの表示タブ" class="wp-image-14105" srcset="https://gungii.com/wp/wp-content/uploads/2020/04/admin-d59a.jpg 488w, https://gungii.com/wp/wp-content/uploads/2020/04/admin-d59a-300x216.jpg 300w" sizes="(max-width: 488px) 100vw, 488px" /></figure>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>XAMPPのダウングレードとphpMyAdminのバージョンアップの方法</title>
		<link>https://gungii.com/xamppdg-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Sat, 14 Mar 2020 07:50:04 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[データベース]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=8073</guid>

					<description><![CDATA[phpの勉強で、データベースを使ったプログラムを作成するために、phpMyAdminを使ってデータベースの登録をしていたところ、「テーブル構造が表示されない。」という不具合が発発生しました。XAMPPを使っていますのでX [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>phpの勉強で、データベースを使ったプログラムを作成するために、phpMyAdminを使ってデータベースの登録をしていたところ、「テーブル構造が表示されない。」という不具合が発発生しました。XAMPPを使っていますのでXAMPPの再インストールを行いましたが、結果は変わりませんでしたが、バージョンダウンしてみると、XAMPPの7.4.1-0では不具合は発生しませんでしたので、その際の対処方法を記録しておきます。又、XAMPPを使用しているとphpMyAdminの最新バージョンへのアップグレードを促されることがありますので、XAMPPでのphpMyAdminのバージョンアップ方法についても、実際の対応を記録します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="474" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg01a.jpg" alt="xamppのphpMyAdminのバージョンアップ対応前と対応後" class="wp-image-14039" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg01a.jpg 600w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg01a-500x395.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg01a-300x237.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p>留意:<br>以下のバージョンのXAMPPでは、phpMyAdminにてデータベースの「テーブル構造が表示されない」という不具合が発生します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="604" height="87" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg02a.jpg" alt="エラーとなるxamppのバージョン" class="wp-image-14041" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg02a.jpg 604w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg02a-500x72.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg02a-300x43.jpg 300w" sizes="(max-width: 604px) 100vw, 604px" /></figure>



<p>注意:xampp-windows-x64-7.4.1-1-VC15ではNGだが、xampp-windows-x64-7.4.1-0-VC15はOKです。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-16" checked><label class="toc-title" for="toc-checkbox-16">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">XAMPPのアンインストール</a><ol><li><a href="#toc2" tabindex="0">アンインストール</a></li><li><a href="#toc3" tabindex="0">アンインストールの確認</a></li></ol></li><li><a href="#toc4" tabindex="0">XAMPPの再インストール</a><ol><li><a href="#toc5" tabindex="0">XAMPPのダウンロード</a></li><li><a href="#toc6" tabindex="0">XAMPPのインストール</a></li><li><a href="#toc7" tabindex="0">不具合解消の確認</a></li></ol></li><li><a href="#toc8" tabindex="0">phpMyAdminのアップグレード</a><ol><li><a href="#toc9" tabindex="0">phpMyAdminのダウンロード</a></li><li><a href="#toc10" tabindex="0">phpMyAdminの置き換え</a></li><li><a href="#toc11" tabindex="0">phpMyAdminの置き換え確認</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">XAMPPのアンインストール</span></h2>



<h3 class="wp-block-heading"><span id="toc2">アンインストール</span></h3>



<p>XAMPPを再インストールするために、現状のXAMPPをアンインストールします。</p>



<h4 class="wp-block-heading">uninstall.exeの検索</h4>



<p>XAMPPフォルダの中に、uninstall.exeがありますので、検索します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="633" height="255" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg11a.jpg" alt="xamppフォルダを選択したWindows(C:)" class="wp-image-14042" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg11a.jpg 633w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg11a-500x201.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg11a-300x121.jpg 300w" sizes="(max-width: 633px) 100vw, 633px" /></figure>



<h4 class="wp-block-heading">uninstall.exeの起動</h4>



<p>uninstall.exeをダブルクリックして起動します。「XAMPPと全てのモジュールを削除して良いか?」との確認メッセージが表示されますが、「YES」を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="452" height="331" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg12a.jpg" alt="起動されたxamppのuninstall.exe" class="wp-image-14043" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg12a.jpg 452w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg12a-300x220.jpg 300w" sizes="(max-width: 452px) 100vw, 452px" /></figure>



<p></p>



<h4 class="wp-block-heading">アンストールの開始</h4>



<p>続けて、「htdocsフォルダも削除して良いか?」との確認メッセージが表示されますが、「YES」を選択します。<br>留意:<br>予め、XAMPPで必要なファイルはバックアップしておきますので、ここでは「YES」、htdocsフォルダを残しておきたい場合は「NO」を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="326" height="275" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg13a.jpg" alt="アンインストールの開始確認画面" class="wp-image-14044" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg13a.jpg 326w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg13a-300x253.jpg 300w" sizes="(max-width: 326px) 100vw, 326px" /></figure>



<p></p>



<h4 class="wp-block-heading">アンストールの終了</h4>



<p>アンインストールが終了すると、以下のように「Uninstllation completed」と表示されますので、「OK」をクリックしてXAMPPのアンインストールは完了です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="326" height="275" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg14a.jpg" alt="アンインストールの終了確認画面" class="wp-image-14045" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg14a.jpg 326w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg14a-300x253.jpg 300w" sizes="(max-width: 326px) 100vw, 326px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc3">アンインストールの確認</span></h3>



<h4 class="wp-block-heading">XAMPPフォルダの確認</h4>



<p>XAMPPフォルダが削除されているかを確認します。例えば、インストールした時と異なり、フォルダやファイルが追加されていると削除されずに残ることが考えられます。今回は、phpmyadminフォルダが残ったため、XAMPPフォルダが削除されていませんでした。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="610" height="242" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg15a.jpg" alt="Windows(C:)のフォルダ一覧" class="wp-image-14046" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg15a.jpg 610w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg15a-500x198.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg15a-300x119.jpg 300w" sizes="(max-width: 610px) 100vw, 610px" /></figure>



<p></p>



<h4 class="wp-block-heading">XAMPPフォルダの削除</h4>



<p>残ったXAMPPフォルダを削除します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="451" height="464" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg16a.jpg" alt="手作業で削除するxamppフォルダ" class="wp-image-14047" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg16a.jpg 451w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg16a-300x309.jpg 300w" sizes="(max-width: 451px) 100vw, 451px" /></figure>



<p></p>



<h4 class="wp-block-heading">パソコンの再起動</h4>



<p>一度、パソコンを再起動しておきます。</p>



<h2 class="wp-block-heading"><span id="toc4">XAMPPの再インストール</span></h2>



<h3 class="wp-block-heading"><span id="toc5">XAMPPのダウンロード</span></h3>



<p>XAMPPのバージョン7.4.1-0ではphpmyadminで「テーブル構造が表示されない。」という不具合は発生しませんので、XAMPPのバージョンをダウングレードして再インストールします。</p>



<h4 class="wp-block-heading">過去のバージョンの検索</h4>



<p>①「ダウンロード」のクリック</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="610" height="295" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg21a.jpg" alt="xamppのダウンロードサイト" class="wp-image-14048" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg21a.jpg 610w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg21a-500x242.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg21a-300x145.jpg 300w" sizes="(max-width: 610px) 100vw, 610px" /></figure>



<p></p>



<p>②その他のダウンロードのクリック</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="409" height="328" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg22a.jpg" alt="「その他のダウンロード」を選択したダウンロードサイト" class="wp-image-14049" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg22a.jpg 409w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg22a-300x241.jpg 300w" sizes="(max-width: 409px) 100vw, 409px" /></figure>



<p></p>



<p>③XAMPP WINDOWSのクリック</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="573" height="303" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg23a.jpg" alt="「xampp windows」を選択したその他のダウンロードサイト" class="wp-image-14050" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg23a.jpg 573w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg23a-500x264.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg23a-300x159.jpg 300w" sizes="(max-width: 573px) 100vw, 573px" /></figure>



<p></p>



<p>④7.4.1のクリック</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="383" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg24a.jpg" alt="バージョン7.4.1を選択したダウンロードサイト" class="wp-image-14051" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg24a.jpg 591w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg24a-500x324.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg24a-300x194.jpg 300w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<p></p>



<p>⑤「xampp windows-x64-7.4.1-0-VC15-installer.exe」のクリック</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="481" height="471" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg25a.jpg" alt="「xampp windows-x64-7.4.1-0-VC15-installer.exe」を選択したダウンロードサイト" class="wp-image-14052" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg25a.jpg 481w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg25a-300x294.jpg 300w" sizes="(max-width: 481px) 100vw, 481px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc6">XAMPPのインストール</span></h3>



<p>インストールの方法については、別ブログ「XAMPPで、Windowsのローカル開発環境を構築する方法」で説明していますので、ここでは省略します。</p>



<h3 class="wp-block-heading"><span id="toc7">不具合解消の確認</span></h3>



<p>「テーブル構造は、表示されています」ので、不具合が解消されたことが確認できます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="599" height="195" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg26a.jpg" alt="不具合解消の確認をしたtablesの構造タブ画面" class="wp-image-14053" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg26a.jpg 599w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg26a-500x163.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg26a-300x98.jpg 300w" sizes="(max-width: 599px) 100vw, 599px" /></figure>



<p>不具合は、解消されましたが、画面下にアップグレードのメッセージが表示されました。この対応については、別項「phpMyAdminのアップグレード」で説明します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="613" height="356" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg27a.jpg" alt="最新バージョンへのアップを促すプロンプトが表示されたphpMyAdmin画面" class="wp-image-14054" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg27a.jpg 613w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg27a-500x290.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg27a-300x174.jpg 300w" sizes="(max-width: 613px) 100vw, 613px" /></figure>



<h2 class="wp-block-heading"><span id="toc8">phpMyAdminのアップグレード</span></h2>



<h3 class="wp-block-heading"><span id="toc9">phpMyAdminのダウンロード</span></h3>



<p>表示されたアップグレードのメッセージをクリックして、最新バージョンをダウンロードして、XAMPPフォルダのphpMyAdminを置き換えます。</p>



<h4 class="wp-block-heading">phpMyAdmin-4.9.4-all-languages.zipの選択</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="609" height="779" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg31a.jpg" alt="phpMyAdminの最新バージョンのインストールexeのダウンロード画面" class="wp-image-14055" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg31a.jpg 609w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg31a-500x640.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg31a-300x384.jpg 300w" sizes="(max-width: 609px) 100vw, 609px" /></figure>



<p></p>



<h4 class="wp-block-heading">zipファイルの解凍</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="278" height="78" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg32a.jpg" alt="ダウンロードされたzipファイルの解凍" class="wp-image-14056"/></figure>



<p></p>



<h4 class="wp-block-heading">ファイルのrename</h4>



<p>フォルダ毎、置き換える為、リネイムします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="616" height="73" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg33a.jpg" alt="renameした解凍済みフォルダ" class="wp-image-14057" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg33a.jpg 616w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg33a-500x59.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg33a-300x36.jpg 300w" sizes="(max-width: 616px) 100vw, 616px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc10">phpMyAdminの置き換え</span></h3>



<h4 class="wp-block-heading">現行フォルダのRENAME</h4>



<p>現行XAMPPフォルダ中のphpMyAdminフォルダをphpMyAdmin-oldとリネイムします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="404" height="593" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg34a.jpg" alt="既存フォルダのrename" class="wp-image-14058" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg34a.jpg 404w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg34a-300x440.jpg 300w" sizes="(max-width: 404px) 100vw, 404px" /></figure>



<p></p>



<h4 class="wp-block-heading">現行config.inc.phpのバックアップ</h4>



<p>phpMyAdmin-oldの中のconfig.inc.phpをバックアップします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="589" height="329" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg35a.jpg" alt="config.inc.hpのバックアップをした既存フォルダ" class="wp-image-14059" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg35a.jpg 589w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg35a-500x279.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg35a-300x168.jpg 300w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg35a-120x68.jpg 120w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg35a-160x90.jpg 160w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg35a-320x180.jpg 320w" sizes="(max-width: 589px) 100vw, 589px" /></figure>



<p></p>



<h4 class="wp-block-heading">ダウンロードしたphpMyAdminフォルダの格納</h4>



<p>解凍してrenameしたphpMyAdminフォルダを、XAMPPフォルダへ移します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="604" height="277" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg36a.jpg" alt="renameしたフォルダを格納したxamppフォルダ" class="wp-image-14060" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg36a.jpg 604w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg36a-500x229.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg36a-300x138.jpg 300w" sizes="(max-width: 604px) 100vw, 604px" /></figure>



<p></p>



<h4 class="wp-block-heading">config.inc.phpの格納</h4>



<p>バックアップしていたconfig.inc.phpをphpMyAdminフォルダへ移します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="335" height="286" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg37a.jpg" alt="config.inc.phpを格納したrenameしたフォルダ" class="wp-image-14061" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg37a.jpg 335w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg37a-300x256.jpg 300w" sizes="(max-width: 335px) 100vw, 335px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc11">phpMyAdminの置き換え確認</span></h3>



<h4 class="wp-block-heading">XAMPPの起動</h4>



<p>XAMPPを起動して、Apache、MySQLを起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="532" height="344" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg38a.jpg" alt="起動したxamppのコントロールパネル" class="wp-image-14062" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg38a.jpg 532w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg38a-500x323.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg38a-300x194.jpg 300w" sizes="(max-width: 532px) 100vw, 532px" /></figure>



<p></p>



<h4 class="wp-block-heading">phpMyAdminの起動</h4>



<p>Adminをクリックして、phpMyAdminを起動します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="533" height="272" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg39a.jpg" alt="Adminを押下して表示されたphpMyAdminの初期画面" class="wp-image-14063" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg39a.jpg 533w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg39a-500x255.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg39a-300x153.jpg 300w" sizes="(max-width: 533px) 100vw, 533px" /></figure>



<p></p>



<p>アップグレードの促進メッセージの表示はなくなりました。テーブル構造もキチンと表示されています。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="538" height="179" src="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg40a.jpg" alt="最新バージョンへのアップを促すプロンプトが表示されなくなったphpMyAdmin画面" class="wp-image-14064" srcset="https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg40a.jpg 538w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg40a-500x166.jpg 500w, https://gungii.com/wp/wp-content/uploads/2020/03/xamppdg40a-300x100.jpg 300w" sizes="(max-width: 538px) 100vw, 538px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
