☰ See All Chapters |
MySQL CREATE TABLE
Creating tables in MySQL is done with the create table command. Create table command does the following:
Defines the table name
Defines the columns in the table
Defines the data types of those columns
Defines the constraints for the columns
Defines the size constraint for the data
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