G
G
generate2020-12-01 14:26:41
MySQL
generate, 2020-12-01 14:26:41

ALTER TABLE IF NOT EXISTS throws an error?

ALTER TABLE table ADD COLUMN IF NOT EXISTS name
Tell me why it gives an IF NOT EXISTS error, there are no errors on the localhost, but an error on the server.
Is there a replacement IF NOT EXISTS, if there is a name structure in the table table, then skip it, if it is not there, add it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2020-12-05
@generate

Method

ADD COLUMN IF NOT EXISTS
only implemented in MariaDB but does not exist in MySQL 5-8.
So it looks like you have MariaDB on your localhost and MySQL on the server.
To check the exact database version, run: In SQLize.online you can test your query against different databases.
SELECT VERSION();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question