SlideShare a Scribd company logo
DATABASE BASIC
MD.WALIUZZAMAN
1.DATABASE CREATE:
CREATE DATABASE mydb
mydb
2.DATABASE RENAME:
ALTER DATABASE mydb MODIFY NAME= mynewdb
mynewdb
Method:1
Method:2
Sp_renameDB ‘mynewdb’ , ‘mydb’
mydb
3.DROP DATABASE
DROP DATABSAE mydb
mydb
4.CREATE TABLE
CREATE TABLE mytable
(
id int primary key ,
name nvarchar(50) not null,
age int(20)
)
NEED: TABLE NAME, COLOMN NAME ,DATA TYPE+SIZE.
OPTIONAL:CONSTRAINTS(such as primary key, check constraints)
mytable
VIEW TABLE PROPERTY
EXEC sp_help mytable
5.INSERT DATA IN TABLE
INSERT INTO mytable
VALUES ( 1,`wali`,25)
Method:1(single row insert)
Method:2(multirow insert)
INSERT INTO mytable
(id,name,age )
VALUES ( 1,`wali`,25), ( 2,`akash`,26);
6.UPDATE DATA IN TABLE
UPDATE mytable
SET name =‘batash’ ,age=25
WHERE id=2;
7.DELETE DATA IN TABLE
DELETE mytable WHERE id=1;
Delete select value:
Delete all value:
DELETE FROM mytable
Delete full table:
DROP TABLE mytable
8.BASIC SELECT STATETMENT
SELECT * FROM mytable;
Show all values in table:
Show selected one column values:
SELECT age FROM mytable;
Show selected multiple column values:
SELECT age,name FROM mytable;
9.SELECT STATEMENT
SELECT DISTINCT
name FROM mytable
(USING DISTINCT)
10.SELECT STATEMENT
For using WHERE Clause
at first we need to know about
WHERE Clause operators
(USING WHERE Clause)
WHERE Clause OPERATORS
=, >, <, >=, <=, <>, !=, !>, !<
AND,OR,NOT
BETWEEN
LIKE
IN
ALL,ANY,SOME
EXISTS
11.SELECT STATEMENT
SELECT * FROM mytable WHERE age = 25
SELECT * FROM mytable WHERE age != 25
SELECT * FROM mytable WHERE age = 25 AND name = ‘wali’
SELECT * FROM mytable WHERE age = 25 OR name = ‘wali’
SELECT * FROM mytable WHERE name LIKE ‘w%’
SELECT * FROM mytable WHERE name LIKE ‘%wa%’
SELECT * FROM mytable WHERE name NOT LIKE ‘%wa%’
SELECT * FROM mytable WHERE name = ‘aksh’ OR name = ‘wali’
SELECT * FROM mytable WHERE name IN (‘aksh’,‘wali’)
SELECT * FROM mytable WHERE EXISTS (SELECT id FROM
mytable2 WHERE fee>500)
(USING WHERE Clause)
12.SELECT STATEMENT
SELECT * FROM mytable ORDER BY
age DESC
(USING ORDER BY Clause)part-1
SHOW ALL VALUES:
SELECT * FROM mytable ORDER BY
age ASC
ASC=ascending;
DESC=descending
Note:
13.SELECT STATEMENT
SELECT name FROM mytable ORDER
BY name DESC
(USING ORDER BY Clause)part-2
SHOW SELECTED COLUMN VALUES:
SELECT name FROM mytable ORDER
BY age ASC
ASC=ascending;
DESC=descending
Note:
14.SELECT STATEMENT
Creating Groups of data
15.SELECT STATEMENT
AGGREGATE MEANS
SUM(numeric)
AVG(numeric)
MIN/MAX(int,datetime,varchar,..)
COUNT(*)-return number of rows
AGGREGATE (USING GROUP BY Clause)
16.SELECT STATEMENT
AGGREGATE (USING GROUP BY Clause)
SELECT id ,SUM(salary) FROM mytable
GROUP BY id
17.SELECT STATEMENT
SELECT id ,SUM(salary) as totalsalary
FROM mytable GROUP BY id
AGGREGATE (USING GROUP BY Clause)
18.SELECT STATEMENT
SELECT id ,SUM(salary) as totalsalary,
AVG(salary) as aversalary FROM mytable
GROUP BY id
AGGREGATE (USING GROUP BY Clause)
19.SELECT STATEMENT
SELECT COUNT(*) FROM mytable
AGGREGATE (USING GROUP BY Clause)
20.SELECT STATEMENT
(USING JOIN Clause)
JOIN
INNER JOIN OUTER JOIN FULL JOIN CROSS JOIN
LEFT JOIN RIGHT JOIN
21.SELECT STATEMENT
At first we need two table
(USING JOIN Clause)
22.SELECT STATEMENT
Simple basic command:
(USING JOIN Clause)
SHOW ALL VALUES FROM BOTH TABLE
INNER JOIN
SELECT * FROM student INNER JOIN
guardian
On student.studentid=guardian. guardianid
23.SELECT STATEMENT
Here is output:
(USING JOIN Clause)
Before joining
After joining
24.SELECT STATEMENT
advance command:
(USING JOIN Clause)
SHOW selected column VALUES FROM BOTH TABLE
INNER JOIN
25.SELECT STATEMENT
INNER JOIN
(USING JOIN Clause)
SELECT s.studentid as ‘id student table’,
g.studentid as ‘id guardian table’,
s.name,g.fathername,g.mothername
FROM student s INNER JOIN guardian g
On s.studentid=g.studentid
s=student table
g=guardian table
26.SELECT STATEMENT
(USING JOIN Clause)
Before joining
After INNER joining
27.SELECT STATEMENT
BASIC
(USING JOIN Clause)
OUTER JOIN
LEFT RIGHT
COLUMN COLUMN
RIGHT
JOIN
LEFT
JOIN
27.SELECT STATEMENT
advance command:
(USING JOIN Clause)
SHOW selected column VALUES FROM BOTH TABLE
OUTER JOIN
(LEFT JOIN)
28.SELECT STATEMENT
OUTER JOIN –(LEFT JOIN)
(USING JOIN Clause)
SELECT s.studentid as ‘id student table’,
g.studentid as ‘id guardian table’,
s.name,g.fathername,g.mothername
FROM student s LEFT JOIN guardian b
On s.studentid=g.studentid
s=student table
g=guardian table
29.SELECT STATEMENT
(USING JOIN Clause)
Before joining
After LEFT joining
30.SELECT STATEMENT
advance command:
(USING JOIN Clause)
SHOW selected column VALUES FROM BOTH TABLE
OUTER JOIN
(RIGHT JOIN)
31.SELECT STATEMENT
OUTER JOIN –(RIGHT JOIN)
(USING JOIN Clause)
SELECT s.studentid as ‘id student table’,
g.studentid as ‘id guardian table’,
s.name,g.fathername,g.mothername
FROM student s RIGHT JOIN guardian b
On s.studentid=g.studentid
s=student table
g=guardian table
32.SELECT STATEMENT
(USING JOIN Clause)
Before joining
After RIGHT joining
33.SELECT STATEMENT
(USING JOIN Clause)
FULL JOIN
34.SELECT STATEMENT
FULL JOIN
(USING JOIN Clause)
SELECT s.studentid as ‘id student table’,
g.studentid as ‘id guardian table’,
s.name,g.fathername,g.mothername
FROM student s FULL JOIN guardian b
On s.studentid=g.studentid
s=student table
g=guardian table
35.SELECT STATEMENT
(USING JOIN Clause)
Before joining
After FULL joining
33.SELECT STATEMENT
(USING JOIN Clause)
CROSS JOIN
To be continue..............
FLASH BACK
1.DATABASE— create,rename,delete
2.TABLE— CREATE, data INSERT+UPDATE ,
data+table DELETE
FLASH BACK
a.basic select statement
b. select statement—(using distinct)
c.(using where clause)+where clause operators
d.order by clause(asc,desc)
e.group by clause(aggregate—sum,min/max,avg,count)
f.join—inner,outer(left+right),full join,
3.SELECT STATEMENT:
33.SELECT STATEMENT
(USING JOIN Clause)
CROSS JOIN
33.SELECT STATEMENT
(USING JOIN Clause)
CROSS JOIN
Wali
Akash
Reza
Foyel
Murad
Haider
diit
horizone
33.SELECT STATEMENT
(USING JOIN Clause)
CROSS JOIN
diit_table horizone_table
33.SELECT STATEMENT
(USING JOIN Clause)
CROSS JOIN
SELECT
diit_student_name,
horizon_student_name
FROM diit_table
CROSS JOIN
horizon_table
33.SELECT STATEMENT
(USING JOIN Clause) CROSS JOIN
diit_table horizone_table
BEFORE
JOINING
After CROSS JOINING

