SlideShare ist ein Scribd-Unternehmen logo
1 von 20
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.
Continue... 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 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 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')
Continue... (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
Continue... (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  BYyrthujoi'; 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, field 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
Continue... 2. Import data from and  Export data to various  formats: , , , , / 26300 – OpenDocument Text  and Spreadsheet, , , L A T E X and others  3. Administering multiple servers  4 .Creating graphics of your database layout  5 .Creating complex queries using Query-by-  example (QBE)  6 .Searching globally in a database or a subset of it  7 .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.
Continue 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.
Continue.... 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() .
Continue.... 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.

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Database administration commands
Database administration commands Database administration commands
Database administration commands
 
Oracle ORA Errors
Oracle ORA ErrorsOracle ORA Errors
Oracle ORA Errors
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
 
15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboards15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboards
 
DBD::SQLite
DBD::SQLiteDBD::SQLite
DBD::SQLite
 
4.3 MySQL + PHP
4.3 MySQL + PHP4.3 MySQL + PHP
4.3 MySQL + PHP
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
 
Procedures and triggers in SQL
Procedures and triggers in SQLProcedures and triggers in SQL
Procedures and triggers in SQL
 
Database Connection Pane
Database Connection PaneDatabase Connection Pane
Database Connection Pane
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Mysql & Php
Mysql & PhpMysql & Php
Mysql & Php
 
PHP with MySQL
PHP with MySQLPHP with MySQL
PHP with MySQL
 
Tuning SGA
Tuning SGATuning SGA
Tuning SGA
 
Lab1-DB-Cassandra
Lab1-DB-CassandraLab1-DB-Cassandra
Lab1-DB-Cassandra
 
An Introduction To PostgreSQL Triggers
An Introduction To PostgreSQL TriggersAn Introduction To PostgreSQL Triggers
An Introduction To PostgreSQL Triggers
 
MySql:Basics
MySql:BasicsMySql:Basics
MySql:Basics
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Sql storeprocedure
Sql storeprocedureSql storeprocedure
Sql storeprocedure
 
16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards
 

Ähnlich wie Msql

PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
Oracle - Program with PL/SQL - Lession 14
Oracle - Program with PL/SQL - Lession 14Oracle - Program with PL/SQL - Lession 14
Oracle - Program with PL/SQL - Lession 14Thuan Nguyen
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
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...Ontico
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql SyntaxReka
 
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 Developmentrehaniltifat
 
Procedures/functions of rdbms
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbmsjain.pralabh
 
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...Jürgen Ambrosi
 
Mysqlppt
MysqlpptMysqlppt
MysqlpptReka
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
My sql presentation
My sql presentationMy sql presentation
My sql presentationNikhil Jain
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
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 KnowAlex Zaballa
 

Ähnlich wie Msql (20)

PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Oracle - Program with PL/SQL - Lession 14
Oracle - Program with PL/SQL - Lession 14Oracle - Program with PL/SQL - Lession 14
Oracle - Program with PL/SQL - Lession 14
 
Sah
SahSah
Sah
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
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...
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
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
 
My sql
My sqlMy sql
My sql
 
Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
 
Procedures/functions of rdbms
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbms
 
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...
 
MySQL
MySQLMySQL
MySQL
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
 
My sql presentation
My sql presentationMy sql presentation
My sql presentation
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
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
 

Msql

  • 1. 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.
  • 2. Continue... 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
  • 3. 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
  • 4. 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
  • 5. 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 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 select,insert,delete,update on emp details from main_dep
  • 6. 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')
  • 7. Continue... (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
  • 8. Continue... (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
  • 9. 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;
  • 10. 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 BYyrthujoi'; We can verify the new user has been added by querying the user table: mysql> SELECT host, user, password FROM user WHERE user='johnB' ;
  • 11. Deleting a MySQL User : DROP USER user name ; DROP USER 'johnB'@'localhost';
  • 12. Renaming a MySQL User : RENAME USER user name TO new user name ; RENAME USER 'johnB'@'localhost' TO 'johnBrown'@'localhost';
  • 13. 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');
  • 14. 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.
  • 15. 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, field 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
  • 16. Continue... 2. Import data from and Export data to various formats: , , , , / 26300 – OpenDocument Text and Spreadsheet, , , L A T E X and others 3. Administering multiple servers 4 .Creating graphics of your database layout 5 .Creating complex queries using Query-by- example (QBE) 6 .Searching globally in a database or a subset of it 7 .Transforming stored data into any format using a set of predefined functions, like displaying BLOB-data as image or download-link.
  • 17. 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.
  • 18. Continue 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.
  • 19. Continue.... 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() .
  • 20. Continue.... 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.