Mysql create table statement

To create table in mysql following syntax is used

For example,

if table created without any error then it will show following statement

Result:

This query will result a table with the above fields. The first column will hold number while other columns are type of varchar.

Create Table in Mysql with primary key

Above mysql create statement create a student table with primary key id,
with auto increment field value and two unique keys mobile_no and email_id,
at the time of creating user add_date is added CURRENT_TIMESTAMP as default value.

This table also uses mysql create table auto_increment

MySql create table if not exists

Syntax of create table if not exist is
CREATE TABLE IF NOT EXISTS table_name(............);

To modity the student table with CREATE TABLE IF NOT EXISTS the query is as below

Leave a Comment