SlideShare ist ein Scribd-Unternehmen logo
1 von 11
MY SQL
DCL:Data Control Language
    1.COMMIT
      SQL>COMMIT
      This will commit (write to dadabase) the transcation
      done by DML
    2.ROLLBACK
      SQL>ROLLBACK
      This will rollback the transactions and will not
      commit the changes to the database.
    3.GRANT
      Giving the permission to acess the user1's objects to
       user2.
       Grant privilege on <object_name> to <user_ name>
       Grant select,insert,delete,update on empdetails to
       main_dep
    4.REVOKE
       Withdraw the privilege which has been granted to the
       user, we use the revoke command
       Revoke privilege on <object_name> from
       <user_name>
        Revoke select,insert,delete,update on emp details
        from main_dep
DDL: Data Definition Language
    1.CREATE
      create database suji
      create table emp(ename varchar(256),eid int identity(1,1),
      edep varchar(256),esalary int)
    2.ALTER:
      alter table emp add eaddr varchar(256)
      alter table emp modify ename varchar(200)
    3.DROP
      drop table emp


DML: Data Manipulation Language
    1.SELECT
       select * from emp
    2.INSERT
       insert into emp value (suji,101,it,20000)
    3.UPDATE
       update emp set ename=amal ,edep=it , esalary=20000
       where eid=101
     4.DELETE
       delete from emp where eid=101
PRIVILEGE:
   It is the right to access another user's objects.
   1.GRANT PRIVILEGE:
       Giving the permission to acess the user1's objects to
       user2.
       Grant privilege on <object_name> to <user_ name>
       Grant select,insert,delete,update on empdetails to
       main_dep
   2.REVOKE PRIVILEGE:
       Withdraw the privilege which has been granted to the
       user, we use the revoke command
       Revoke privilege on <object_name> from
       <user_name>
       Revoke select,insert,delete,update on emp details
       from main_dep
FUNCTIONS:
   A function perform an operation and return a value.
   1.SCALAR FUNCTION
      (A)Numeric function
          select round(12.5,0),round912.499,1)
          select sign(-10),sign(10)
          select power(5,3)
      (B)String function
          select lower(ename),upper(ename) from emp
          select len('queries')
          select replace('queries','e','i')
      (C)Date and Time function
         select get date('today date')
         select * from emp where month(Doj)=4
      (D)System function
          DB_NAME()
          OBJECT_ID('object name')
      (E)Calculating results
         select ename,esalary,esalary*12,'annual esalary'
         from emp
      (F)Convertion function
         select ename,convert(varchar,doj,1) AS from emp
         'joined date'.
2.AGGREGATE FUNCTION
     (A)AVG
     (B)COUNT
     (C)MAX
     (D)MIN
     (E)SUM
USERS:
       The mysql database contains a table called user which in turn
contains a number of columns including the user login name and the
users various privileges and connection rights. To obtain a list of users
run the following command:
       SELECT user FROM user;
 A newly installed MySQL database will only list one user, the root
 user:
       mysql> select user from user;

Creating a New MySQL User:
      The syntax for creating a user account is as follows:
      CREATE user name IDENTIFIED BY 'password';
       CREATE USER 'johnB'@'localhost' IDENTIFIED BY '
       'yrthujoi';
       We can verify the new user has been added by querying the user
       table:
       mysql> SELECT host, user, password FROM

       user WHERE user='johnB';

Deleting a MySQL User:

       DROP USER user name;

       DROP USER 'johnB'@'localhost';

Renaming a MySQL User :

       RENAME USER user name TO new user name;

       RENAME USER 'johnB'@'localhost' TO

       'johnBrown'@'localhost';
Changing the Password for a MySQL User :

      To change the password for your own account, use the following

       syntax:

       SET PASSWORD = Password('newpassword');
       SET PASSWORD FOR 'johnB'@'localhost' =
       Password('newpassword');


PHPMYADMIN:
      phpMyAdmin is a free software tool written in PHP intended to
handle the administration of MySQL over the World Wide Web.
phpMyAdmin supports a wide range of operations with MySQL. The
most frequently used operations are supported by the user interface
(managing databases, tables, fields, relations, indexes, users,
permissions,etc), while you still have the ability to directly execute any
SQL statement.
Features
     Intuitive web interface
      1.Support for most MySQL features:
        a. browse and drop databases, tables, views, fields and indexes
        b. create, copy, drop, rename and alter databases, tables, fields
           and indexes
        c. maintenance server, databases and tables, with proposals on
           server configuration
        d. execute, edit and bookmark any -statement, even batch-
           queries
        e. manage MySQL users and privileges
        f. manage stored procedures and triggers
