您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

我们如何通过MySQL存储过程访问表?

2024/2/20 6:04:35发布16次查看
我们可以从 mysql 存储过程访问一个或所有表。以下是一个示例,其中我们创建了一个存储过程,它将接受表的名称作为参数,并在调用它后,将生成包含表中所有详细信息的结果集。
示例mysql> delimiter //mysql> create procedure access(tablename varchar(30)) -> begin -> set @x := concat('select * from',' ',tablename); -> prepare statement from @x; -> execute statement; -> end//query ok, 0 rows affected (0.16 sec)
现在使用我们需要访问的表名称作为其参数来调用该过程。
mysql> delimiter ;mysql> call access('student_info');+------+---------+----------+------------+| id | name | address | subject |+------+---------+----------+------------+| 101 | yashpal | amritsar | history || 105 | gaurav | jaipur | literature || 125 | raman | shimla | computers |+------+---------+----------+------------+3 rows in set (0.02 sec)query ok, 0 rows affected (0.04 sec)
以上就是我们如何通过mysql存储过程访问表?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product