"你可以使用以下存储过程来判断表是否存在:\n\nDELIMITER //\n\nCREATE PROCEDURE CheckTableExists(IN tableName VARCHAR(255), OUT tableExists INT)\nBEGIN\n\tSELECT COUNT(*) INTO tableExists\n\tFROM information_schema.tables\n\tWHERE table_name = tableName;\nEND //\n\nDELIMITER ;\n然后,你可以调用这个存储过程来判断表是否存在,方法如下:\n\nSET @tableExists = 0;\nCALL CheckTableExists('your_table_name', @tableExists);\nIF @tableExists = 1 THEN\n\t-- 表存在\nELSE\n\t-- 表不存在\nEND IF;

MySQL存储过程:如何判断表是否存在

原文地址: https://www.cveoy.top/t/topic/p6PJ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录