0
4

1 回答 1

1

使用SELECT ... INTO OUTFILE语法从旧表中创建一个 CSV 文件,查询如下

SELECT *
  INTO OUTFILE '/path/to/your/file.csv'
    FIELDS TERMINATED BY ',' ENCLOSED BY '"'
    LINES TERMINATED BY '\n'
  FROM
(
  SELECT 'id', 'user_login', 'user_pass', 'user_nicename','user_email','user_url','user_registered','user_activation_key','user_status','display_name'
  UNION ALL
  SELECT id, email, hash, SUBSTRING_INDEX(email, '@', 1), email, '', created, '', status, SUBSTRING_INDEX(email, '@', 1)
    FROM ezxsubscription
) q

创建文件的内容:

"id","user_login","user_pass","user_nicename","user_email","user_url","user_registered","user_activation_key","user_status","display_name"
"454","name@surname.com","31b6bde64e1282ba82d7d0c8ad6ebaa9","name","name@surname.com","","1142840848","","2","name"
"1","name.name@gmail.com","fff4b8d75ecdfad43ed8c89444939cfb","name.name","name.name@gmail.com","","1141956489","","2","name 。姓名”
于 2013-09-11T07:38:01.433 回答