Some other SQL databases have -- as start comment. MySQL
has # as the start comment character, even if the mysql
command line tool removes all lines that starts with --.
You can also use the C comment style /* this is a comment */ with
MySQL.
See section Comment syntax
MySQL will not support this degenerated comment style because we have had many problems with automatically generated SQL queries that have used something like the following code:
UPDATE table_name SET credit=credit-!payment!
Where instead of !payment! we automaticly insert the value of the payment.
What do you think will happen when 'payment' is negative ?
Because 1--1 is legal in SQL, we think is terrible that '--' means start comment.
If you have a sql program in a textfile that contains -- comments
you should use:
replace " --" " #" < text-file-with-funny-comments.sql | mysql database. instead of the normal mysql database < text-file-with-funny-comments.sql
You can also change the -- to # comments in the command file:
replace " --" " #" -- text-file-with-funny-comments.sql
Change them back with:
replace " #" " --" -- text-file-with-funny-comments.sql
Go to the first, previous, next, last section, table of contents.