DECLAREcursor_name
CURSOR FORselect_statement
This statement declares a cursor and associates it with a 此语句声明一个指针并将其与一个SELECT
statement that retrieves the rows to be traversed by the cursor. SELECT
语句相关联,SELECT
语句检索指针要遍历的行。To fetch the rows later, use a 要稍后提取行,请使用FETCH
statement. FETCH
语句。The number of columns retrieved by the SELECT
statement must match the number of output variables specified in the FETCH
statement.SELECT
语句检索到的列数必须与FETCH
语句中指定的输出变量数匹配。
The SELECT
statement cannot have an INTO
clause.SELECT
语句不能有INTO
子句。
Cursor declarations must appear before handler declarations and after variable and condition declarations.指针声明必须出现在处理程序声明之前,变量和条件声明之后。
A stored program may contain multiple cursor declarations, but each cursor declared in a given block must have a unique name. 存储程序可以包含多个指针声明,但给定块中声明的每个指针必须具有唯一的名称。For an example, see Section 13.6.6, “Cursors”.有关示例,请参见第13.6.6节,“指针”。
For information available through 对于通过SHOW
statements, it is possible in many cases to obtain equivalent information by using a cursor with an INFORMATION_SCHEMA
table.SHOW
语句获得的信息,在许多情况下,可以通过使用带有INFORMATION_SCHEMA
表的指针来获得等效的信息。