2. Import data from and
      3.Export data to various formats: , , , , / 26300 – OpenDocument
        Text and Spreadsheet, , , LATEX and others
      4.Administering multiple servers
      5.Creating graphics of your database layout
      6.Creating complex queries using Query-by-example (QBE)
      7.Searching globally in a database or a subset of it
      8.Transforming stored data into any format using a set of
         predefined functions, like displaying BLOB-data as image or
         download-link.


 PROCEDURES:
        Stored procedures are set of SQL commands that are stored in
the database data server. After the storing of the commands is done, the
tasks can be performed or executed continuously, without being
repeatedly sent to the server.
Executing Stored Procedures:
         MySQL refers to stored procedure execution as calling, and so
the MySQL statement to execute a stored procedure is simply CALL.
CALL takes the name of the stored procedure and any parameters that
need to be passed to it. Take a look at this example:
       • Input
        CALL productpricing(@pricelow,
                   @pricehigh,
                   @priceaverage);


         Analysis
         Here a stored procedure named productpricing is
        executed; it calculates and returns the lowest, highest, and
        average product prices.
        Stored procedures might or might not display results, as you
        will see shortly.
Creating Stored Procedures:
        Input
          CREATE PROCEDURE productpricing()
          BEGIN
          SELECT Avg(prod_price) AS
          priceaverage
          FROM products;
          END;

        Analysis

        The stored procedure is named productpricing and

        is thus defined with the statement CREATE

        PROCEDURE productpricing().This stored procedure has no

        parameters, but the trailing () is still required. BEGIN and

        END statements are used to delimit the stored procedure body,

        and the body itself is just a simple SELECT statement.

Dropping Stored Procedures:

        To remove the stored procedure we just created, use the

        following statement:
        Input
          DROP PROCEDURE productpricing;

        Analysis
       This removes the just-created stored procedure. Notice that
       the trailing () is not used; here just the stored procedure name
        is specified.
Mysql
Mysql

Weitere ähnliche Inhalte

Was ist angesagt?

My sql with querys
My sql with querysMy sql with querys
My sql with querys
NIRMAL FELIX
 
Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With Mysql
Harit Kothari
 
Learn PHP Lacture2
Learn PHP Lacture2Learn PHP Lacture2
Learn PHP Lacture2
ADARSH BHATT
 

Was ist angesagt? (20)

My sql with querys
My sql with querysMy sql with querys
My sql with querys
 
MYSQL
MYSQLMYSQL
MYSQL
 
Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With Mysql
 
Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database Jones
 
Beginner guide to mysql command line
Beginner guide to mysql command lineBeginner guide to mysql command line
Beginner guide to mysql command line
 
Mysql ppt
Mysql pptMysql ppt
Mysql ppt
 
Introduction to php database connectivity
Introduction to php  database connectivityIntroduction to php  database connectivity
Introduction to php database connectivity
 
MySQL Cheat Sheet
MySQL Cheat SheetMySQL Cheat Sheet
MySQL Cheat Sheet
 
Developing for Node.JS with MySQL and NoSQL
Developing for Node.JS with MySQL and NoSQLDeveloping for Node.JS with MySQL and NoSQL
Developing for Node.JS with MySQL and NoSQL
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
 
java
javajava
java
 
MySQL Document Store
MySQL Document StoreMySQL Document Store
MySQL Document Store
 
Data Processing Inside PostgreSQL
Data Processing Inside PostgreSQLData Processing Inside PostgreSQL
Data Processing Inside PostgreSQL
 
My sql.ppt
My sql.pptMy sql.ppt
My sql.ppt
 
My sql tutorial-oscon-2012
My sql tutorial-oscon-2012My sql tutorial-oscon-2012
My sql tutorial-oscon-2012
 
Learn PHP Lacture2
Learn PHP Lacture2Learn PHP Lacture2
Learn PHP Lacture2
 
Optimizer Cost Model MySQL 5.7
Optimizer Cost Model MySQL 5.7Optimizer Cost Model MySQL 5.7
Optimizer Cost Model MySQL 5.7
 
