如何建立一個儲存過程來獲取儲存在資料庫中的某個特定 MySQL 表的詳細資訊?


以下示例將建立一個名為“tabledetails”的儲存過程,它提供了儲存在資料庫中的某個特定表的詳細資訊。

示例

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)

更新於: 22-6-2020

314 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.