sql basic. what is sql? sql (pronounced "ess-que-el") stands for structured query...
TRANSCRIPT
SQLSQL
BasicBasic
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 Quiz1. Structured Query Language2. Select3. Update4. Delete5. Insert6. Select Firstname from Persons7. Select * from Persons8. Select * from persons where firstname = “peter9. Select * from persons where firstname like ‘a%’10. Update persons set lastname = ‘nilsen’ where
lastname = ‘hansen’
Congratulations! You have just learned Basic SQL statements.