search

Home  >  Q&A  >  body text

MySQL 导出的时候, OPTIONALLY 是个什么作用?

我学MySQL导入导出的时候,在菜鸟教程俩例子:

第一个:

SELECT * FROM c200401 INTO OUTFILE 'D:/csv.txt'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';

第二个:

SELECT * FROM c200401 INTO OUTFILE 'D:/result2.txt'
FIELDS TERMINATED BY ','
OPTIONALLY
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';

第二个比第一个多了个 OPTIONALLY ,我试了试, 第一组数据少了个一对"",
我想问问,OPTIONALLY有什么讲究?

PHPzPHPz2784 days ago645

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 14:29:31

    [OPTIONALLY] ENCLOSED indicates what characters are used to include the field. If OPTIONALLY is used, only CHAR and VERCHAR are included. ESCAPED indicates what characters are used as escape characters when escaping is required. LINES TERMINATED indicates what characters are used to separate each row of records.

    reply
    0
  • Cancelreply