Sto tentando di fare un truncate di una tabella.. senza successo.
Sinceramente son perplesso... se la tabella di riferimento è vuota, e non ci sono perciò chiavi
legate alla tabella da truncare perchè si arrabbia?
Comunque a parte questo.. ho provato tramite riga di comando a fare 3 prove diverse
SET foreign_key_constraints = 0;
truncate tbl_comuni
SET foreign_key_constraints = 1;
ERRORE
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '▬
SET foreign_key_constraints = 0' at line 1
--------------------------------------
SET @SESSION.foreign_key_constraints = 0;
truncate tbl_comuni
SET @SESSION.foreign_key_constraints = 1;
SUCCESS:
Query OK, 0 rows affected (0.00 sec)
ERROR:
ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constrai
nt (`puntore`.`tbl_localitazone`, CONSTRAINT `fk_tbl_localitazone_tbl_comuni1` F
OREIGN KEY (`tbl_comuni_idtbl_comuni`) REFERENCES `puntore`.`tbl_comuni` (`idtbl
_comuni`))
--------------------------------------
foreign_key_checks = 0;
truncate tbl_comuni
foreign_key_checks = 1;
ERROR:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'forei
gn_key_checks = 0' at line 1
--------------------------------------
qualcuno sa darmi indicazioni?

Rispondi quotando