Mysql
Upcoming SlideShare
Loading in...5
×
 

Mysql

on

  • 1,563 views

 

Statistics

Views

Total Views
1,563
Views on SlideShare
1,563
Embed Views
0

Actions

Likes
1
Downloads
71
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Mysql Mysql Presentation Transcript

  • MYSQL
  • INTRODUCTION
    • WHAT IS A DATABASE?
    • 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.
    • 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.
    • So now a days we use relational database management systems (RDBMS) to store and manager huge volume of data.
  • RDBMS
    • WHAT IS RDBMS?
    • 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.
    • 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.
  • MYSQL DATABASE
    • 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.
    • MySQL is released under an open-source license. So you have nothing to pay to use it.
    • 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.
    • MySQL uses a standard form of the well-known SQL data language.
    • MySQL works on many operating systems and with many languages including PHP, PERL, C, C++, JAVA etc.
    • MySQL works very quickly and works well even with large data sets.
  • MYSQL COMMANDS
    • MYSQL Commands consists of three categories
    • DDL (Data defenition language)
    • DML (Data manipulation language)
    • TCL (Transaction control language) and
    • DCL (Data control language)
  • DDL COMMANDS
    • A Data Definition Language (DDL) is a computer language for defining data structures.
    • 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 "sets" 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.
    • The DDL Commands in MYSQL are CREATE, ALTER and DROP .
  • CREATE
    • To make a new database, table, index, or stored query.
    • A CREATE statement in MY SQL creates an object inside of a relational database management system (RDBMS).
    • 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.
    • The syntax of create statement is :
    • CREATE [TEMPORARY] TABLE [table name] ( [column definitions] ) [table parameters].
  • ALTER
    • To modify an existing database object.
    • 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.
    • The syntax of ALTER statement is:
    • ALTER TABLE tbl_name ADD [COLUMN] col_name column_definition
  • DROP
    • DROP DATABASE command is used to drop the all tables in the given database and deletes the database also.
    • But for using the DROP DATABASE statement you need the DROP privilege on the database.
    • 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.
    • The syntax of DROP command is :
    • DROP [TEMPORARY] TABLE [IF EXISTS] tbl_name
    • DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
  • DML COMMANDS
    • 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.
    • The Data manipulation commands are SELECT, INSERT, UPDATE and DELETE.
  • SELECT
    • 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.
    • In this statement the user can specify a description of the required result set.
    • The syntax of select command is :
    • 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, .... ]
  • INSERT
    • The INSERT statement is used to add one or more records to a existing table in a database.
    • This statement can insert the data into only a single table.
    • The syntax of insert command is :
    • INSERT INTO table_name [ ( col_name1, col_name2, .... ) ]
    • VALUES ( expression1_1, expression1_2, .... ),
    • ( expression2_1, expression2_2, .... ), ....
  • UPDATE
    • The UPDATE statement is used to modify the record contained with in a table either one row or more than one row.
    • The syntax of update command is :
    • UPDATE table_name
    • SET col_name1 = expression1, col_name2 = expression2, ....
    • [ WHERE expression ]
    • [ LIMIT limit_amount ]
  • DELETE
    • The DELETE Statement is used the remove the records from the table.
    • The syntax of delete command is :
    • DELETE FROM table_name [WHERE Clause]
  • DCL COMMANDS
    • DCL is abbreviation for Data control language.
    • It is used to create roles, permissions, and referential integrity as well it is useto control access to database by securing it.
    • The DCL Commands are GRANT
  • GRANT
    • The GRANT statement specifies that this user is only allowed to run a limited amount of statements on the MySQL server.
    • This user will be allowed to: select records, insert records, update records, delete records, create databases, and DROP DATABASEs.
    • More importantly, this user is not permitted to create users and set privileges.
    • The syntax of grant statement is :
    • GRANT privileges ON database_object TO ( PUBLIC | user_list )
    • [ WITH GRANT OPTION ]
  • REVOKE
    • Like the GRANT command, you must have the privileges you want to revoke from the user along with the GRANT OPTION privilege.
    • The syntax of revoke command is :
    • REVOKE [ GRANT OPTION FOR ] privileges ON database_object FROM ( PUBLIC | user_list )
  • TCL COMMANDS
    • TCL Commands stands for Transactional control language.
    • It is used to handle all the transactions occuring in the database.
    • The transactional control language commands are COMMIT and ROLLBACK.
  • COMMIT
    • When a successful transaction is completed, the COMMIT command should be issued so that the changes to all involved tables will take effect.
    • The syntax of commit command is :
    • COMMIT
  • ROLLBACK
    • If a failure occurs, a ROLLBACK command should be issued to return every table referenced in the transaction to its previous state.
    • The syntax of Rollback is :
    • ROLLBACK
  • JOINS
    • Sometimes you required the data from more than one table.
    • When you select the data from more than one table this is known as Joining.
    • A join is a SQL query that is used to select the data from more than one table or views.
    • 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.
    • There are three different types of joins in mysql, INNER JOIN, OUTER JOIN and SELF JOIN.
  • INNER JOIN
    • The INNER join is considered as the default Join type.
    • 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.
    • The general syntax of INNER Join is :
    • SELECT <column_name1>, <column_name2> FROM <tbl_name> INNER JOIN <tbl_name> ON <join_conditions>
  • OUTER JOIN
    • 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.
    • 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
  • THANK YOU
  • OUTERJOIN
    • LEFT OUTER JOIN :-
    • 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.
    • The general syntax of LEFT OUTER Join is :
    • SELECT <column_name1>, <column_name2> FROM <tbl_name> LEFT OUTER JOIN <tbl_name> ON <join_conditions>
  • OUTER JOIN
    • RIGHT OUTER JOIN :-
    • RIGHT OUTER Join is much same as the LEFT OUTER JOIN.
    • 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.
    • The general syntax of RIGHT OUTER Join is :
    • SELECT <column_name1>, <column_name2> FROM <tbl_name> RIGHT OUTER JOIN <tbl_name> ON <join_conditions>
  • SELF JOIN
    • SELF Join means a table can be joined with itself.
    • SELF Join is useful when we want to compare values in a column to other values in the same column.
    • 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.