Version: 5.6.16
In your own virtual environment, the test creates a table with the following table structure:
mysql> drop table yoon_temp;
Query OK, 0 rows affected (0.09 sec)
Mysql> Show CREATE TABLE Yoon\g
1. Row ***************************
Table:yoon
Create table:create Table ' Yoon ' (
' id ' int (one) DEFAULT NULL,
' Name ' varchar (DEFAULT NULL)
) Engine=innodb DEFAULT Charset=utf8
1 row in Set (0.00 sec)
Create an identical table structure, name varchar (30) to 30, and modify the field of the Yoon table by replacing the. FRM:
Mysql> Show CREATE TABLE Yoon_temp\g
1. Row ***************************
Table:yoon_temp
Create table:create Table ' yoon_temp ' (
' id ' int (one) DEFAULT NULL,
' Name ' varchar (+) DEFAULT NULL
) Engine=innodb DEFAULT Charset=utf8
1 row in Set (0.00 sec)
Accidentally delete the yoon_temp.frm file directly, cannot be replaced, delete the Yoon_temp prompt table on the database does not exist:
[Email protected] yoon]# RM-RF yoon_temp.frm
Mysql> Show tables;
+----------------+
| Tables_in_yoon |
+----------------+
| Yoon |
+----------------+
1 row in Set (0.00 sec)
To delete a table:
mysql> drop table yoon_temp;
ERROR 1051 (42S02): Unknown table ' Yoon.yoon_temp '
Re-create the table:
Mysql> CREATE TABLE yoon_temp (ID int,name varchar (30));
ERROR 1813 (HY000): tablespace for table ' Yoon '. ' Yoon_temp ' exists. Please DISCARD the tablespace before IMPORT.
mysql> ALTER TABLE yoon_temp DISCARD tablespace;
ERROR 1146 (42S02): Table ' yoon.yoon_temp ' doesn ' t exist
Create yoon_temp.frm with yoon.frm copy under directory
[email protected] yoon]# CP yoon.frm YOON_TEMP.FRM
[Email protected] yoon]# chown mysql.mysql yoon_temp.frm
View table:
Mysql> Show tables;
+----------------+
| Tables_in_yoon |
+----------------+
| Yoon |
| Yoon_temp |
+----------------+
2 rows in Set (0.00 sec)
Mysql> Show CREATE TABLE Yoon_temp\g
1. Row ***************************
Table:yoon_temp
Create table:create Table ' yoon_temp ' (
' id ' int (one) DEFAULT NULL,
' Name ' varchar (DEFAULT NULL)
) Engine=innodb DEFAULT Charset=utf8
1 row in Set (0.00 sec)
mysql> drop table yoon_temp;
Query OK, 0 rows affected (0.03 sec)
Re-create the re-test:
Mysql> CREATE TABLE yoon_temp (ID int,name varchar (30));
Query OK, 0 rows affected (0.02 sec)
When the table structure file is accidentally deleted, can be created through the other table structure to repair the deletion, the table structure is the same, the field Varcahr (XXX) XXX size difference does not matter, also indirectly implemented by replacing the FRM way to modify the table structure.
Modify the table structure by replacing the frm file