Create a stored procedure to get the detail of a particular MySQL table stored in a database?


Following example will create a procedure named ‘tabledetails’ which gives all the details of a particular table stored in database.

Example

mysql> DELIMITER //
mysql> Create Procedure tabledetails()
   -> BEGIN
   -> DESCRIBE Student_detail;
   -> END //
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;

mysql> CALL tabledetails;
+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| Studentid   | int(11)     | NO   | PRI | NULL    |       |
| StudentName | varchar(20) | YES  |     | NULL    |       |
| address     | varchar(20) | YES  |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
Query OK, 0 rows affected (0.04 sec)

Updated on: 22-Jun-2020

198 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements