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.
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.