In MySQL, it’s always advantageous to use the keyword IF NOT EXISTS when creating database objects like databases, tables, views, functions, and procedures.
In this post, we’ll see how to use it while creating a table.
CREATE TABLE IF NOT EXISTS tbStudent
(iStudentID INT,
vcStudentName VARCHAR(100));
The table won’t return any errors if it already exists. It creates a table if one doesn’t already exist.