I read from MySQL documentation
CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE statements are not supported inside transactions when using GTIDs (that is, when the server was started with the --enforce-gtid-consistency option). It is possible to use these statements with GTIDs enabled, but only outside of any transaction, and only with autocommit=1
and very confused why CREATE/DROP TEMPORARY TABLE not supported inside transactions when GTID is enable, can someone explain in more detail? Thanks!
There are reasons most likely relating to replication when GTID is enabled. You can always create a normal table inside a transaction.
Drop
that tableif exists
before creating. It will work the same way as temporary table.