BEGIN -- 定义变量 DECLARE index_id intDEFAULT1 ; DECLARE singerName VARCHAR(255); DECLARE singerID VARCHAR(255); -- 遍历歌手表 while index_id <1499 do -- 提取出歌手id和歌手姓名存储在变量中 SELECT name,singer_id into singerName,singerID from singer where id = index_id; -- 根据歌手id更新歌曲表的歌手姓名 update song set singer_name = singerName where singer_id=singerID; -- 下标自增 set index_id = index_id +1; end while; END