Search code examples
databaseoracle-databaseinsert

How to insert simple string with ' char into oracle database


So my problem is that i need to insert company names into some database. It works fine but when i try to insert, for example Mc'Donalds it doesnt work because it finds end before the real end. So when i try that:

Inert into mydatabase (name, adress) values ('Mc'Donalds', 'somewhere') 

It crashes. Is there some char like \ to ignore it? Thank u!


Solution

  • To escape reserved chars like ', you'll probably want to double the apostrophe character. See http://www.orafaq.com/faq/how_does_one_escape_special_characters_when_writing_sql_queries