close[x]


MySQL

MySQL-Home MySQL-Environment setup MySQL- Workbench MySQL-Basic syntax MySQL-Operator MySQL-Data type MySQL-Comments MySQL-Create DB MySQL-Drop DB MySQL-Select DB MySQL-Create Table MySQL-Drop table MySQL-Truncate MySQL-Primary Key MySQL-Foreign Key MySQL-Null MySQL-Increment MySQL-Having MySQL-Top MySQL-Insert Statement MySQL-Select Statement MySQL-Alter Statement MySQL-Where MySQL-And & Or MySQL-Default values MySQL-Exists MySQL-Order by MySQL-View MySQL-Update Statement MySQL-Delete Statement MySQL-Like MySQL-Sort MySQL-Limit MySQL-Min MySQL-Max MySQL-Group MySQL-In MySQL-Between MySQL-Union MySQL-Count MySQL-Average MySQL-Sum MySQL-Date & Time MySQL-Import MySQL-Export MySQL-Index MySQL-Temporary MySQL-Join MySQL-Full Join MySQL-Inner Join MySQL-Left Join MySQL-Right Join MySQL-Store Procedure MySQL-Injection MySQL-PHP connection



learncodehere.com



MySQL - CREATE Table

Table is a collection of data, organized in terms of rows and columns.

Table is the simple form of data storage or store a set of records.

A table creation command requires Name of the table, Names of fields and Definitions for each field

The MySQL CREATE Table statement is used to create a new MySQL table.


Syntax : CREATE Table


 CREATE TABLE table_name
 (
 column1 data_type(size),
 column2 data_type(size),
 column3 data_type(size),
 ....
 );   

table_name: Name of the table you want to create under a database.

column : Name of the columns in side the table.

data_type: Type of data we want to store in the particular column

size: Size of the data we can store in a particular column



Here, we will create a table named "Students" in the database "first_db".

Example : CREATE Table


CREATE TABLE Students
 (
 ROLL_NO int(3),
 NAME varchar(20),
 SUBJECT varchar(20),
 );  

Students : Name of the table

ROLL_NO : Name of the column one in side the table and is of type int and will hold an integer.

NAME, SUBJECT : Name of columns are type varchar and will hold characters, and the maximum length for these fields is 20 characters.

The empty "Students" table will now look like this:

db table

You can verify if your table has been created successfully using the DESCRIBE command as follows −

DESCRIBE Students;

Now, you have Students table available in your database which you can use to store the required information related to Students.