database foundation training
TRANSCRIPT
Database Foundation TrainingFeb. 2011
Database & DBMS
Insert, Update, Delete, Select
Create. Drop, Alter, Truncate
Categories of Database
Categories
Relational Database (RDBMS)
Microsoft SQL Server
Oracle
Sybase
IBM
Mysql
Flat File Database
Lotus Notes
Objects of Database
Objects
Database
Schema
Table
View
Synonym
Store Procedure
Function
Trigger
Table
Table
Column Name
Data Type
Data Length
Nullable
Default Value
Constraint (PK. FK)
Index
Index
Index
B-Tree Index
Bitmap Index
Hash Index
Reverse Index
...
ID Name Corporation Country
…. …. ….. ….
1258 Kong IBM CN
1259 Kong IBM CN
…. … … …
1335 ZhaoPing HP EN
Select * From Tab1Where Name=‘Kong’ And Corporation=‘IBM’ And Country=‘CN’
View
View
Views can represent a subset of the data contained in a table
Views can join and simplify multiple tables into a single virtual table
Views can act as aggregated tables, where the database engine aggregates data (sum, average etc) and presents the calculated results as part of the data
Views can hide the complexity of data; for example a view could appear as Sales2000 or Sales2001, transparently partitioning the actual underlying table
Views take very little space to store; the database contains only the definition of a view, not a copy of all the data it presents
Depending on the SQL engine used, views can provide extra security
Views can limit the degree of exposure of a table or tables to the outer world
Store Procedure & Function
Store Procedure
CREATE { PROC | PROCEDURE } [schema_name.] procedure_name [ ;number ] [ { @parameter [ type_schema_name. ] data_type } [ VARYING ] [ = default ] [ OUT | OUTPUT ] [READONLY] ] [ ,...n ] [ WITH <procedure_option> [ ,...n ] ] [ FOR REPLICATION ] AS { [ BEGIN ] sql_statement [;] [ ...n ] [ END ] } [;]
Function
CREATE FUNCTION [ schema_name. ] function_name( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type [ = default ] [ READONLY ] } [ ,...n ] ] ) RETURNS return_data_type [ WITH <function_option> [ ,...n ] ] [ AS ] BEGIN function_body RETURN scalar_expression END [ ; ]
Trigger
Trigger
{CREATE | RECREATE | CREATE OR ALTER} TRIGGER name
FOR {TABLE name | VIEW name}
[ACTIVE | INACTIVE]
{BEFORE | AFTER} {INSERT [OR UPDATE] [OR DELETE] | UPDATE [OR INSERT] [OR DELETE] | DELETE [OR UPDATE] [OR INSERT] }
[POSITION n]
AS BEGIN ..... END
Synonym
Synonym
Public Synonym
CREATE PUBLIC SYNONYM employees for hr.employees;
Private Synonym
CREATE SYNONYM addresses FOR hr.locations;
Transaction
Transaction
1. To provide reliable units of work that allow correct recovery from failures and keep a database consistent even in cases of system failure, when execution stops (completely or partially) and many operations upon a database remain uncompleted, with unclear status.
2. To provide isolation between programs accessing a database concurrently. Without isolation the program's outcomes are possibly erroneous.
How DML works
Oracle Client
3.1 Syntax Validation
3.2 Objects Validation
3.3 Objects Locks
3.4 Access Right of Objects Validation
3.5 Explain Plan
Sql Query Cache
Sql Query Cache
2/5
. SQ
L query +
Plan
2. SQL query
1. SQL query
Database
4. SQL query + Plan
6. SQL query + Plan
4.Exception
Database vs. Data Warehouse
OLTP (Online Transaction Processing)
OLAP (Online Analysis Processing)
Q & A
Questions?