microsoft sql…
DULAN WIJENAYAKA, esoft metro campus kandy , HND computing batch 61
What is SQL ?
SQL stands for structured query language
SQL lets you acesss and manipulate database
SQL is an ANSI (American national standards institute) standard
What can SQL do?
SQL can execute queries against a database
SQL can retrieve from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new database
SQL can create new table in a database
SQL can create stored procedures In a database
SQL can create views in a database
SQL can set permissions on tables, procedures, and
views
Most important SQL commands…
SELECT…………………………..
UPDATE…………………………
DELETE………………………….
INSERT INTO………………….
CREATE DATABASE………..
ALTER DATABASE…………..
CREATE DATABASE…………
CREATE TABLE………………..
ALTER TABLE…………………..
DROP TABLE……………………
CREATE INDEX…………………
DROP INDEX……………………
The SQL CREATE DATABASE statements…
The CREATE DATABASE statement is used to create a database
SQL CREATE DATABASE syntax
CREATE DATABASE dbname,
Ex-
CREATE DATABASE school
SQL CREATE TABLES Syntax…
Ex-
CREATE TABLE student
(
St_id int,
St_name varchar(255),
Address varchar(255),
Mobile no(255),
Grade (255),
);
SQI CHECK on CREATE TABLE
INSERT INTO Statement………………….
SQL CHECK on ALTER TABLE………………
ALTER TABLE Pearsons
ADD CHECK (AGE >18)
AUTO INCREMENT FIELD…………………..
CREATE TABLE Persons(
ID int IDENTITY(1,1) PRIMARY KEY
Last Name varchar(255) NOT NULL,
First Name varchar(255),
Ageint
);
SQL CREATE VIEW STATEMENTS……………..
CREATE VIEW Syntax
CREATE VIEW view_name As
SELECT colum1,colum2…..
FROM table _name
WHERE condition;
The SQL SELECT statement……….
SELECT *FROM table _name,
SELECT Customer Name,City FROM Customers;
SQL WHERE Clause…….
SELECT colum1,colum2…
FROM table_name
WHERE condition,
TEXT:
SELECT* FROM Customers
WHERE Country = Mexico;
Number
SELECT*FROM Customers
WHERE Customer ID =1:
SQL Aggregate Functions………….
AVG
COUNT
MAX
MIN
SUM
SQL udate statement
UPDATE table name,
SET colum1=value1,value2=value2,…
WHERE condition
SQL DELETE statement
DELETE FROM table name
WHERE condition
Different types of SQL JOINS……………………
(INNER) JOIN-returns records that have matching
values in both tables
LEFT (OUTER) JOIN-return all records from the left
table and the matched records from the right table
RIGHT (OUTER) JOIN-return all records from the right
table and the matched records from the left table
FULL (OUTER) JOIN-return all records when there is a
match in either left or right table