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

MySQLMySQLi 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)
raja
Published on 21-Feb-2018 10:20:58
Advertisements