Sunil Kumar Sahoo
Sunil Kumar Sahoo

Reputation: 53687

How to insert escape characters in mysql

Hi I want to insert all escape characters in a column in MySQL. I can not insert \ always because a long data may have a lot escape characters.

Thanks Sunil Kumar Sahoo

Upvotes: 0

Views: 2525

Answers (1)

Michal Sznajder
Michal Sznajder

Reputation: 9406

I am not sure if I am getting this correct but you

  • have a lot of data
  • you want to insert them into database with regular SQL commands
  • most of data requires escaping.

So you have no much options. Since there is no direct binary mode in MySQL you

  • either execute SQL script with escaping
  • you will write parametrized queries and insert data directly with some custom tool you will write.

If choosing first approach have a look at MySQL manual for some escaping string details. Particularly you may escape one backslash \ with double backslashes \\ sequence. Also have a look at NO_BACKSLASH_ESCAPES, which eliminates need for escaping completly.

Upvotes: 1

Related Questions