Você está na página 1de 12

Writing SQL Queries in

a Database

...
What is SQL?
Structured Query Language
Communicate
access and manipulate
ANSI (American National Standards
Institute
standard language for relational database
management systems (RDBMS)
What can SQL do?
execute queries against a database
retrieve data from a database
Insert, Update and Delete records in a
database
create new databases and tables
Database
collection of information that is organized
so that it can be easily accessed, managed
and updated
...
SQL Syntax
A grammatical rules for programming language
followed by a unique set of rules and guidelines
called Syntax
SQL Syntax Commands
SELECT extracts data from a database

UPDATE updates data into the database

DELETE - delete data into the database

INSERT INTO - inserts new data into a database

CREATE DATABASE - creates a new database

ALTER DATABASE - modifies a database


SQL Syntax Commands
CREATE TABLE - creates a new table

ALTER TABLE - modifies a table

DROP TABLE - deletes a table

CREATE INDEX - creates an index (search


key)
DROP INDEX - deletes an index
Basic SELECT Statement
Is used to retrieve records from one or
more table.

SELECT a command to retrieve information


FROM command to identify where the
information to gather will
WHERE command to cater the condition to be
used.
Sample codes

Run SQL

SELECT CustomerName,
City FROM Customers;
Run SQL
SELECT * FROM Customers
WHERE Country='Mexico;
Ctrl+Enter

SELECT * FROM Customers


WHERE CustomerID=1;
Run SQL
Self-check
1. Retrieve the information from column
COMPUTER inside the table EQUIPMENT
2. Retrieve all the information from the table
TOOLS
3. Retrieve the information from column LAND
inside the table VEHICLE
4. Retrieve all information from table
ELECTRONICS
Evaluation
Remove all the information of
CostumerID=1 from Costumers.

Change the City of Juan from Sweden.

1. Delete * from costumers where CostumerId=1;


2. Update costumer set contactname = juan where city =
sweden

Você também pode gostar