Download Mobule 7 - Enhanced SQL

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

DBase wikipedia , lookup

Tandem Computers wikipedia , lookup

Oracle Database wikipedia , lookup

Microsoft Access wikipedia , lookup

Functional Database Model wikipedia , lookup

Database wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Ingres (database) wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Relational algebra wikipedia , lookup

Null (SQL) wikipedia , lookup

Clusterpoint wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Join (SQL) wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

SQL wikipedia , lookup

PL/SQL wikipedia , lookup

Transcript
Module 7 – Extended SQL
Content:
As we began looking at SQL last week - with our CREATE TABLE, SELECT, INSERT INTO,
DELETE FROM, etc. SQL commands, we only touched on the basic SQL commands. This
module looks at additional SQL commands that let you look at searching more than one table for
to get the information you need. You are actually comparing the table data in your JOIN
statements (there are several different types) and other similar statements.
A JOIN statement is a relational operation that causes two tables with a common domain
(column) to be combined into a single table.
An EQUI-JOIN stastement is a join in which the joining condition is based on equality between
values in the common columns. Common columns appear redundantly in the result table.
A NATURAL-JOIN is the same as an equi-join except on eof the duplicate columns is
eliminated in the result table.
An OUTER JOIN is a join in which rows that do not have matching value sin common columns
are neverless included in the result table.
A sub-query is actually a SELECT query embedded in another SELECT query as part of the
WHERE or FROM statement. For example for the WHERE:
SELECT CUSTOMER_NAME, CUSTOMER_ADDRESS, CUSTOMER_CITY,
CUSTOMER_STATE, POSTAL_CODE
FROM CUSTOMER
WHERE CUSTOMER.CUSTOMER_ID = (SELECT
ORDER.CUSTOMER_ID FROM ORDER WHERE ORDER_ID = 1008);
An example from the FROM:
SELECT PRODUCT_DESCRIPTION, STANDARAD_PRICE, AVGPRICE
FROM
(SELECT AVG(STANDARD_PRICE), AVGPRICE FROM
PRODUCT),
PRODUCT
WHERE STANDARD_PRICE > AVGPRICE;
-----------------------------Some of the data dictionary tables that come with a relational database are:
DBA_TABLES (describes all tables in the database)
DBA_TAB_COMMENTS (comments on all tables in the database)
DBA_TAB_COLUMNS (describes columns of all tables, views, and clusters)
DBA_USERS (information about all users of the database)
DBA_SYS_PRIVS (describes system privileges granted to users and to roles
there are several other system tables - but these are a few. This allows you to see more
information about the database itself as a whole and those who use it.
-----------------------------------SQL:200n
The newer versions of SQL have added some new built in functions:
CEILING (computes the least integer greater than or equal to its argument)
FLOOR (computes the greatest integer less than or equal to its argument)
SQRT (computes the square root of its argument - SQRT(36))
Some new data types include:
BIGINT
MULTISET
XML
Some new statements are:
CREATE TABLE LIKE
MERGE
A trigger is used as an SQL statement that can occur before, afater or instead of an SQL
statement.
CREATE TRIGGER trigger_name
{BEFORE|AFTER|INSTEAD OF} {INSERT|DELETE|UPDATE} ON
table-name
[FOR EACH {ROW|STATEMENT}] [WHEN (search condition)]
<triggered SQL statement here>;
Example:
CREATE TRIGGER STANDARD_PRICE_UPDATE
AFTER UPDATE OF STANDARD_PRICE ON PRODUCT
FOR EACH ROW
INSERT INTO PRICE_UPDATES VALUES (PRODUCT_DESCRIPTION, SYSDATE,
STANDARD_PRICE);
The newest versions of PL/SQL (procedures language/SQL) actually includes statements that are
like normal programming)
You can have functions and procedures as part of your SQL statements.
SQL has become a powerful language that can be used just like a regular programming language
in handling your database data.
Links:
https://www.youtube.com/watch?v=KTvYHEntvn8
https://www.youtube.com/watch?v=KTvYHEntvn8