MySQL applies these rules when various CREATE ... IF
NOT EXISTS
statements are replicated:
Every
CREATE DATABASE IF NOT EXISTS
statement is replicated, whether or not the database already exists on the source.Similarly, every
CREATE TABLE IF NOT EXISTS
statement without aSELECT
is replicated, whether or not the table already exists on the source. This includesCREATE TABLE IF NOT EXISTS ... LIKE
. Replication ofCREATE TABLE IF NOT EXISTS ... SELECT
follows somewhat different rules; see Section 19.5.1.7, “Replication of CREATE TABLE ... SELECT Statements”, for more information.CREATE EVENT IF NOT EXISTS
is always replicated, whether or not the event named in the statement already exists on the source.CREATE USER
is written to the binary log only if successful. If the statement includesIF NOT EXISTS
, it is considered successful, and is logged as long as at least one user named in the statement is created; in such cases, the statement is logged as written; this includes references to existing users that were not created. See CREATE USER Binary Logging, for more information.CREATE PROCEDURE IF NOT EXISTS
,CREATE FUNCTION IF NOT EXISTS
, orCREATE TRIGGER IF NOT EXISTS
, if successful, is written in its entirety to the binary log (including theIF NOT EXISTS
clause), whether or not the statement raised a warning because the object (procedure, function, or trigger) already existed.