• Save
Upcoming SlideShare
Loading in...5







Total Views
Views on SlideShare
Embed Views



1 Embed 2

http://jebaranjan.com 2



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.

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

Sql Sql Presentation Transcript

  • SQL  SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in relational database.  SQL is an ANSI (American National Standards Institute) standard but there are many different versions of the SQL language.  SQL is the standard language for Relation Database System. All relational database management systems like MySQL, MS Access, Oracle, Sybase, Informix, postgres and SQL Server use SQL as standard database language.  Also, they are using different dialects, such as:  MS SQL Server using T-SQL,  Oracle using PL/SQL,  MS Access version of SQL is called JET SQL (native format) etc.
  • SQL Constraints: ( )  Constraints are the rules enforced on data columns on table. These are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the database. Following are commonly used constraints available in SQL:  NOT NULL Constraint: Ensures that a column cannot have NULL value.  DEFAULT Constraint: Provides a default value for a column when none is specified.  UNIQUE Constraint: Ensures that all values in a column are different.  PRIMARY Key: Uniquely identified each rows/records in a database table.  FOREIGN Key: Uniquely identified a rows/records in any another database table.  CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy certain conditions.  INDEX: Use to create and retrieve data from the database very quickly.
  • Data Integrity  The following categories of the data integrity exist with each RDBMS:  Entity Integrity: There are no duplicate rows in a table.  Domain Integrity: Enforces valid entries for a given column by restricting the type, the format, or the range of values.  Referential integrity: Rows cannot be deleted, which are used by other records.  User-Defined Integrity: Enforces some specific business rules that do not fall into entity, domain or referential integrity.
  • CREATE Database
  • DROP or DELETE Database
  • SELECT Database, USE Statement
  • CREATE Table
  • DROP or DELETE Table
  • INSERT Query
  • SQL - SELECT Query
  • SQL - WHERE Clause
  • SQL - AND and OR Conjunctive Operators
  • UPDATE Query
  • DELETE Query Following is an example, which would DELETE a customer, whose ID is 6: If you want to DELETE all the records from CUSTOMERS table, you do not need to use WHERE clause and DELETE query would be as follows:
  • LIKE Clause
  • Following is an example, which would display all the records from CUSTOMERS table where SALARY starts with 200:
  • TOP, LIMIT or ROWNUM Clause The SQL TOP clause is used to fetch a TOP N number or X percent records from a table. All the databases do not support TOP clause. For example MySQL supports LIMIT clause to fetch limited number of records and Oracle uses ROWNUM to fetch limited number of records.
  • ORDER BY Clause  The SQL ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. Some database sorts query results in ascending order by default.
  • SQL - Group By  The SQL GROUP BY clause is used in collaboration with the SELECT statement to arrange identical data into groups.
  • Distinct Keyword  The SQL DISTINCT keyword is used in conjunction with SELECT statement to eliminate all the duplicate records and fetching only unique records.
  • NOT NULL Constraint  By default, a column can hold NULL values. If you do not want a column to have a NULL value, then you need to define such constraint on this column specifying that NULL is now not allowed for that column. A NULL is not the same as no data, rather, it represents unknown data.
  • DEFAULT Constraint  The DEFAULT constraint provides a default value to a column when the INSERT INTO statement does not provide a specific value.
  • UNIQUE Constraint  The UNIQUE Constraint prevents two records from having identical values in a particular column. In the CUSTOMERS table, for example, you might want to prevent two or more people from having identical age.
  • Primary Key
  • Foreign Key  The relationship between 2 tables matches the Primary Key in one of the tables with a Foreign Key in the second table.