赞
踩
select * into oufile '/path/file_name' fields terminated by '|' enclose by '"' from tbl1;
fields terminated by ‘|’:字段分割符
fields enclose by ‘”’:字段值由”符包起来
fields OPTIONALLY enclose by :字段为数字则不包起来
lines terminated by ‘\r\n’:行换符
下面写发效果和上面一样
select * from tbl1 into oufile '/path/file_name' fields terminated by '|' enclose by '"'
load data infile '/path/file_name' into table tbl_name fields terminated by '|' enclosed by '"';
load data infile '/var/lib/mysql-files/tbl_trans_id.txt' into table tbl_ fields terminated by '|' enclosed by '"' (trans_id, trans_name, trans_code, trans_level, forbid, reserve);
mysqlimport -h127.0.0.1 -uroot -p123456 mysql '/var/lib/mysql-files/tbl_trans_id.txt' --columns='trans_id, trans_name, trans_code, trans_level, forbid, reserve' --fields-terminated-by '|' --fields-enclosed-by '"'
mysqldump -h${DB_HOST} -u${DB_USER} -p${DB_PWD} -P${DB_PORT} --set-gtid-purged=off ${DB_NAME} ${TBL_NAME} > ${BACK_DIR}/${TBL_NAME}.sql
mysql -h${DB_HOST} -u${DB_USER} -p${DB_PWD} -P${DB_PORT} ${DB_NAME} -e "source ${BACK_DIR}/${TBL_NAME}.sql"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。