• PREPARE
    • 语法图
    • 示例
    • MySQL 兼容性
    • 另请参阅

    PREPARE

    PREPARE 语句为服务器端预处理语句提供 SQL 接口。

    语法图

    PreparedStmt:

    PreparedStmt

    示例

    1. mysql> PREPARE mystmt FROM 'SELECT ? as num FROM DUAL';
    2. Query OK, 0 rows affected (0.00 sec)
    3. mysql> SET @number = 5;
    4. Query OK, 0 rows affected (0.00 sec)
    5. mysql> EXECUTE mystmt USING @number;
    6. +------+
    7. | num |
    8. +------+
    9. | 5 |
    10. +------+
    11. 1 row in set (0.00 sec)
    12. mysql> DEALLOCATE PREPARE mystmt;
    13. Query OK, 0 rows affected (0.00 sec)

    MySQL 兼容性

    PREPARE 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 issue。

    另请参阅

    • EXECUTE
    • DEALLOCATE