My SQL Summerized


FUNCTIONS IN MY SQL:

  • NOW() FUNCTION: 

        This query shows the current date and time. 

SELECT NOW();


  • SUM() FUNCTION:

SELECT SUM(column_name) as new_name FROM table_name;


        WITH WHERE CLAUSE:

SELECT SUM(column_name) as new_name FROM table_name WHERE condition;

 

 

    SHOW IN MY SQL:

            GET LIST OF ALL TABLES:

    SHOW TABLES;

            This shows all the tables in the selected database as a information. 


            GET CREATE QUERY OF ANY TABLE:

    SHOW CREATE TABLE table_name;
            This shows the complete CREATE TABLE statement used by MySQL for creating             the table.


    SHOW CURRENT DATE AND TIME:

    SELECR CURDATE();

            This Statement show current date. 

     

    SELECT CURTIME();

            This statement shows the current time.


    TABLE QUERY:

    DELETE TABLE:

    DELETE FROM table_name;


    RENAME TABLE NAME:

    RENAME TABLE old_table_name TO new_table_name;

    ALTER TABLE  
    old_table_name RENAME TO new_table_name;

    ADD NEW COLUMN IN A TABLE:

    ALTER TABLE table_name ADD column_name datatypes;

    ALTER TABLE table_name ADD(column1, column2, column3..) 


    ADD or DROP a column IN TABLE:

    ALTER TABLE table_name ADD COLUMN column_name datatype(size);
    ALTER TABLE table_name DROP COLUMN column_name;

     

     GET DESCRIPTION OF TABLE:

    DESCRIBE table_name

    This describes the columns of the table_name with respect to Field, Type, Null, Key, Default, Extra. 


    Comments

    Popular posts from this blog

    Java Script - Table of Content

    Constraints in MySQL