MySQL Server

  . MySQL Server is a Relational Database Management System based on SQL.
  . Runs on all platforms including Linux, Windows, Unix.
  . Most of the websites adopt MySQL database for their data storage.
  . It is well suited for small and medium scale data storage operations.

 Installing MySQL Server:

   . Download MySQL Server from the internet.
   . Go to official website of MySQL and click on MySQL Community Server.


    . Choose the Operating System and click on Go to Download page.
 
   . Download the mysql community installer.
     
    . Run the file. Accept the License Agreement and click on Next.

    . Select the Developer Default and click on Next.

    . Click on Next.

    . Click on Execute.

    . Click on Next.



    . Set the account password and click on Next.





    . After configuration, type the password and check. Click Next.


    . Click on Finish after the completion of installation.

    . Now open MySQL Workbench which is a GUI tool for MySQL which helps you to interact with database.
   . Type the password and connect to it.

  Creating a table:

    . Syntax for creating table: create table table_name(col_name datatype,...);
    . In the following table, a table called emp is created with id, name, dept as column names.



  Inserting values into table:

   . Syntax for inserting values into table:  insert into table_name values(val1,val2,..,valn),(val1,val2,..,valn);

 Retrieving data from table:

  . Syntax for retrieving data from table: select * from table_name;

 Updating data in table:

   . Syntax for updating data: update table_name set col_name=value where condition;
   . In the below example, record with name 'Kumar' is updated to 'Sai Kumar' by mentioning id number in the where condition.

  Alter table:

   . Alter can be used in many ways like adding constraints, adding or deleting rows etc.
   . In the below example, Primary key is added to column id.
   . Syntax for adding Primary key: alter table table_name add constraint pk_name Primary key(column_name);

   . After adding Primary key, it never allows duplicate or null values in that column.

  Deleting records from table:

   . Syntax for deleting record from table: delete * from table_name where condition;
   . In the below example, record with id 103 is deleted.