[root@ambow-school-system-hylm bin]# ll /usr/local/mysql567/init.file
-rw-rw---- 1 mysql mysql 92 Dec 15:43 /usr/local/mysql567/init.file
[root@hylm bin]cat /usr/local/mysql567/init.file
use test;
insert chen select substr(passid,1,7) a, max(passid) as aa from user group by a;
[root@hylm bin]#
mysql> show create table chen\G;
*************************** 1. row ***************************
Table: chen
Create Table: CREATE TABLE `chen` (
`pkey` char(8) default NULL,
`value` char(25) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> show create table USER\G;
*************************** 1. row ***************************
Table: USER
Create Table: CREATE TABLE `user` (
`passid` char(25) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> select * from user;
+-----------------+
| passid |
+-----------------+
| apt1212100000 |
| apt1212100002 |
| apt1212100003 |
| cisco1212100001 |
| cisco1212100002 |
| cisco1212100003 |
| tmp1212100001 |
| tmp1212100002 |
| tmp1212100003 |
+-----------------+
9 rows in set (0.00 sec)
mysql>
重起后就可以看到如下:
mysql> select * from chen;
+---------+-----------------+
| pkey | value |
+---------+-----------------+
| apt1212 | apt1212100003 |
| cisco12 | cisco1212100003 |
| tmp1212 | tmp1212100003 |
+---------+-----------------+