Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql script file comments 1

Status
Not open for further replies.

murrayja

Programmer
May 6, 2000
90
US
Can anyone tell me how to comment out a line in an sql script file being input to mysql on the command line?
(eg: >mysql source \scriptfile.txt)
 
The most standard way is to start the line with two minus signs and a space, Like:
Code:
-- This is a comment

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
there are also block comments; e.g.,

/*
set v = 5;
set h = 3;
*/

-- doesn't get executed.

btw, two dashes by themselves don't produce a comment. You need the space after them.

--not a comment
-- is a comment.

 
MDCrab said:
btw, two dashes by themselves don't produce a comment. You need the space after them.
Actually, that's not correct. No space is necessary - all you need is the 2 dashes. In fact, you can have pretty much any character you want after the double dashes, including more dashes. (Refer to page 83 of the ANSI SQL-92 standard.)
 
Oh, wait, you're talking MySQL-specific. In that case, never mind, you're right. Sorry, guess I'm wasn't paying attention to which forum I'm in.
 
there's nothing wrong with quoting ANSI standards if someone says "The most standard way is ..."

:)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top