×
☰ See All Chapters

MySQL CREATE TABLE

Creating tables in MySQL is done with the create table command. Create table command does the following:

  1. Defines the table name 

  2. Defines the columns in the table 

  3. Defines the data types of those columns 

  4. Defines the constraints for the columns 

  5. Defines the size constraint for the data 

  6. Defines what tablespace the table resides in (optional) 

Syntax:

CREATE TABLE <table-name>

(

<column-name1> <data-type(size)> <constraint>,

<column-name2> <data-type(size)> <constraint>,

<column-name3> <data-type(size)> <constraint>,

<column-name4> <data-type(size)> <constraint>,

<column-name5> <data-type(size)> <constraint>

);

Example:

CREATE TABLE CUSTOMER

(

CUSTOMER_ID INT,

CUSTOMER_NAME VARCHAR2(30) ,

EMAIL VARCHAR2(30) ,

DOB DATE

)

 


All Chapters
Author