SlideShare a Scribd company logo
1 of 11
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
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
webhostingguy
 

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

POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
Cherry
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
MohamedFarag457087
 
COMPOSTING : types of compost, merits and demerits
COMPOSTING : types of compost, merits and demeritsCOMPOSTING : types of compost, merits and demerits
COMPOSTING : types of compost, merits and demerits
Cherry
 
ONLINE VOTING SYSTEM SE Project for vote
ONLINE VOTING SYSTEM SE Project for voteONLINE VOTING SYSTEM SE Project for vote
ONLINE VOTING SYSTEM SE Project for vote
RaunakRastogi4
 
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cherry
 
Lipids: types, structure and important functions.
Lipids: types, structure and important functions.Lipids: types, structure and important functions.
Lipids: types, structure and important functions.
Cherry
 

Recently uploaded (20)

POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
 
Cot curve, melting temperature, unique and repetitive DNA
Cot curve, melting temperature, unique and repetitive DNACot curve, melting temperature, unique and repetitive DNA
Cot curve, melting temperature, unique and repetitive DNA
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptx
 
Dr. E. Muralinath_ Blood indices_clinical aspects
Dr. E. Muralinath_ Blood indices_clinical  aspectsDr. E. Muralinath_ Blood indices_clinical  aspects
Dr. E. Muralinath_ Blood indices_clinical aspects
 
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate ProfessorThyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
 
Plasmid: types, structure and functions.
Plasmid: types, structure and functions.Plasmid: types, structure and functions.
Plasmid: types, structure and functions.
 
Terpineol and it's characterization pptx
Terpineol and it's characterization pptxTerpineol and it's characterization pptx
Terpineol and it's characterization pptx
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
 
Genome Projects : Human, Rice,Wheat,E coli and Arabidopsis.
Genome Projects : Human, Rice,Wheat,E coli and Arabidopsis.Genome Projects : Human, Rice,Wheat,E coli and Arabidopsis.
Genome Projects : Human, Rice,Wheat,E coli and Arabidopsis.
 
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
 
COMPOSTING : types of compost, merits and demerits
COMPOSTING : types of compost, merits and demeritsCOMPOSTING : types of compost, merits and demerits
COMPOSTING : types of compost, merits and demerits
 
ONLINE VOTING SYSTEM SE Project for vote
ONLINE VOTING SYSTEM SE Project for voteONLINE VOTING SYSTEM SE Project for vote
ONLINE VOTING SYSTEM SE Project for vote
 
X-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
X-rays from a Central “Exhaust Vent” of the Galactic Center ChimneyX-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
X-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
 
Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.
 
GBSN - Microbiology (Unit 5) Concept of isolation
GBSN - Microbiology (Unit 5) Concept of isolationGBSN - Microbiology (Unit 5) Concept of isolation
GBSN - Microbiology (Unit 5) Concept of isolation
 
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
 
Understanding Partial Differential Equations: Types and Solution Methods
Understanding Partial Differential Equations: Types and Solution MethodsUnderstanding Partial Differential Equations: Types and Solution Methods
Understanding Partial Differential Equations: Types and Solution Methods
 
Taphonomy and Quality of the Fossil Record
Taphonomy and Quality of the  Fossil RecordTaphonomy and Quality of the  Fossil Record
Taphonomy and Quality of the Fossil Record
 
Lipids: types, structure and important functions.
Lipids: types, structure and important functions.Lipids: types, structure and important functions.
Lipids: types, structure and important functions.
 

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