100% found this document useful (1 vote)
281 views49 pages

Practical Lab Session: SQL-server Manual

SQL is a standard language for accessing and manipulating databases that allows users to execute queries to retrieve, insert, update and delete data. It works with many database programs. A database contains tables that hold records with data organized into columns. Queries using SQL can select specific columns from a table. When data is split across multiple tables, joins allow combining results by relating tables through primary keys which uniquely identify each row.

Uploaded by

Abel Mulatu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
281 views49 pages

Practical Lab Session: SQL-server Manual

SQL is a standard language for accessing and manipulating databases that allows users to execute queries to retrieve, insert, update and delete data. It works with many database programs. A database contains tables that hold records with data organized into columns. Queries using SQL can select specific columns from a table. When data is split across multiple tables, joins allow combining results by relating tables through primary keys which uniquely identify each row.

Uploaded by

Abel Mulatu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Practical lab session

SQL- server manual


What is SQL?
• SQL stands for Structured Query Language
• SQL allows you to access a database
• SQL is an ANSI standard computer language
• SQL can execute queries against a database
• SQL can retrieve data from a database
• SQL can insert new records in a database
• SQL can delete records from a database
• SQL can update records in a database
• SQL is easy to learn.
Con’d
• SQL is an ANSI (American National Standards Institute)
standard computer language for accessing and manipulating
database systems.
• SQL statements are used to retrieve and update data in a
database. SQL works with database programs like MS Access,
DB2, Informix, MS SQL Server, Oracle, Sybase, etc.

Create a Database
CREATE DATABASE database_name
Create a Database
To create a database:
To create a database:

CREATE DATABASE database_name


SQL Database Tables
• A database most often contains one or more tables. Each table
is identified by a name (e.g. "Customers" or "Orders"). Tables
contain records (rows) with data. Below is an example of a
table called "Persons":

LastName FirstName Address City

Hansen Ola Timoteivn 10 Sandnes

Svendson Tove Borgvn 23 Sandnes

Pettersen Kari Storgt 20 Stavanger


SQL Database Tables
• A database most often contains one or more tables. Each table
is identified by a name (e.g. "Customers" or "Orders"). Tables
contain records (rows) with data. Below is an example of a
table called "Persons":

LastName FirstName Address City

Hansen Ola Timoteivn 10 Sandnes

Svendson Tove Borgvn 23 Sandnes

Pettersen Kari Storgt 20 Stavanger


Con’d
• The table above contains three records (one for each person)
and four columns (LastName, FirstName, Address, and City).
SQL Queries
With SQL, we can query a database and have a result set returned.
A query like this:

SELECT LastName FROM Persons


Joins and Keys
• Sometimes we have to select data from two or
more tables to make our result complete. We
have to perform a join.
• Tables in a database can be related to each
other with keys. A primary key is a column with
a unique value for each row.
• Each primary key value must be unique within
the table. The purpose is to bind data together,
across tables, without repeating all of the data
in every table.
Joins and Keys
• Sometimes we have to select data from two or
more tables to make our result complete. We
have to perform a join.
• Tables in a database can be related to each
other with keys. A primary key is a column with
a unique value for each row.
• Each primary key value must be unique within
the table. The purpose is to bind data together,
across tables, without repeating all of the data
in every table.
Joins and Keys
• Sometimes we have to select data from two or
more tables to make our result complete. We
have to perform a join.
• Tables in a database can be related to each
other with keys. A primary key is a column with
a unique value for each row.
• Each primary key value must be unique within
the table. The purpose is to bind data together,
across tables, without repeating all of the data
in every table.
Joins and Keys
• Sometimes we have to select data from two or
more tables to make our result complete. We
have to perform a join.
• Tables in a database can be related to each
other with keys. A primary key is a column with
a unique value for each row.
• Each primary key value must be unique within
the table. The purpose is to bind data together,
across tables, without repeating all of the data
in every table.
The End of To day Class

You might also like