MySQL Store Procedure

Vote 0 Votes

MySQL Store Procedure 可以預先定義一些 function, 在 SQL Server 執行, 簡少程式的複雜性.

範例: 帶使用者 id, 取得使用者名稱
CREATE PROCEDURE test_proc(id CHAR(15))
SELECT name from nms_reso_user where uid=id;

在使用時只要 call
mysql> call test_proc('jack');
| name |
| 林傑克 |
1 row in set (0.00 sec)

show procedure status; 查看現有的 stored procedures
用 drop procedure 來刪除 stored procedures, 例如: drop procedure test_proc;

call 只需開放 execute 權限
grant execute on dbname.* to username@'192.168.0.%' identified by "password";

Leave a comment

About this Entry

This page contains a single entry by Pank published on April 16, 2010 3:30 PM.

Pixel Peeper was the previous entry in this blog.

Garmin nüMaps is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives