You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ALTERTABLEALTERUSER
ANALYZE TABLE
CACHE INDEX
CALL
CHANGE MASTER
CHECKSUM {TABLE | TABLES}
COMMIT
{CREATE | DROP} INDEX
{CREATE | RENAME | DROP} DATABASE
{CREATE | DROP} TABLE
{CREATE | RENAME | DROP} USER
{CREATE | DROP} VIEW
DELETE
DO
FLUSH {TABLE | TABLES | TABLES WITH READ LOCK | HOSTS | PRIVILEGES
| LOGS | STATUS | MASTER | SLAVE | USER_RESOURCES}
GRANT
INSERT
INSTALL PLUGIN
KILL
LOAD INDEX INTO CACHE
OPTIMIZE TABLE
RENAME TABLE
REPAIR TABLE
REPLACE
RESET {MASTER | SLAVE}
REVOKESELECTSET
SHOW BINLOG EVENTS
SHOW CREATE {PROCEDURE | FUNCTION | EVENT | TABLE | VIEW}
SHOW {MASTER | BINARY} LOGS
SHOW {MASTER | SLAVE} STATUS
SLAVE {START | STOP}
TRUNCATE TABLE
UNINSTALL PLUGIN
UPDATE
8 一些诊断式的 sql 也不能出现在 prepare statement 中
SHOW WARNINGS, SHOW COUNT(*) WARNINGS
SHOW ERRORS, SHOW COUNT(*) ERRORS
Statements containing any reference to the warning_count or error_count system variable.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
1 mysql 官方文档
from https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html
prepared statement 有如下特征:
这些 prepare statement 不支持的 sql,存储过程也不支持。
2 命令行示例
示例1:prepare 后面直接跟着 sql statement
示例2: 把 sql text 作为 user variable,然后赋值为 prepare
示例3:仍然是 sql text 作为 user variable,但是可以动态选择一个表名作为 prepament statement 的一部分
3 prepare statement
from https://dev.mysql.com/doc/refman/8.0/en/prepare.html
语法格式
PREPARE stmt_name FROM preparable_stmt
?
替代,其中不能出现引号,即便你想使用的是字符串变量也不行4 execute statement
from https://dev.mysql.com/doc/refman/8.0/en/execute.html
语法格式
5 deallocate prepare statement
from https://dev.mysql.com/doc/refman/8.0/en/deallocate-prepare.html
语法格式
Beta Was this translation helpful? Give feedback.
All reactions