1

In MySQL there are two options for the SELECT INTO OUTFILE command:

--fields-enclosed-by=char
--fields-optionally-enclosed-by=char

What's the basic difference in these two options?

Enclosed by means forcefully all fields are escaped by given char but what in case of optionally? How MySQL take care of this option ?

Thanks

Aman Aggarwal
  • 17,619
  • 9
  • 53
  • 81

1 Answers1

2

Here is what MySQL manual says (I don't know why they put it in LOAD DATA):

if you omit the word OPTIONALLY, all fields are enclosed by the ENCLOSED BY character.

...

If you specify OPTIONALLY, the ENCLOSED BY character is used only to enclose values from columns that have a string data type (such as CHAR, BINARY, TEXT, or ENUM)

In reality, also TIME, TIMESTAMP, DATE and DATETIME values are enclosed when OPTIONALLY is specified.

elenst
  • 3,839
  • 1
  • 15
  • 22