CREATE TABLE IF EXISTS in MySQL

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s