Dagang Wei
Dagang Wei

Reputation: 26458

Prevent comments lost in MySQL stored procedure

Sometimes I write comments in MySQL stored procedure, but after database recovery, all the comments are lost. How to prevent comments lost? Thanks!

Upvotes: 1

Views: 1735

Answers (3)

IvanD
IvanD

Reputation: 8291

This is a common problem with the mysql CLI. By default, it strips out all the comments from the SQL restore file.

Use --comments on the command line to prevent mysql CLI from stripping out the comments. Works for me.

eg. mysql mydb -u root -ppassword --comments < /tmp/db_to_restore.sql

Upvotes: 3

T.J. Crowder
T.J. Crowder

Reputation: 1074138

Your database should not be where your source code for your stored procedures is stored. That should be in a source code control system so that you have access to previous revisions, modification history, etc., etc. (And, of course, that means you've stored the actual files you edit, and so the comments will remain intact.) The database is where the code is deployed, not where it's stored.

Upvotes: 2

sarnold
sarnold

Reputation: 104040

Store all your work in a source control system. If you're looking for suggestions, consider git, which is extremely popular and simple uses are relatively simple while complex things are still possible.

Upvotes: 2

Related Questions