Download SQL - WorkForceInfoDB

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Microsoft Access wikipedia , lookup

Oracle Database wikipedia , lookup

Concurrency control wikipedia , lookup

Ingres (database) wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Database wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Functional Database Model wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Clusterpoint wikipedia , lookup

SQL wikipedia , lookup

Relational model wikipedia , lookup

PL/SQL wikipedia , lookup

Database model wikipedia , lookup

Transcript
SQL
Basic
What is SQL?
SQL (pronounced "ess-que-el")
stands for Structured Query
Language. SQL is used to
communicate with a database.
What can you do with SQL?
SQL enables you to select, insert, modify, and
delete the information in a database; perform
system security functions and set user
permission on tables and databases; handle
online transaction processing within an
application, create store procedures and
triggers to reduce application coding; and
transfer data between different databases.
SQL Data Manipulation
Language (DML)
SQL (Structured Query Language) is a syntax
for executing queries.
 SELECT - extracts data from a database
table
 UPDATE - updates data in a database table
 DELETE - deletes data from a database table
 INSERT INTO - inserts new data into a
database table
Selecting Data
The select statement is used to query the
database and retrieve selected data that
match the criteria that you specify. Here is the
format of a simple select statement:
select "column1"
[,"column2",etc] from
"tablename" [where "condition"];
[ ] = optional
Inserting data into a Table
The insert statement is used to insert or add a
row of data into the table.
insert into "tablename"
(first_column,...last_column) values
(first_value,...last_value);
Updating Records
The update statement is used to update or
change records that match a specified
criteria. This is accomplished by carefully
constructing a where clause.
update "tablename”
set "columnname" =
"newvalue" [,"nextcolumn" = "newvalue2"...]
where "columnname"
OPERATOR "value" [and| or "column"
OPERATOR "value"];
Deleting Records
The delete statement is used to delete records
or rows from the table.
delete from "tablename"
where "columnname"
OPERATOR "value" [and|or "column"
OPERATOR "value"];
Will this statement work?
Select *
The FROM clause is missing
Select * from [tablename]
If amount name payee are column names
from tables check would this statement
work
Select amount name payee from checks
Select amount, name, payee from checks
You need to have comma between each
column name.
What is wrong with the
following statement?
Delete collection,
Delete from collections;
Is this correct
Delete * from collections
Delete * from Collection
No the * is not needed
Let’s take a quiz!!!!!
Answer to Quiz
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Structured Query Language
Select
Update
Delete
Insert
Select Firstname from Persons
Select * from Persons
Select * from persons where firstname = “peter
Select * from persons where firstname like ‘a%’
Update persons set lastname = ‘nilsen’ where
lastname = ‘hansen’
Congratulations! You have
just learned Basic SQL
statements.