TRUNCATE seulement si la table existe
Bonjour,
j'ai un script qui me permet de vider la bdd avant de pouvoir effectuer un nouveau test :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| SET FOREIGN_KEY_CHECKS = 0;,
TRUNCATE table `ag_assign_group`;,
TRUNCATE table `ap_application`;,
TRUNCATE table `pl_platform`;,
TRUNCATE table `oz_organization`;,
TRUNCATE table `lo_location`;,
TRUNCATE table `li_license`;,
TRUNCATE table `fu_file_uploaded`;,
TRUNCATE table `em_mail`;,
TRUNCATE table `cou_country`;,
TRUNCATE table `co_company`;,
TRUNCATE table `ti_ticket`;,
TRUNCATE table `co_company`;,
TRUNCATE table `us_user`;,
TRUNCATE table `usl_user_license`;,
TRUNCATE table `ust_user_ticket`;,
SET FOREIGN_KEY_CHECKS = 1; |
Le souci, c'est que si la table n'existe pas, ça génère une erreur. Pas moyen de rajouter IF EXISTS. Comment puis-je faire pour ne pas avoir d'erreur ?