PostgreSQL- An Introduction
PostgreSQL- An IntroductionPostgreSQL- An Introduction
PostgreSQL- An Introduction
 
Lab2-DB-Mongodb
Lab2-DB-MongodbLab2-DB-Mongodb
Lab2-DB-Mongodb
 

Andere mochten auch (7)

The colors
The colorsThe colors
The colors
 
Chapitre 7
Chapitre 7Chapitre 7
Chapitre 7
 
Conference Package - Holiday Inn Express &amp; Suites Gananoque
Conference Package - Holiday Inn Express &amp; Suites GananoqueConference Package - Holiday Inn Express &amp; Suites Gananoque
Conference Package - Holiday Inn Express &amp; Suites Gananoque
 
Els lleons
Els lleonsEls lleons
Els lleons
 
Ph
PhPh
Ph
 
Can unit 1 2o.
Can unit 1 2o.Can unit 1 2o.
Can unit 1 2o.
 
Quality Inn Tower Room Package
Quality Inn Tower Room PackageQuality Inn Tower Room Package
Quality Inn Tower Room Package
 

Ähnlich wie Mysql

Get database properties using power shell in sql server 2008 techrepublic
Get database properties using power shell in sql server 2008   techrepublicGet database properties using power shell in sql server 2008   techrepublic
Get database properties using power shell in sql server 2008 techrepublic
Kaing Menglieng
 
1 Database Security Lab 2 – Virtual Private Database.docx
1 Database Security Lab 2 – Virtual Private Database.docx1 Database Security Lab 2 – Virtual Private Database.docx
1 Database Security Lab 2 – Virtual Private Database.docx
jeremylockett77
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
Reka
 

Ähnlich wie Mysql (20)

Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
 
Jsp project module
Jsp project moduleJsp project module
Jsp project module
 
Get database properties using power shell in sql server 2008 techrepublic
Get database properties using power shell in sql server 2008   techrepublicGet database properties using power shell in sql server 2008   techrepublic
Get database properties using power shell in sql server 2008 techrepublic
 
Database administration
Database administrationDatabase administration
Database administration
 
1 Database Security Lab 2 – Virtual Private Database.docx
1 Database Security Lab 2 – Virtual Private Database.docx1 Database Security Lab 2 – Virtual Private Database.docx
1 Database Security Lab 2 – Virtual Private Database.docx
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
 
SQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptxSQL_SERVER_BASIC_1_Training.pptx
SQL_SERVER_BASIC_1_Training.pptx
 
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
Sql
SqlSql
Sql
 
12c db upgrade from 11.2.0.4
12c db upgrade from 11.2.0.412c db upgrade from 11.2.0.4
12c db upgrade from 11.2.0.4
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 
08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata
 
Sql lite android
Sql lite androidSql lite android
Sql lite android
 
MariaDB training
MariaDB trainingMariaDB training
MariaDB training
 
Useful PL/SQL Supplied Packages
Useful PL/SQL Supplied PackagesUseful PL/SQL Supplied Packages
Useful PL/SQL Supplied Packages
 
Sah
SahSah
Sah
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 

