GBase 如何批量清空某数据库中部分表的数据?

编写一个存储过程来实现: dropprocedureifexiststruncate_tables; delimiter// CREATEPROCEDUREtruncate_tables(db_namevarchar(50))// 根据情况可以增加参数 BEGIN DECLAREdoneINTDEFAULT0; DECLAREtnamevarchar(50); DECLAREcur1CURSORFORSELECTtable_namefromINFORMATION_SCHEMA.TABLESWHERE table_schema=db_name;// 根据情况修改条件 DECLARECONTINUEHANDLERFORSQLSTATE'02000'SETdone=1; OPENcur1; REPEAT FETCHcur1INTOtname; IFNOTdoneTHEN set@str=concat('truncatetable',tname); preparestmt1from@str; executestmt1; deallocatepreparestmt1; ENDIF; UNTILdoneENDREPEAT; CLOSEcur1; END//
上一篇:优雅的暴力——树上启发式合并


下一篇:vue子组件传父组件