More Related Content

What's hot (18)

PPTX
PostgreSQL's Secret NoSQL Superpowers
Amanda Gilmore
 
PPTX
Avinash database
avibmas
 
PDF
SXML: S-expression eXtensible Markup Language
elliando dias
 
PDF
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
PPTX
DDL(Data defination Language ) Using Oracle
Farhan Aslam
 
PPT
My sql presentation
Nikhil Jain
 
KEY
Zf Zend Db by aida
waraiotoko
 
PDF
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
PPTX
Introduction to SQL (for Chicago Booth MBA technology club)
Jennifer Berk
 
PPTX
Sql Basics And Advanced
rainynovember12
 
PPTX
SQL Commands
Sachidananda M H
 
DOC
A must Sql notes for beginners
Ram Sagar Mourya
 
PPTX
Introduction to SQL
Amin Choroomi
 
PPTX
Introduction to (sql)
Dattatray Ghorpade
 
PPTX
Lab2 ddl commands
Balqees Al.Mubarak
 
PPT
MySQL
Gouthaman V
 
PPT
Introduction to-sql
BG Java EE Course
 
PostgreSQL's Secret NoSQL Superpowers
Amanda Gilmore
 
Avinash database
avibmas
 
SXML: S-expression eXtensible Markup Language
elliando dias
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
DDL(Data defination Language ) Using Oracle
Farhan Aslam
 
My sql presentation
Nikhil Jain
 
Zf Zend Db by aida
waraiotoko
 
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
Introduction to SQL (for Chicago Booth MBA technology club)
Jennifer Berk
 
Sql Basics And Advanced
rainynovember12
 
SQL Commands
Sachidananda M H
 
A must Sql notes for beginners
Ram Sagar Mourya
 
Introduction to SQL
Amin Choroomi
 
Introduction to (sql)
Dattatray Ghorpade
 
Lab2 ddl commands
Balqees Al.Mubarak
 
Introduction to-sql
BG Java EE Course
 

Viewers also liked (10)

PPTX
basic database concepts
IIUI
 
PPTX
Database management system basic, database, database management, learn databa...
University of Science and Technology Chitttagong
 
PPTX
RDBMS.ppt
Ketan Chaoji
 
PPTX
Rdbms
rdbms
 
PPT
Types dbms
Avnish Shaw
 
PPTX
Types of databases
PAQUIAAIZEL
 
PPTX
Introduction to database
Pongsakorn U-chupala
 
PPT
Basic DBMS ppt
dangwalrajendra888
 
PPTX
Dbms slides
rahulrathore725
 
basic database concepts
IIUI
 
Database management system basic, database, database management, learn databa...
University of Science and Technology Chitttagong
 
RDBMS.ppt
Ketan Chaoji
 
Rdbms
rdbms
 
Types dbms
Avnish Shaw
 
Types of databases
PAQUIAAIZEL
 
Introduction to database
Pongsakorn U-chupala
 
Basic DBMS ppt
dangwalrajendra888
 
Dbms slides
rahulrathore725
 
Ad

Similar to MS SQL Database basic (20)

DOCX
Ddl commands
Vasudeva Rao
 
PPTX
SQL Data Manipulation language and DQL commands
sonali sonavane
 
DOCX
Farheen abdul hameed ip project (MY SQL);
abdul talha
 
PPT
MY SQL
sundar
 
PDF
dbms.pdf
walter brand
 
PDF
SQL on Linux and its uses and application.pdf
bhaveshsethi456
 
PPT
Mysql 120831075600-phpapp01
sagaroceanic11
 
PPTX
DBMS - Presentationhgfhfhfghfghfhfgh.pptx
SajidHossainKhan1
 
ODT
Sql Tags
Sutharsan nagarajan
 
PDF
Sql server query collection
Rabin Koirala
 
PDF
Mysql quick guide
Sundaralingam Puvikanth
 
PDF
T sql denali code Day of .Net
KathiK58
 
DOCX
Bibashsql
Bkas CrEsta
 
PPTX
Database Management - Lecture 2 - SQL select, insert, update and delete
Al-Mamun Sarkar
 
PPTX
DBMS: Week 06 - SQL - Data Manipulation Language (DML)
RashidFaridChishti
 
PPTX
Creating database using sql commands
Belle Wx
 
PPTX
DOODB_LAB.pptx
FilestreamFilestream
 
PDF
MySQL 8.0 NF : Common Table Expressions (CTE)
I Goo Lee
 
PPT
Tables And SQL basics
Amit Kumar Singh
 
Ddl commands
Vasudeva Rao
 
SQL Data Manipulation language and DQL commands
sonali sonavane
 
Farheen abdul hameed ip project (MY SQL);
abdul talha
 
MY SQL
sundar
 
dbms.pdf
walter brand
 
SQL on Linux and its uses and application.pdf
bhaveshsethi456
 
Mysql 120831075600-phpapp01
sagaroceanic11
 
DBMS - Presentationhgfhfhfghfghfhfgh.pptx
SajidHossainKhan1
 
Sql server query collection
Rabin Koirala
 
Mysql quick guide
Sundaralingam Puvikanth
 
T sql denali code Day of .Net
KathiK58
 
Bibashsql
Bkas CrEsta
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Al-Mamun Sarkar
 
DBMS: Week 06 - SQL - Data Manipulation Language (DML)
RashidFaridChishti
 
Creating database using sql commands
Belle Wx
 
DOODB_LAB.pptx
FilestreamFilestream
 
MySQL 8.0 NF : Common Table Expressions (CTE)
I Goo Lee
 
Tables And SQL basics
Amit Kumar Singh
 
Ad

Recently uploaded (20)

PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PDF
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Difference between write and update in odoo 18
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Horarios de distribución de agua en julio
pegazohn1978
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
Introduction presentation of the patentbutler tool
MIPLM
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 

MS SQL Database basic