MySQL Forums
Forum List  »  Newbie

IF NOT EXISTS - checking for table by name
Posted by: Wayne Rasmussen
Date: May 05, 2017 03:19PM

Writing a build script. I want to see if table customer exists within database wjr and if it doesn't, then create it. This is failing.

IF NOT EXISTS
(
SELECT *
FROM information_schema.tables
WHERE table_schema = 'wjr'
AND table_name = 'customer'
LIMIT 1;
)
BEGIN
CREATE TABLE customer(n int);
END

How do I do this test using the information_schema?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.