MySQL存储过程执行SHOW CREATE TABLE?
要在存储过程中执行SHOWCREATETABLE,请使用SHOWCREATETABLE。让我们首先创建一个表-
mysql> create table DemoTable2011 -> ( -> StudentId int NOT NULL AUTO_INCREMENT, -> StudentName varchar(20), -> StudentAge int, -> StudentCountryName varchar(20), -> PRIMARY KEY(StudentId) -> );
以下是执行SHOWCREATETABLE的存储过程-
mysql> delimiter //
mysql> create procedure test_show_create_demo(table_name varchar(100))
-> begin
-> set @query=concat("SHOW CREATE TABLE ",table_name);
-> prepare st from @query;
-> execute st;
-> end
-> //
mysql> delimiter ;使用CALL命令调用存储过程-
mysql> call test_show_create_demo('DemoTable2011');这将产生以下输出-
+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | DemoTable2011 | CREATE TABLE `demotable2011` ( `StudentId` int(11) NOT NULL AUTO_INCREMENT, `StudentName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `StudentAge` int(11) DEFAULT NULL, `StudentCountryName` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`StudentId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.01 sec)
热门推荐
1 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