mysqldump
工具没有内置的选项可以直接跳过某些列
方法一:使用临时表
column_to_skip
列,请执行以下命令:CREATE TABLE temp_table AS SELECT column1, column2, column3 FROM original_table;
mysqldump
备份临时表:mysqldump -u username -p database_name temp_table > backup.sql
DROP TABLE temp_table;
方法二:使用 SELECT ... INTO OUTFILE
和 LOAD DATA INFILE
SELECT column1, column2, column3 INTO OUTFILE '/path/to/output.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '
'
FROM original_table;
mysqldump
或其他备份工具)。CREATE TABLE new_table LIKE original_table;
ALTER TABLE new_table DROP COLUMN column_to_skip;
LOAD DATA INFILE '/path/to/output.csv'
INTO TABLE new_table
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATE BY '
';
领取专属 10元无门槛券
手把手带您无忧上云