0

So I want to create a trigger or some other kind of method for dropping an entire table if it is created. I have the following SQL query but as of this moment I'm stuck.

CREATE OR REPLACE
    TRIGGER `kill_migrations` AFTER CREATE ON SCHEMA
BEGIN
    IF SYS.DICTIONARY_OBJ_TYPE = 'TABLE' THEN
        DROP TABLE IF EXISTS django_migrations
END;

How do I drop a table if it is created? The current SQL query provided has a syntax error around "Drop Table".

1 Answer 1

1

The MySQL manual and the MariaDB manual clearly limit trigger_event_ to INSERT | UPDATE | DELETE. That is, CREATE is not an option. Note how the error 1064 ... syntax to use near 'CREATE ON ... points exactly there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.