- - PR -
[MySQL]データのダンプと一緒にストアドプロシージャのダンプも取れないか?
1
| 投稿者 | 投稿内容 |
|---|---|
|
投稿日時: 2006-11-01 11:01
MySQLのダンプを取る際に、mysqldump コマンドを使って
該当データベースのダンプをファイルに保存しています。 システムのパワーアップを図るため、ストアドプロシージャを 使ったのですが、mysqldumpコマンドを使ってダンプをとっても、 ストアドプロシージャだけがエクスポートされません。 そこで、そもそもストアドプロシージャがダンプで出力できるのでしょうか? 現在は、データはmysqldumpコマンドで出力されたダンプファイルをインポートし、 ストアドプロシージャは別途、スクリプトを実行する、という方法で、 データ移行を行なっています。 |
|
投稿日時: 2006-11-01 11:40
バージョンによります
|
|
投稿日時: 2006-11-01 14:23
ぶさいくろうさん、ありがとうございます。
MySQL5.0以上でストアドがサポートされていますが、 実際に、 mysqldump コマンドを使ってもエクスポートされません。 方法が間違っているのでしょうか? |
|
投稿日時: 2006-11-01 15:40
本家のドキュメントからです
dev.mysql.com/doc/refman/5.0/en/mysqldump.html 8.12. mysqldump --routines, -R Dump stored routines (functions and procedures) from the dumped databases. Use of this option requires the SELECT privilege for the mysql.proc table. The output generated by using --routines contains CREATE PROCEDURE and CREATE FUNCTION statements to re-create the routines. However, these statements do not include attributes such as the routine creation and modification timestamps. This means that when the routines are reloaded, they will be created with the timestamps equal to the reload time. この辺重要 If you require routines to be re-created with their original timestamp attributes, do not use --routines. Instead, dump and reload the contents of the mysql.proc table directly, using a MySQL account that has appropriate privileges for the mysql database. This option was added in MySQL 5.0.13. Before that, stored routines are not dumped. Routine DEFINER values are not dumped until MySQL 5.0.20. This means that before 5.0.20, when routines are reloaded, they will be created with the definer set to the reloading user. If you require routines to be re-created with their original definer, dump and load the contents of the mysql.proc table directly as described earlier. |
|
投稿日時: 2006-11-01 17:24
99riさん、ありがとうございます。
解決することができました。 でも、MySQLの旧バージョンと新バージョンが同居している場合は、 いちいち、MySQL5.0のフォルダをカレントにして実行しないといけないので、 面倒だったりしますね。 |
1
