blog/content/post/2009/08/01/2009-08-01-00001207.md

39 lines
3.2 KiB
Markdown
Raw Normal View History

2019-03-31 11:00:21 +00:00
---
title: MySQLでテーブルのコピーを作成する
author: kazu634
date: 2009-08-01
wordtwit_post_info:
- 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4737;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
categories:
- mysql
---
<div class="section">
<p>
<a href="http://tech.lampetty.net/tech/index.php/archives/273" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://tech.lampetty.net/tech/index.php/archives/273', 'MySQLでテーブルのコピーを簡単に作る方法');" target="_blank">MySQLでテーブルのコピーを簡単に作る方法</a>」を参考させていただきましたおいぬまさんとは昨年のEmacs勉強会でご一緒したような記憶が
</p>
<p>
MySQLでテーブルのコピーを作成する方法は下記の通りになります:
</p>
<pre class="syntax-highlight">
kazu634@kazu634-desktop% mysql -uusername -ppassword ~/public_html/cgi-bin [<span class="synConstant">3578</span>]
Welcome <span class="synSpecial">to</span> the MySQL monitor. Commands <span class="synSpecial">end</span> <span class="synSpecial">with</span> ; <span class="synStatement">or</span> \g.
Your MySQL connection id <span class="synSpecial">is</span> <span class="synConstant">133</span>
Server version: <span class="synConstant">5.0</span>.<span class="synConstant">75</span>-0ubuntu10.<span class="synConstant">2</span> (Ubuntu)
<span class="synSpecial">Type</span> <span class="synConstant">'help;'</span> <span class="synStatement">or</span> <span class="synConstant">'\h'</span> <span class="synSpecial">for</span> help. <span class="synSpecial">Type</span> <span class="synConstant">'\c'</span> <span class="synSpecial">to</span> clear the buffer.
mysql&#62; use sample;
Reading <span class="synSpecial">table</span> information <span class="synSpecial">for</span> completion <span class="synSpecial">of</span> <span class="synSpecial">table</span> <span class="synStatement">and</span> <span class="synSpecial">column</span> names
You can turn off this feature <span class="synSpecial">to</span> get a quicker startup <span class="synSpecial">with</span> -A
Database changed
mysql&#62; <span class="synStatement">CREATE</span> <span class="synSpecial">TABLE</span> renoir_20090801 <span class="synStatement">LIKE</span> renoir;
Query OK, <span class="synConstant"></span> <span class="synSpecial">rows</span> affected (<span class="synConstant"></span>.<span class="synConstant">15</span> sec)
mysql&#62; <span class="synStatement">INSERT</span> <span class="synSpecial">INTO</span> renoir_20090801 <span class="synStatement">SELECT</span> * <span class="synSpecial">FROM</span> renoir;
Query OK, <span class="synConstant">87</span> <span class="synSpecial">rows</span> affected (<span class="synConstant"></span>.<span class="synConstant">07</span> sec)
Records: <span class="synConstant">87</span> Duplicates: <span class="synConstant"></span> Warnings: <span class="synConstant"></span>
mysql&#62; exit
Bye
</pre>
</div>