|
发表于 2025-1-5 12:37:46
|
显示全部楼层
河北省石家庄市
用AI试了试,主要是弄好索引,或者可以先创时候cha询表里是否有这个数据,然后再插入
-- 创建索引
CREATE INDEX idx_main_data ON main_table(column_name);
-- 创建临时表并导入数据
CREATE TEMPORARY TABLE temp_table (
column_name datatype,
...
);
LOAD DATA INFILE 'path/to/your/file.csv' INTO TABLE temp_table
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
-- cha询不重复的数据
INSERT INTO main_table (column_name, ...)
SELECT t.column_name, ...
FROM temp_table t
LEFT JOIN main_table m ON t.column_name = m.column_name
WHERE m.column_name IS NULL;
-- 导出主表中的所有数据
SELECT * FROM main_table INTO OUTFILE 'path/to/your/output.csv'
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'; |
|