SQL
INDEX
• Introduction
• Basic SQL
INTRODUCTION
• SQL lets you access and manipulate databases
• SQL became a standard of the American National Standards Institute (ANSI)
in 1986, and of the International Organization for Standardization (ISO) in
1987
What Can SQL do?
• SQL can create new databases, schemas, Tables
• SQL can insert, Update, Delete records in a database
• SQL can execute queries against a database
• SQL can retrieve data from a database
REQUIREMENT FOR USE SQL
• An RDBMS database program (i.e. MS Access,
SQL Server, MySQL)
• To use SQL to get the data you want
SOME BASIC
TERMS USED IN
SQL
Database
Schema
Table
Fields
RDBMS
KEEP IN MIND THAT...
• SQL keywords are NOT case sensitive.
EX.: select is same as SELECT.
• Some database systems require a semicolon at the end of each SQL
statement.
• Semicolon is the standard way to separate each SQL statement in
database systems that allow more than one SQL statement to be
executed in the same call to the server.
SQL COMMANDS
SQL
Commands
DDL
Create, Alter,
Drop, Truncate,
Rename
DML
Select, Insert,
Update,
Delete, Merge
DCL
Grant, Revoke
IMPORTANT SQL COMMANDS
•SELECT - extracts data from a database
•UPDATE - updates data in a database
•DELETE - deletes data from a database
•INSERT INTO - inserts new data into a database
•CREATE DATABASE - creates a new database
•ALTER DATABASE - modifies a database
•CREATE TABLE - creates a new table
•ALTER TABLE - modifies a table
•DROP TABLE - deletes a table
HOW TO BUILD A QUERY
1 • Select
2 • From
3 • Where
4 • Group by
5 • Having
CREATE TABLE MAYUR_UGALE.CORE
(
Employee_ID NUMBER(10) NOT
NULL,
Last_name CHAR(50),
First_name CHAR(50),
Address VARCHAR(100),
CONSTRAINT CORE_PK
PRIMARY KEY ( Employee_ID)
)
Schemma
Table name
Attributes/Fields
Data Types
SELECT Last_name,
First_name
FROM CORE
WHERE Employee_ID= 12345
FIELDS
Table name

SQL Overview.pptx

  • 1.
  • 2.
  • 3.
    INTRODUCTION • SQL letsyou access and manipulate databases • SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International Organization for Standardization (ISO) in 1987
  • 4.
    What Can SQLdo? • SQL can create new databases, schemas, Tables • SQL can insert, Update, Delete records in a database • SQL can execute queries against a database • SQL can retrieve data from a database
  • 5.
    REQUIREMENT FOR USESQL • An RDBMS database program (i.e. MS Access, SQL Server, MySQL) • To use SQL to get the data you want
  • 6.
    SOME BASIC TERMS USEDIN SQL Database Schema Table Fields RDBMS
  • 7.
    KEEP IN MINDTHAT... • SQL keywords are NOT case sensitive. EX.: select is same as SELECT. • Some database systems require a semicolon at the end of each SQL statement. • Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
  • 8.
    SQL COMMANDS SQL Commands DDL Create, Alter, Drop,Truncate, Rename DML Select, Insert, Update, Delete, Merge DCL Grant, Revoke
  • 9.
    IMPORTANT SQL COMMANDS •SELECT- extracts data from a database •UPDATE - updates data in a database •DELETE - deletes data from a database •INSERT INTO - inserts new data into a database •CREATE DATABASE - creates a new database •ALTER DATABASE - modifies a database •CREATE TABLE - creates a new table •ALTER TABLE - modifies a table •DROP TABLE - deletes a table
  • 10.
    HOW TO BUILDA QUERY 1 • Select 2 • From 3 • Where 4 • Group by 5 • Having
  • 11.
    CREATE TABLE MAYUR_UGALE.CORE ( Employee_IDNUMBER(10) NOT NULL, Last_name CHAR(50), First_name CHAR(50), Address VARCHAR(100), CONSTRAINT CORE_PK PRIMARY KEY ( Employee_ID) ) Schemma Table name Attributes/Fields Data Types
  • 12.
    SELECT Last_name, First_name FROM CORE WHEREEmployee_ID= 12345 FIELDS Table name