mysql : copy teble

テーブルをコピーしてみます。

table_a を table_b にコピー
mysql> create table table_b like table_a;
Query OK, 0 rows affected (0.32 sec)

mysql> show create table table_b\G;
*************************** 1. row ***************************
Table: table_b
Create Table: CREATE TABLE `table_b` (
`id` varchar(32) NOT NULL,
`url` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
`created_at` datetime default NULL,
`updated_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`site` varchar(8) default ‘Y’,
PRIMARY KEY (`id`),
KEY `index_endtime` (`endtime`),
KEY `updated_at` (`updated_at`),
FULLTEXT KEY `title` USING MECAB, NO NORMALIZE, 512 (`title`,`description`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.01 sec)

ERROR:
No query specified

まぁテーブルの内容は気にしないでもらって title indexをみてもらうとちゃんとsennaの構造も引き継いでますね。

データも入れてみます。
====
まずは件数を確認

mysql> select count(*) from bid where endtime<'2009-11-01 00:00:00';
+----------+
| count(*) |
+----------+
| 156645 |
+----------+
1 row in set (6.14 sec)

mysql> select count(*) from bid where endtime>=’2009-11-01 00:00:00′;
+———-+
| count(*) |
+———-+
| 10510 |
+———-+
1 row in set (0.41 sec

156645個入れてみます。
mysql> insert into bid_0910 select * from bid where endtime<'2009-11-01 00:00:00';
Query OK, 156645 rows affected (13 min 46.06 sec)
Records: 156645 Duplicates: 0 Warnings: 0

大成功したようです^-^。

mysql

This entry was posted on 金曜日, 11月 6th, 2009 at 12:22 AM and is filed under database, mysql. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。