我是mysql数据库的新手。我试图通过加入MySQL中现有的两个表来创建维护。我使用了以下命令。但它会引发以下错误。
create table maintable as select * from table1 union select * from table2;
Error 126 (HY000): incorrect key file for table 'c:\temp'; try to repair it

[client]
port=3306
[mysql]
default-character-set=UTF8
[mysqld]
port=3306
max_allowed_packet=128M
basedir="C:/Program Files/MySQL/MySQL Server 5.5/"
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"
character-set-server=UTF8
default-storage-engine=INNODB
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=100
query_cache_size=0
table_cache=2G
tmp_table_size=2G
max_heap_table_size=2G
thread_cache_size=32
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=126M
read_buffer_size=128K
read_rnd_buffer_size=612K
sort_buffer_size=566K
innodb_additional_mem_pool_size=512M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=50M
innodb_buffer_pool_size=127M
innodb_log_file_size=24M

但似乎没有什么可以解决这个错误...非常感谢您的帮助。谢谢
答案 0 :(得分:1)
如果两个表都有相同的号码。列的顺序和顺序相同,因为你正在使用union,只有在没有时才能工作。列将是相同的,然后你可以使用下面的任何一种方法,这将比简单的插入方法更快 -
通过转储:
步骤1:通过结构和数据转储将table1备份。
步骤2:仅使用table2转储数据。
第3步:恢复table1。
步骤4:仅在table1中恢复table2数据。
通过导出/导入方法:
步骤1:在csv中进行两个表备份。
select * INTO OUTFILE 'd:\\backup\\table1.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n' FROM table1;
select * INTO OUTFILE 'd:\\backup\\table1.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n' FROM table2;
步骤3:现在将两个csv数据导入表中,首先创建表 -
LOAD DATA LOCAL INFILE 'd:\\backup\\table1.csv' INTO TABLE mytable FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' ignore 1 lines;
LOAD DATA LOCAL INFILE 'd:\\backup\\table2.csv' INTO TABLE mytable FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' ignore 1 lines;