Add transaction and commit statements to SQL scripts

This commit is contained in:
Morph01
2024-04-05 11:20:17 +02:00
parent f06818d9da
commit 44fd7669ba
3 changed files with 8 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
-- Generated by Mocodo 4.2.4
START TRANSACTION;
CREATE TABLE
carte (
PRIMARY KEY (idcarte),
@@ -337,4 +337,5 @@ ALTER TABLE tente_validation ADD FOREIGN KEY (idpartie, num_tour) REFERENCES tou
ALTER TABLE tour ADD FOREIGN KEY (idpartie) REFERENCES partie (idpartie);
ALTER TABLE valide ADD FOREIGN KEY (idcontrainte) REFERENCES contrainte (idcontrainte);
ALTER TABLE valide ADD FOREIGN KEY (idcontrainte) REFERENCES contrainte (idcontrainte);
COMMIT;

View File

@@ -1,3 +1,4 @@
START TRANSACTION;
INSERT INTO
`contrainte` (`idcontrainte`, `couleur`)
SELECT DISTINCT
@@ -265,7 +266,7 @@ GROUP BY
SET @row_number = 0;
INSERT INTO `comprend`(`idpartie`, `num_tour`, `idlancer`) SELECT `id_partie`, `num_tour`, @row_number:=@row_number+1 AS idlancers
INSERT INTO `comprend`(`idpartie`, `numTour`, `idlancer`) SELECT `id_partie`, `numTour`, @row_number:=@row_number+1 AS idlancers
FROM donnees_fournies.instances3 t;
SET @row_number = 0;
@@ -281,4 +282,5 @@ UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('2;', de2) FROM `donnees_fournie
UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('3;', de3) FROM `donnees_fournies`.`instances3`
UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('4;', de4) FROM `donnees_fournies`.`instances3`
UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('5;', de5) FROM `donnees_fournies`.`instances3`
UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('6;', de6) FROM `donnees_fournies`.`instances3`;
UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('6;', de6) FROM `donnees_fournies`.`instances3`;
COMMIT;

View File

@@ -49,7 +49,7 @@ WITH participants_tournois AS
(SELECT idtournoi, COUNT(idtournoi) AS nb
FROM participe
JOIN tournoi USING(idtournoi)
AND YEAR(T.date_deb) >= (YEAR(NOW()) - 3)
WHERE YEAR(date_deb) >= (YEAR(NOW()) - 3)
GROUP BY idtournoi)
SELECT AVG(nb) AS average FROM participants_tournois;