Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

Published in: Education
  • Be the first to comment


  1. 1. MYSQL
  2. 2. INTRODUCTION <ul><li>WHAT IS A DATABASE? </li></ul><ul><li>A database is a separate application that stores a collection of data. Each database has one or more distinct APIs for creating, accessing, managing, searching, and replicating the data it holds. </li></ul><ul><li>Other kinds of data stores can be used, such as files on the file system or large hash tables in memory but data fetching and writing would not be so fast and easy with those type of systems. </li></ul><ul><li>So now a days we use relational database management systems (RDBMS) to store and manager huge volume of data. </li></ul>
  3. 3. RDBMS <ul><li>WHAT IS RDBMS? </li></ul><ul><li>A relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd. Most popular commercial and open source databases currently in use are based on the relational model. </li></ul><ul><li>A short definition of an RDBMS may be a DBMS in which data is stored in the form of tables and the relationship among the data is also stored in the form of tables. </li></ul>
  4. 4. MYSQL DATABASE <ul><li>MySQL is a fast, easy-to-use RDBMS used being used for many small and big businesses. MySQL is developed, marketed, and supported by MySQL AB, which is a Swedish company. MySQL is becoming so popular because of many good reasons. </li></ul><ul><li>MySQL is released under an open-source license. So you have nothing to pay to use it. </li></ul><ul><li>MySQL is a very powerful program in its own right. It handles a large subset of the functionality of the most expensive and powerful database packages. </li></ul><ul><li>MySQL uses a standard form of the well-known SQL data language. </li></ul><ul><li>MySQL works on many operating systems and with many languages including PHP, PERL, C, C++, JAVA etc. </li></ul><ul><li>MySQL works very quickly and works well even with large data sets. </li></ul>
  5. 5. MYSQL COMMANDS <ul><li>MYSQL Commands consists of three categories </li></ul><ul><li>DDL (Data defenition language) </li></ul><ul><li>DML (Data manipulation language) </li></ul><ul><li>TCL (Transaction control language) and </li></ul><ul><li>DCL (Data control language) </li></ul>
  6. 6. DDL COMMANDS <ul><li>A Data Definition Language (DDL) is a computer language for defining data structures. </li></ul><ul><li>The term was first introduced in relation to the Codasyl database model, where the schema of the database was written in a Data Definition Language describing the records, fields, and &quot;sets&quot; making up the user Data Model. Initially it referred to a subset of SQL, but is now used in a generic sense to refer to any formal language for describing data or information structures, like XML schemas. </li></ul><ul><li>The DDL Commands in MYSQL are CREATE, ALTER and DROP . </li></ul>
  7. 7. CREATE <ul><li>To make a new database, table, index, or stored query. </li></ul><ul><li>A CREATE statement in MY SQL creates an object inside of a relational database management system (RDBMS). </li></ul><ul><li>The types of objects that can be created depends on which RDBMS is being used, but most support the creation of tables, indexes, users, synonyms and databases. </li></ul><ul><li>The syntax of create statement is : </li></ul><ul><li>CREATE [TEMPORARY] TABLE [table name] ( [column definitions] ) [table parameters]. </li></ul>
  8. 8. ALTER <ul><li>To modify an existing database object. </li></ul><ul><li>An ALTER statement in MYSQL changes the properties of an object inside of a relational database management system (RDBMS). The types of objects that can be altered depends on which RDBMS is being used. </li></ul><ul><li>The syntax of ALTER statement is: </li></ul><ul><li>ALTER TABLE tbl_name ADD [COLUMN] col_name column_definition </li></ul>
  9. 9. DROP <ul><li>DROP DATABASE command is used to drop the all tables in the given database and deletes the database also. </li></ul><ul><li>But for using the DROP DATABASE statement you need the DROP privilege on the database. </li></ul><ul><li>If you are not using IF EXISTS option and the database is not available which you want to drop then it occurs the error but if you are using this option then it doesn't occur the error. </li></ul><ul><li>The syntax of DROP command is : </li></ul><ul><li>DROP [TEMPORARY] TABLE [IF EXISTS] tbl_name </li></ul><ul><li>DROP {DATABASE | SCHEMA} [IF EXISTS] db_name </li></ul>
  10. 10. DML COMMANDS <ul><li>Data Manipulation Statement is used to retrieve, insert, update and delete the records in a database. All database users will use these commands during routine operation of the database. </li></ul><ul><li>The Data manipulation commands are SELECT, INSERT, UPDATE and DELETE. </li></ul>
  11. 11. SELECT <ul><li>The SELECT statement is used to retrieve a result set of records from one or more tables, temporary tables or views in a database. It is the most commonly used DML command. </li></ul><ul><li>In this statement the user can specify a description of the required result set. </li></ul><ul><li>The syntax of select command is : </li></ul><ul><li>SELECT [ DISTINCT | ALL ] column_expression1, column_expression2, ... [ FROM from_clause ] [ WHERE where_expression ] [ GROUP BY expression1, expression2, .... ] [ HAVING having_expression ] [ ORDER BY order_column_expr1, order_column_expr2, .... ] </li></ul>
  12. 12. INSERT <ul><li>The INSERT statement is used to add one or more records to a existing table in a database. </li></ul><ul><li>This statement can insert the data into only a single table. </li></ul><ul><li>The syntax of insert command is : </li></ul><ul><li>INSERT INTO table_name [ ( col_name1, col_name2, .... ) ] </li></ul><ul><li>VALUES ( expression1_1, expression1_2, .... ), </li></ul><ul><li>( expression2_1, expression2_2, .... ), .... </li></ul>
  13. 13. UPDATE <ul><li>The UPDATE statement is used to modify the record contained with in a table either one row or more than one row. </li></ul><ul><li>The syntax of update command is : </li></ul><ul><li>UPDATE table_name </li></ul><ul><li>SET col_name1 = expression1, col_name2 = expression2, .... </li></ul><ul><li>[ WHERE expression ] </li></ul><ul><li>[ LIMIT limit_amount ] </li></ul>
  14. 14. DELETE <ul><li>The DELETE Statement is used the remove the records from the table. </li></ul><ul><li>The syntax of delete command is : </li></ul><ul><li>DELETE FROM table_name [WHERE Clause] </li></ul>
  15. 15. DCL COMMANDS <ul><li>DCL is abbreviation for Data control language. </li></ul><ul><li>It is used to create roles, permissions, and referential integrity as well it is useto control access to database by securing it. </li></ul><ul><li>The DCL Commands are GRANT </li></ul>
  16. 16. GRANT <ul><li>The GRANT statement specifies that this user is only allowed to run a limited amount of statements on the MySQL server. </li></ul><ul><li>This user will be allowed to: select records, insert records, update records, delete records, create databases, and DROP DATABASEs. </li></ul><ul><li>More importantly, this user is not permitted to create users and set privileges. </li></ul><ul><li>The syntax of grant statement is : </li></ul><ul><li>GRANT privileges ON database_object TO ( PUBLIC | user_list ) </li></ul><ul><li>[ WITH GRANT OPTION ] </li></ul>
  17. 17. REVOKE <ul><li>Like the GRANT command, you must have the privileges you want to revoke from the user along with the GRANT OPTION privilege. </li></ul><ul><li>The syntax of revoke command is : </li></ul><ul><li>REVOKE [ GRANT OPTION FOR ] privileges ON database_object FROM ( PUBLIC | user_list ) </li></ul>
  18. 18. TCL COMMANDS <ul><li>TCL Commands stands for Transactional control language. </li></ul><ul><li>It is used to handle all the transactions occuring in the database. </li></ul><ul><li>The transactional control language commands are COMMIT and ROLLBACK. </li></ul>
  19. 19. COMMIT <ul><li>When a successful transaction is completed, the COMMIT command should be issued so that the changes to all involved tables will take effect. </li></ul><ul><li>The syntax of commit command is : </li></ul><ul><li>COMMIT </li></ul>
  20. 20. ROLLBACK <ul><li>If a failure occurs, a ROLLBACK command should be issued to return every table referenced in the transaction to its previous state. </li></ul><ul><li>The syntax of Rollback is : </li></ul><ul><li>ROLLBACK </li></ul>
  21. 21. JOINS <ul><li>Sometimes you required the data from more than one table. </li></ul><ul><li>When you select the data from more than one table this is known as Joining. </li></ul><ul><li>A join is a SQL query that is used to select the data from more than one table or views. </li></ul><ul><li>When you define multiple tables or views in the FROM clause of a query the MySQL performs a join that linking the rows from multiple tables together. </li></ul><ul><li>There are three different types of joins in mysql, INNER JOIN, OUTER JOIN and SELF JOIN. </li></ul>
  22. 22. INNER JOIN <ul><li>The INNER join is considered as the default Join type. </li></ul><ul><li>Inner join returns the column values from one row of a table combined with the column values from one row of another table that satisfy the search condition for the join. </li></ul><ul><li>The general syntax of INNER Join is : </li></ul><ul><li>SELECT <column_name1>, <column_name2> FROM <tbl_name> INNER JOIN <tbl_name> ON <join_conditions> </li></ul>
  23. 23. OUTER JOIN <ul><li>Sometimes when we are performing a Join between the two tables, we need all the records from one table even there is no corresponding record in other table. We can do this with the help of OUTER Join. </li></ul><ul><li>In other words an OUTER Join returns the all rows that returned by an INNER Join plus all the rows from one table that did not match any row from the other table. Outer Join are divided in two types : LEFT OUTER Join, RIGHT OUTER Join </li></ul>
  24. 24. THANK YOU
  25. 25. OUTERJOIN <ul><li>LEFT OUTER JOIN :- </li></ul><ul><li>LEFT OUTER Join is used to return all the rows that returned by an INNER Join plus all the rows from first table that did not match with any row from the second table but with the NULL values for each column from second table. </li></ul><ul><li>The general syntax of LEFT OUTER Join is : </li></ul><ul><li>SELECT <column_name1>, <column_name2> FROM <tbl_name> LEFT OUTER JOIN <tbl_name> ON <join_conditions> </li></ul>
  26. 26. OUTER JOIN <ul><li>RIGHT OUTER JOIN :- </li></ul><ul><li>RIGHT OUTER Join is much same as the LEFT OUTER JOIN. </li></ul><ul><li>But RIGHT OUTER Join is used to return all the rows that returned by an INNER Join plus all the rows from second table that did not match with any row from the first table but with the NULL values for each column from first table. </li></ul><ul><li>The general syntax of RIGHT OUTER Join is : </li></ul><ul><li>SELECT <column_name1>, <column_name2> FROM <tbl_name> RIGHT OUTER JOIN <tbl_name> ON <join_conditions> </li></ul>
  27. 27. SELF JOIN <ul><li>SELF Join means a table can be joined with itself. </li></ul><ul><li>SELF Join is useful when we want to compare values in a column to other values in the same column. </li></ul><ul><li>For creating a SELF Join we have to list a table twice in the FROM clause and assign it a different alias each time. For referring the table we have to use this aliases. </li></ul>