Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create a TABLE in MySQL?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 179
    Comment on it

    To create a table in MySQL, we use the CREATE TABLE statement. A table is a combination of row and columns.

    CREATE TABLE Syntax

    CREATE TABLE table_name
    (
    column_name1 data_type(size),
    column_name2 data_type(size),
    ....
    );
    

    In the above syntax parameters are described as below:

    The column_name parameters - It specifies the name of the column in the table.

    The data_type parameter - It specifies the data type of the column for ex. int, varchar, date etc.

    The size parameter - It specifies the maximum length of data a column can hold..

    CREATE TABLE Example

    Suppose we want to create a table named "user" that have four column - id, first_name, last_name, country. Use the below statement:

    CREATE TABLE user
    (
    id int(11),
    first_name varchar(45),
    last_name varchar(45),
    country varchar(45)
    );
    

    where id column is of type int and will have only integer values. The first_name, last_name and country columnsare of type varchar and will have characters and can have only 45 characters.

    Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: