SlideShare a Scribd company logo
Microsoft SQL server
Lecture : four
Lecturer :Ashna nazm hamasalh
ashnanazm2@gmail.com
Kirkuk institute for computer science
1
lecturer.Miss.Ashna Nazm Hamasalh
outline
Microsoft SQL SERVER
SQL Parts
DDL STATEMENTS
2
lecturer.Miss.Ashna Nazm Hamasalh
DDL STATEMENTS
• To create a Database
– Syntax : CREATE DATABASE dbname;
– Example: CREATE DATABASE my_db;
• To Use a database
– Syntax : Use dbname;
– Example: Use my_db;
3
lecturer.Miss.Ashna Nazm Hamasalh
Creating a table
• Syntax CREATE
TABLE table_name
(
column_name1
data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
PRIMARY
KEY(column_name1));
• Example
CREATE TABLE Persons
(
PersonID int
identity(1,1),
FirstName varchar(255),
Address varchar(255),
City varchar(255),
Primary key(PersonalID)
);
4
lecturer.Miss.Ashna Nazm Hamasalh
DDL - Altering a table
• ALTER TABLE Persons ADD email VARCHAR(60);
• ALTER TABLE Persons DROP COLUMN city;
• exec sp_rename 'Table_1.email','fullname','column';
• DDL - Deleting a Table
• DROP TABLE table_name ;
5
lecturer.Miss.Ashna Nazm Hamasalh
DML STATEMENTS
• DML - Insert Data into a table
• Syntax :
– INSERT INTO table_name VALUES
(value1,value2,value3,...);
• Example:
– INSERT INTO Customers (CustomerName, City, Country) VALUES (baabtra', ‘Calicut', ‘India');
Note : String and date values are specified as quoted string. Also with insert you can
insert NULL directly to represent a missing value.
6
lecturer.Miss.Ashna Nazm Hamasalh
• DML -Retrieving information from a table
•The SELECT statement is used to pull data from a table”
• Syntax: SELECT what_to_select FROM table_name Whereconditions_to_satisfy ;
The Where clause is
optional. If it is present,
conditions_to_satisfy
specifies one or more
conditions that rows must
satisfy to qualify for retrieval.
What_to_select indicates
what you want to see.
This can be a list of
columns or * to indicate
“all columns”.
7
lecturer.Miss.Ashna Nazm Hamasalh
DML - Example
• Select * from person;
• Select id,firstname from person;
• Select * from person where city=‘banglore’
8
lecturer.Miss.Ashna Nazm Hamasalh
• DML - Update Query
Syntax:
• UPDATE table_name
SET column1=value1,column2=value2,... WHERE
some_column=some_value;
Example:
• UPDATE Customers
SET ContactName=‘Alex', City=‘calicut‘ WHERE
CustomerName=‘baabtra';
9
lecturer.Miss.Ashna Nazm Hamasalh
• Delete Query
Syntax:
DELETE FROM table_name WHERE some_column=some_value;
Example :
DELETE FROM Customers WHERE CustomerName=‘baabtra' AND
ContactName='Maria';
10
lecturer.Miss.Ashna Nazm Hamasalh
11
lecturer.Miss.Ashna Nazm Hamasalh

More Related Content

Similar to SQL server management studio

xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
WrushabhShirsat3
 
lab#1,2,3.pptx
lab#1,2,3.pptxlab#1,2,3.pptx
lab#1,2,3.pptx
AkifaAbbas
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
Saeid Zebardast
 
Introduction to NoSQL CassandraDB
Introduction to NoSQL CassandraDBIntroduction to NoSQL CassandraDB
Introduction to NoSQL CassandraDB
Janos Geronimo
 
Mysql grand
Mysql grandMysql grand
Mysql grand
Siddique Ibrahim
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
enosislearningcom
 
1.2 sql create and drop table
1.2 sql create and drop table1.2 sql create and drop table
1.2 sql create and drop table
MLG College of Learning, Inc
 
SQL basics.pptx
SQL basics.pptxSQL basics.pptx
SQL basics.pptx
ZakReeceJames
 
SQL Queries - DDL Commands
SQL Queries - DDL CommandsSQL Queries - DDL Commands
SQL Queries - DDL Commands
ShubhamBauddh
 
Cassandra-Powered Distributed DNS
Cassandra-Powered Distributed DNSCassandra-Powered Distributed DNS
Cassandra-Powered Distributed DNS
David Timothy Strauss
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinhwebhostingguy
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
Prof. Dr. K. Adisesha
 
PostgreSQL - It's kind've a nifty database
PostgreSQL - It's kind've a nifty databasePostgreSQL - It's kind've a nifty database
PostgreSQL - It's kind've a nifty database
Barry Jones
 

Similar to SQL server management studio (20)

xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
 
lab#1,2,3.pptx
lab#1,2,3.pptxlab#1,2,3.pptx
lab#1,2,3.pptx
 
Introduction to mysql part 1
Introduction to mysql part 1Introduction to mysql part 1
Introduction to mysql part 1
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
 
My sql
My sqlMy sql
My sql
 
Introduction to NoSQL CassandraDB
Introduction to NoSQL CassandraDBIntroduction to NoSQL CassandraDB
Introduction to NoSQL CassandraDB
 
Mysql grand
Mysql grandMysql grand
Mysql grand
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 
1.2 sql create and drop table
1.2 sql create and drop table1.2 sql create and drop table
1.2 sql create and drop table
 
SQL basics.pptx
SQL basics.pptxSQL basics.pptx
SQL basics.pptx
 
SQL Queries - DDL Commands
SQL Queries - DDL CommandsSQL Queries - DDL Commands
SQL Queries - DDL Commands
 
Cassandra-Powered Distributed DNS
Cassandra-Powered Distributed DNSCassandra-Powered Distributed DNS
Cassandra-Powered Distributed DNS
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
 
SQL_NOTES.pdf
SQL_NOTES.pdfSQL_NOTES.pdf
SQL_NOTES.pdf
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
 
PostgreSQL - It's kind've a nifty database
PostgreSQL - It's kind've a nifty databasePostgreSQL - It's kind've a nifty database
PostgreSQL - It's kind've a nifty database
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 

Recently uploaded

plant biotechnology Lecture note ppt.pptx
plant biotechnology Lecture note ppt.pptxplant biotechnology Lecture note ppt.pptx
plant biotechnology Lecture note ppt.pptx
yusufzako14
 
Predicting property prices with machine learning algorithms.pdf
Predicting property prices with machine learning algorithms.pdfPredicting property prices with machine learning algorithms.pdf
Predicting property prices with machine learning algorithms.pdf
binhminhvu04
 
Structures and textures of metamorphic rocks
Structures and textures of metamorphic rocksStructures and textures of metamorphic rocks
Structures and textures of metamorphic rocks
kumarmathi863
 
general properties of oerganologametal.ppt
general properties of oerganologametal.pptgeneral properties of oerganologametal.ppt
general properties of oerganologametal.ppt
IqrimaNabilatulhusni
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
Scintica Instrumentation
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
ChetanK57
 
Penicillin...........................pptx
Penicillin...........................pptxPenicillin...........................pptx
Penicillin...........................pptx
Cherry
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
DiyaBiswas10
 
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Sérgio Sacani
 
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
Sérgio Sacani
 
EY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptxEY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptx
AlguinaldoKong
 
Lateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensiveLateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensive
silvermistyshot
 
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptxBody fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
muralinath2
 
Seminar of U.V. Spectroscopy by SAMIR PANDA
 Seminar of U.V. Spectroscopy by SAMIR PANDA Seminar of U.V. Spectroscopy by SAMIR PANDA
Seminar of U.V. Spectroscopy by SAMIR PANDA
SAMIR PANDA
 
insect morphology and physiology of insect
insect morphology and physiology of insectinsect morphology and physiology of insect
insect morphology and physiology of insect
anitaento25
 
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Sérgio Sacani
 
Hemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptxHemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptx
muralinath2
 
Anemia_ different types_causes_ conditions
Anemia_ different types_causes_ conditionsAnemia_ different types_causes_ conditions
Anemia_ different types_causes_ conditions
muralinath2
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
YOGESH DOGRA
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerin
ossaicprecious19
 

Recently uploaded (20)

plant biotechnology Lecture note ppt.pptx
plant biotechnology Lecture note ppt.pptxplant biotechnology Lecture note ppt.pptx
plant biotechnology Lecture note ppt.pptx
 
Predicting property prices with machine learning algorithms.pdf
Predicting property prices with machine learning algorithms.pdfPredicting property prices with machine learning algorithms.pdf
Predicting property prices with machine learning algorithms.pdf
 
Structures and textures of metamorphic rocks
Structures and textures of metamorphic rocksStructures and textures of metamorphic rocks
Structures and textures of metamorphic rocks
 
general properties of oerganologametal.ppt
general properties of oerganologametal.pptgeneral properties of oerganologametal.ppt
general properties of oerganologametal.ppt
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
 
Penicillin...........................pptx
Penicillin...........................pptxPenicillin...........................pptx
Penicillin...........................pptx
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
 
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
 
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
 
EY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptxEY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptx
 
Lateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensiveLateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensive
 
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptxBody fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
 
Seminar of U.V. Spectroscopy by SAMIR PANDA
 Seminar of U.V. Spectroscopy by SAMIR PANDA Seminar of U.V. Spectroscopy by SAMIR PANDA
Seminar of U.V. Spectroscopy by SAMIR PANDA
 
insect morphology and physiology of insect
insect morphology and physiology of insectinsect morphology and physiology of insect
insect morphology and physiology of insect
 
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...
 
Hemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptxHemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptx
 
Anemia_ different types_causes_ conditions
Anemia_ different types_causes_ conditionsAnemia_ different types_causes_ conditions
Anemia_ different types_causes_ conditions
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerin
 

SQL server management studio

  • 1. Microsoft SQL server Lecture : four Lecturer :Ashna nazm hamasalh ashnanazm2@gmail.com Kirkuk institute for computer science 1 lecturer.Miss.Ashna Nazm Hamasalh
  • 2. outline Microsoft SQL SERVER SQL Parts DDL STATEMENTS 2 lecturer.Miss.Ashna Nazm Hamasalh
  • 3. DDL STATEMENTS • To create a Database – Syntax : CREATE DATABASE dbname; – Example: CREATE DATABASE my_db; • To Use a database – Syntax : Use dbname; – Example: Use my_db; 3 lecturer.Miss.Ashna Nazm Hamasalh
  • 4. Creating a table • Syntax CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), column_name3 data_type(size), PRIMARY KEY(column_name1)); • Example CREATE TABLE Persons ( PersonID int identity(1,1), FirstName varchar(255), Address varchar(255), City varchar(255), Primary key(PersonalID) ); 4 lecturer.Miss.Ashna Nazm Hamasalh
  • 5. DDL - Altering a table • ALTER TABLE Persons ADD email VARCHAR(60); • ALTER TABLE Persons DROP COLUMN city; • exec sp_rename 'Table_1.email','fullname','column'; • DDL - Deleting a Table • DROP TABLE table_name ; 5 lecturer.Miss.Ashna Nazm Hamasalh
  • 6. DML STATEMENTS • DML - Insert Data into a table • Syntax : – INSERT INTO table_name VALUES (value1,value2,value3,...); • Example: – INSERT INTO Customers (CustomerName, City, Country) VALUES (baabtra', ‘Calicut', ‘India'); Note : String and date values are specified as quoted string. Also with insert you can insert NULL directly to represent a missing value. 6 lecturer.Miss.Ashna Nazm Hamasalh
  • 7. • DML -Retrieving information from a table •The SELECT statement is used to pull data from a table” • Syntax: SELECT what_to_select FROM table_name Whereconditions_to_satisfy ; The Where clause is optional. If it is present, conditions_to_satisfy specifies one or more conditions that rows must satisfy to qualify for retrieval. What_to_select indicates what you want to see. This can be a list of columns or * to indicate “all columns”. 7 lecturer.Miss.Ashna Nazm Hamasalh
  • 8. DML - Example • Select * from person; • Select id,firstname from person; • Select * from person where city=‘banglore’ 8 lecturer.Miss.Ashna Nazm Hamasalh
  • 9. • DML - Update Query Syntax: • UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value; Example: • UPDATE Customers SET ContactName=‘Alex', City=‘calicut‘ WHERE CustomerName=‘baabtra'; 9 lecturer.Miss.Ashna Nazm Hamasalh
  • 10. • Delete Query Syntax: DELETE FROM table_name WHERE some_column=some_value; Example : DELETE FROM Customers WHERE CustomerName=‘baabtra' AND ContactName='Maria'; 10 lecturer.Miss.Ashna Nazm Hamasalh