<

MYSQL CREATE TABLE

The MySQL CREATE TABLE command is used to create a new table into the database. A table creation command requires three things:



  • Name of the table

  • Names of fields

  • Definitions for each field


  • MySQL Create Table Syntax



    
    CREATE TABLE table_name (column_name column_type...);   
    


    MySQL Optional Attributes:


  • NOT NULL - null values are not allowed

  • DEFAULT -Set a default value

  • UNSIGNED - Used for number types, limits the stored data to positive numbers and zero

  • AUTO INCREMENT - automatically increases the value 1 each time a new record is added

  • PRIMARY KEY - Used to uniquely identify the rows in a table and used with AUTO_INCREMENT


  • MySQL Create Table Example



    
    CREATE TABLE student(  
       id INT NOT NULL AUTO_INCREMENT,  
       name VARCHAR(100) NOT NULL,  
       class VARCHAR(100) NOT NULL,  
       PRIMARY KEY (id )  
    );  
    
    















    © copyright 2017-2022 Completedone pvt ltd.