If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
इस topic में आप सीखेंगे की कैसे stored procedure को drop / delete करते हैं।
आगे बढ़ने से पहले आप चाहेंगे कि हमारे database में कितने stored procedures define हैं , procedures की listing के लिए SHOW PROCEDURE STATUS
query का use किया जाता है।
> SHOW PROCEDURE STATUS;
Output
+-----------+--------------+-----------+----------------+---------------------+---------------------+ | Db | Name | Type | Definer | Modified | Created | +-----------+--------------+-----------+----------------+---------------------+---------------------+ | tutorials | counter_test | PROCEDURE | root@localhost | 2023-03-19 08:30:47 | 2023-03-19 08:30:47 | | tutorials | GetCustomers | PROCEDURE | root@localhost | 2023-03-16 18:55:03 | 2023-03-16 18:55:03 | | tutorials | get_user | PROCEDURE | root@localhost | 2023-03-19 08:29:12 | 2023-03-19 08:29:12 | | tutorials | get_users | PROCEDURE | root@localhost | 2023-03-16 18:57:05 | 2023-03-16 18:57:05 | | tutorials | total_users | PROCEDURE | root@localhost | 2023-03-19 08:29:43 | 2023-03-19 08:29:43 | | tutorials | var_test | PROCEDURE | root@localhost | 2023-03-18 19:44:42 | 2023-03-18 19:44:42 | +-----------+--------------+-----------+----------------+---------------------+---------------------+
Output में आपको बाकी information जैसे Security_type , Comment , character_set_client etc भी मिलेगा।
आप चाहें तो WHERE Clause या LIKE operator ला use करके कोई particular condition भी रख सकते हैं -
For Example
SHOW PROCEDURE STATUS LIKE '%search%';
or
SHOW PROCEDURE STATUS WHERE db='tutorials';
अब बात करते हैं कि किसी procedure को delete कैसे करेंगे।
Well , किसी procedure को delete करने के लिए DROP PROCEDURE
statement का use किया जाता है।
> DROP PROCEDURE counter_test;
Query OK, 0 rows affected (0.039 sec)
Query OK, होने का मतलब है procedure delete हो गया है।
अगर आप किसी ऐसे procedure को delete कर रहे जो exist नहीं कर रहे तो आपको error मिलेगी।
> DROP PROCEDURE counter;
Output
ERROR 1305 (42000): PROCEDURE tutorials.counter does not exist
- इसलिए किसी भी procedure को delete करने से पहले यह check करना सही रहता है कि वो exist करता है या नहीं , इससे हम run time error को avoid कर सकते हैं।
> DROP PROCEDURE IF EXISTS counter;
Query OK, 0 rows affected, 1 warning (0.001 sec)
I Hope , आपको MySQL में Stored Procedure के बारे में अच्छे से समझ आ गया होगा।
Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook