Your SlideShare is downloading. ×
Sql
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Sql

481

Published on

The main definition,basic queries and functions

The main definition,basic queries and functions

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
481
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MYSQL Data Manipulation Language(DML)     :   1.SELECT­ extracts data from a database.   2.UPDATE­update data from a database.   3.DELETE ­deletes data from a database.   4.INSERT INTO – inserts a new data into database  Select statements:                                    The Select statement is used to select data from a database. Syntax             1.Select *  from table_name Eg:          Select   * from person             2.Select column_name(s) from table Eg:           Select lastname, firstname from person Update Statement:                              The update statement is used to update records in a table. Syntax:                    Update table_name set column1=value,column2=value2,...where  some_column=some_value Eg:   Update Persons  set Address='parrys', where LastName='kumar' and FirstName='kalpana' Delete Statement:                             The Delete statement is used to delete records in a table. Syntax:               Delete from table_name where some_columns =some values Eg:        Delete from Persons where LastName='viji' and FirstName='kavitha' Insert Statement:                                 The Insert into statement is used to insert new records in a table. Syntax          Insert into table_name values(value 1,value 2,value 3.........) Eg:        Insert into Persons values('15','anu','kanna','minjur')
  • 2. DDL(Data Definition Languages                    The DDL part of SQL permits database tables to be created or deleted. It also define  indexes (keys), specify links between tables, and impose constraints between tables.              1.creates database­ creates a new database              2.alter databases­ modifies a databases              3.create table­ create a new table              4.alter table­ modifies a table              5.drop table ­ deletes a table              6.create index­ creates an index (search key)              7.drop index ­ deletes an index     Create database Statement:                   The create database statement is used to create a database. Syntax:       create database database_name Eg:      create database my_db  Create table Statement          The Create table statement is used to create a table in a database. Syntax             Create table_name( column_name1 data_type,column_name2 data_type,column_name3  data_type,...) Eg:      Create table Persons(P_Id int,LastName varchar(255),FirstName varchar(255),Address  varchar(255)) Alter table Statement:            The alter statement is used to add, delete, or modify columns in an existing . Syntax:      add a column in a table             alter table table_name add column_name datatype Eg:     alter table Persons add  DateOfBirth date Drop index Statement          The drop index statement is used to delete an index in a table.         Eg :        Drop index table_name.index_name Drop table Statement:         The drop table statement is used to delete a table. Eg:       Drop table table_name Drop database Statement       The drop database statement is used to delete a database.     Eg:       Drop database database_name
  • 3. PHP MY ADMIN                        Php MyAdmin 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:               1.Support for most MySQL features.               2.Import data from CSV and SQL               3.Administering multiple servers               4.Creating PDF 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 8.Export data to various formats: CSV, SQL, XML, PDF, ISO/IEC 26300 - OpenDocument Text and Spreadsheet, Word, Excel, LATEX and others. DCL:Data Control Language 1.COMMIT                              SQL>COMMIT         This will commit (write to data base) 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 m 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. SQL Functions         SQL has many built­in functions for performing calculations on data Aggregate Functions             SQL aggregate functions return a single value, calculated from values in a column.     *  AVG() ­ Returns the average value     * COUNT() ­ Returns the number of rows     * FIRST() ­ Returns the first value     * LAST() ­ Returns the last value     * MAX() ­ Returns the largest value     * MIN() ­ Returns the smallest value     * SUM() ­ Returns the sum Scalar functions            SQL scalar functions return a single value, based on the input value.               # UCASE() ­ Converts a field to upper case               # LCASE() ­ Converts a field to lower case               # MID() ­ Extract characters from a text field 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;     

×