Saturday, February 10, 2018

MY SQL TABLE RELATED QUERIES

                                         MY SQL TABLE RELATED QUERIES


Create Database Command:

          The following command will show to you how to create database by using Mysql queries.

    1. create database databasename; /// create a new databse by using this command

    2. use database; ///to open the the database

   3. show database; /// It will help to view th ewhat are the databses available.


The syntax to create a table:

       create table tablename(colname1 datatypesize,colname2 datatypesize,colname3 datatypesize.......colname n datatypesize);

      create table customer(id int,name varchar(20),phone int,dop timestamp,dob datetime);

To view table structure:

                  desc customer;

      This command will help to see the whole table structure created by the user by using the Mysql queries.

To rename table:

      This command is used to change the table name which means we can able to change the name to the table.

           
          rename table oldtablename to newtablename;

Alter Command:

       The table was already created but you want add a another colname into that table you can use this query.

          alter table tablename add colname datatype;

Drop Command:

     The table was already created but you want delete a existing colname from htat table you can use this query.

      alter table tablename drop colname;

Change Command:

    If you want to change the colname to any particular attribute you can use this.

        alter table tablename change colname newcolname datatype();

Modify Command:

     alter table tablename modify colname();

             





No comments:

Post a Comment

A R Murugadoss --- Film Career and Biography

         A R Murugadoss --- Film Career a Biography  Early Life :          A.R Murugadoss was Born on 25th September in the Year o...