Mysql

  • 1. MY SQL DCL:Data Control Language 1.COMMIT SQL>COMMIT This will commit (write to dadabase) the transcation done by DML 2.ROLLBACK SQL>ROLLBACK This will rollback the transactions and will not commit the changes to the database. 3.GRANT Giving the permission to acess the user1's objects to user2. Grant privilege on <object_name> to <user_ name> Grant select,insert,delete,update on empdetails to main_dep 4.REVOKE Withdraw the privilege which has been granted to the user, we use the revoke command Revoke privilege on <object_name> from <user_name> Revoke select,insert,delete,update on emp details from main_dep
  • 2. DDL: Data Definition Language 1.CREATE create database suji create table emp(ename varchar(256),eid int identity(1,1), edep varchar(256),esalary int) 2.ALTER: alter table emp add eaddr varchar(256) alter table emp modify ename varchar(200) 3.DROP drop table emp DML: Data Manipulation Language 1.SELECT select * from emp 2.INSERT insert into emp value (suji,101,it,20000) 3.UPDATE update emp set ename=amal ,edep=it , esalary=20000 where eid=101 4.DELETE delete from emp where eid=101
  • 3. PRIVILEGE: It is the right to access another user's objects. 1.GRANT PRIVILEGE: Giving the permission to acess the user1's objects to user2. Grant privilege on <object_name> to <user_ name> Grant select,insert,delete,update on empdetails to main_dep 2.REVOKE PRIVILEGE: Withdraw the privilege which has been granted to the user, we use the revoke command Revoke privilege on <object_name> from <user_name> Revoke select,insert,delete,update on emp details from main_dep
  • 4. FUNCTIONS: A function perform an operation and return a value. 1.SCALAR FUNCTION (A)Numeric function select round(12.5,0),round912.499,1) select sign(-10),sign(10) select power(5,3) (B)String function select lower(ename),upper(ename) from emp select len('queries') select replace('queries','e','i') (C)Date and Time function select get date('today date') select * from emp where month(Doj)=4 (D)System function DB_NAME() OBJECT_ID('object name') (E)Calculating results select ename,esalary,esalary*12,'annual esalary' from emp (F)Convertion function select ename,convert(varchar,doj,1) AS from emp 'joined date'.
  • 5. 2.AGGREGATE FUNCTION (A)AVG (B)COUNT (C)MAX (D)MIN (E)SUM
  • 6. USERS: The mysql database contains a table called user which in turn contains a number of columns including the user login name and the users various privileges and connection rights. To obtain a list of users run the following command: SELECT user FROM user; A newly installed MySQL database will only list one user, the root user: mysql> select user from user; Creating a New MySQL User: The syntax for creating a user account is as follows: CREATE user name IDENTIFIED BY 'password'; CREATE USER 'johnB'@'localhost' IDENTIFIED BY ' 'yrthujoi'; We can verify the new user has been added by querying the user table: mysql> SELECT host, user, password FROM user WHERE user='johnB'; Deleting a MySQL User: DROP USER user name; DROP USER 'johnB'@'localhost'; Renaming a MySQL User : RENAME USER user name TO new user name; RENAME USER 'johnB'@'localhost' TO 'johnBrown'@'localhost';
  • 7. Changing the Password for a MySQL User : To change the password for your own account, use the following syntax: SET PASSWORD = Password('newpassword'); SET PASSWORD FOR 'johnB'@'localhost' = Password('newpassword'); PHPMYADMIN: phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. phpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions,etc), while you still have the ability to directly execute any SQL statement. Features Intuitive web interface 1.Support for most MySQL features: a. browse and drop databases, tables, views, fields and indexes b. create, copy, drop, rename and alter databases, tables, fields and indexes c. maintenance server, databases and tables, with proposals on server configuration d. execute, edit and bookmark any -statement, even batch- queries e. manage MySQL users and privileges f. manage stored procedures and triggers
  • 8. 2. Import data from and 3.Export data to various formats: , , , , / 26300 – OpenDocument Text and Spreadsheet, , , LATEX and others 4.Administering multiple servers 5.Creating graphics of your database layout 6.Creating complex queries using Query-by-example (QBE) 7.Searching globally in a database or a subset of it 8.Transforming stored data into any format using a set of predefined functions, like displaying BLOB-data as image or download-link. PROCEDURES: Stored procedures are set of SQL commands that are stored in the database data server. After the storing of the commands is done, the tasks can be performed or executed continuously, without being repeatedly sent to the server. Executing Stored Procedures: MySQL refers to stored procedure execution as calling, and so the MySQL statement to execute a stored procedure is simply CALL. CALL takes the name of the stored procedure and any parameters that need to be passed to it. Take a look at this example: • Input CALL productpricing(@pricelow, @pricehigh, @priceaverage); Analysis Here a stored procedure named productpricing is executed; it calculates and returns the lowest, highest, and average product prices. Stored procedures might or might not display results, as you will see shortly.
  • 9. Creating Stored Procedures: Input CREATE PROCEDURE productpricing() BEGIN SELECT Avg(prod_price) AS priceaverage FROM products; END; Analysis The stored procedure is named productpricing and is thus defined with the statement CREATE PROCEDURE productpricing().This stored procedure has no parameters, but the trailing () is still required. BEGIN and END statements are used to delimit the stored procedure body, and the body itself is just a simple SELECT statement. Dropping Stored Procedures: To remove the stored procedure we just created, use the following statement: Input DROP PROCEDURE productpricing; Analysis This removes the just-created stored procedure. Notice that the trailing () is not used; here just the stored procedure name is specified.