Вы находитесь на странице: 1из 7

Database Overview :Adv & Disadv & Diff between File & Database Management System.

FILE DISADVANTAGE :- Datasharing,accessing, inconsistency & redundant security p roblem Types of Database Systems : Types(IMS/IDMS/DB2) DB2 Adv.. Normalizations: 1st Normal Form 2nd Normal Form 3rd Normal Form 4th Normal Form Cond 12 Rules: 1. Information, 2. Guaranteed access, 3. Systematic use of null , 4. Active online catalog, 5. Comprehensive data sublanguage, 6. View updating, 7. High level insert, 8. update & delete, 9. Physical data Independence, 10. Logical data Independence, 11. Integrity Independence, 12. Distribution, Nonsubversion. Any dataase which has > = 6 rules then it will be called as a RDBMS. DB2 objects: 1. System objects 2. Recovery objects 3. Storage objects 4. Database (or data) objects Database objects Tables Base tables Result tables Materialized query tables Declared temporary tables Typed tables Indexes Views Schemas Qualifier Aliases Alias chain Trigger Subject table Trigger event Trigger activation time Set of affected rows Trigger granularity Triggered action User-defined data types User-defined functions Sequences CREATE TABLE Data type NOT NULL constraint

Default constraint Check constraint Unique constraint Referential integrity constraint Unique key Primary key Foreign key Parent key Parent table Parent row Dependent/child table Dependent/child row Descendant table Referential cycle Self-referencing table Self-referencing row ON UPDATE NO ACTION ON UPDATE RESTRICT ON DELETE CASCADE ON DELETE SET NULL ON DELETE NO ACTION ON DELETE RESTRICT Identity column CREATE VIEW WITH CHECK OPTION Authentication Authorities Privileges Object privileges Special registers VALUES External Stored Procedure SQL Stored Procedure CREATE PROCEDURE CALL Embedded SQL Host language Host application SQL precompiler Static SQL Dynamic SQL DB2 OBJECTS : DB2 Catalog : Storage Group, Databases, Table space, Tables, Index, Schemas, Triggers, Views, Synonyms, Alias SOME DB2 Terminology Primary key : Composite Key: Alternate Key:

Foreign Key : Entity Integrity : Referential Integrity : Domain Integrity : Related data : Related table : Protecting data : Constraints: NOT NULL constraints Default constraints Check constraints Unique constraints Referential integrity constraints The Insert Rule for Referential Constraints The Update Rule for Referential Constraints ON UPDATE NO ACTION ON UPDATE RESTRICT The Delete Rule for Referential Constraints ON DELETE CASCADE ON DELETE SET NULL. ON DELETE NO ACTION ON DELETE RESTRICT. A Word about Declared Temporary Tables Controlling Database Access Schema privileges (CREATEIN, ALTERIN, DROPIN) Table privileges (ALTER,SELECT, INSERT, UPDATE, DELETE, INDEX, REFERENCE) View privileges (SELECT, INSERT, UPDATE, DELETE) Package privileges(BIND, EXECUTE) Routine privileges(EXECUTE) How Privileges Are Granted (Implicitly, Indirectly, Explicitly) Locking. MOD(share/exclusive) SIZE(PAGE/TABLE)TIME isolation levels Concurrency Explain Names-Tables, Column s, Datatypes(Numeric/Char/Graphics/Date or Time/ User defined Stored Procedures : Calling a Stored Procedure Structured Query Language (SQL) Embedded SQL Static SQL Dynamic SQL Data Manipulation Data Control Language (DCL) Statements. SQL statements used to grant and revoke authorities and privileges. Data Definition Language (DDL) Statements. SQL statements used to create, alter, and delete database objects. Data Manipulation Language (DML) Statements. SQL statements used to store data i n and retrieve or remove data from database objects. Transaction Management Statements. SQL statements used to establish and terminat e active transactions.

INSERT UPDATE Cursor DELETE SELECT Query Subquery The DISTINCT Clause The FROM Clause The WHERE Clause Relational Predicates The BETWEEN Predicate The LIKE Predicate Wild Card Characters The IN Predicate The EXISTS Predicate The NULL Predicate The GROUP BY Clause GROUP BY ROLLUP GROUP BY CUBE The HAVING Clause The ORDER BY Clause The FETCH FIRST Clause Cartesian Product Joining Tables Inner Join Left Outer Join Right Outer Join Full outer join Combining Two or More Queries with a Set Operator The UNION Set Operator The UNION ALL Set Operator The EXCEPT Set Operator The EXCEPT ALL Set Operator The INTERSECT Set Operator The INTERSECT ALL Set Operator Using SQL Functions to Transform Data SUM(Column). Returns the sum of the values in the column specified. AVG(Column). Returns the sum of the values in the column specified divided by th e number of values found in that column (the average). MIN(Column). Returns the smallest value found in the column specified. MAX(Column). Returns the largest value found in the column specified. COUNT(Column). Returns the total number of non-null values found in the column s pecified. Scalar functions are ABS(Value). COALESCE(Expression, Expression, ). LENGTH( CharacterString ). LCASE( CharacterString ) or LOWER( CharacterString ). UCASE( CharacterString ) or UPPER( CharacterString ). DATE(Value CharacterString ). MONTH( DateValue ). DAY( DateValue ). YEAR( DateValue ). The built-in function SNAPSHOT_TABLE is an example of a table function.) Retrieving Results from a Result Data Set Using a Cursor DECLARE CURSOR OPEN

FETCH CLOSE Retrieving a Single Row of Data SELECT INTO VALUES INTO Transactions COMMIT ROLLBACK Transaction Management and Savepoints Embedded SQL Programming Structured Query Language (SQL) Embedded SQL EXEC SQL Static SQL Dynamic SQL Host variables Declare section BEGIN DECLARE SECTION END DECLARE SECTION Indicator variables SQL Communications Area (SQLCA) data structure SQL Descriptor Area (SQLDA) data structure SQLVAR variables Base SQLVARs Secondary SQLVARs INCLUDE CONNECT "Type 1" connections Remote unit of work "Type 2" connections Application-directed distributed unit of work Connection states SET CONNECTION PREPARE EXECUTE EXECUTE IMMEDIATE Parameter markers Typed parameter markers Untyped parameter markers Cursor SELECT INTO VALUES INTO DISCONNECT SQL return code WHENEVER Administrative APIs Get Error Message API Get SQLSTATE Message API SQL precompiler Package Precompiling Compiling Linking Binding Deferred binding

Declaring Host Variables Declaring Indicator Variables Declaring SQL Data Structure Variables Establishing a Database Connection Preparing and Executing SQL Statements Prepare and Execute. Execute Immediately. Retrieving and Processing Results Managing Transactions Diagnostics and Error Handling WHENEVER SQLERROR GOTO [Label]. WHENEVER SQLWARNING GOTO [Label]. WHENEVER NOT FOUND GOTO [Label]. WHENEVER [SQLERROR SQL WARNING NOT FOUND] CONTINUE. A Word about SQLSTATEs Creating Executable Applications Precompiling Source Code Files Compiling Source Code Files Linking Object Modules Creating and Binding Packages

CURSOR (Declare ,Open,Fetch, Close) Modify /Create database structure,adduser permissions Query a database for info,update the content of database DDL : CREATE, ALTER,DROP DML:SELECT, INSERT, UPDATE &DELETE DCL :Grant Revoke TCL : Commit,Rollback DQL :

Select all cols, all rows -----Select * from emp; Select some cols ----Select col1, col2 from emp; Select some rows-----Select * from emp where eno=1 Sort the query output------Select * from emp order by ED Remove Duplicates--------Select Distinct/Unique * from emp; Conditions----Arithematic Operaters ------ +, -, /, *, Mod(%) Comparision Operators------- > , < , <= , >= , <> or ! Char Operators------ LIKE, '-',% Logical Operators------ OR, AND, NOT Set Operators------UNION(Without duplicate), UNION ALL ,INTERSECT(With duplicat es) IN & BETWEEN : Group functions: Count (*),MIN, MAX, AVG, Select deptno,MIN(sal),MAX(sal),AVG(sal) from emp group by deptno; Select deptno,MIN(sal),MAX(sal), from emp group by deptno, having AVG(sal) < 500 0 How to count duplicate column values :Select ename, count (*) from emp group by ename having count (*) > 1. Select deptno,Job,count(*) from emp where dept no IN Group by deptno, Job having count(*) > 1

Order by count (*) DESC; JOINS : Cartessian Join (Arrows & Brows) Select Ano, Aname, Bno, Bname from A, B Inner Join (Equi): Select eno,emp.deptno, dept.deptno, dname from emp, dept wher e emp.deptno = dept. dept Full outer join :Select D.Dno, E. Eno from D FULL OUTER JOIN E on D. did = E .eid Left outer join select e.eno, e.deptno, d.dno from emp edept where e.dno = d. dno (+) Right outer Join : Select e.no, e.dno from empe.dept where e.dno(+) = d.d no SUBQUERY:Select eno,ename,edno from emp where sal = (select max(sal) from emp) inner query executes first, then result used for main query CORELATED SUBQUERY :- Outer query executes first,on the basis of result value in ner query gets executed. A list of all emps whose sal > AVG sal of their dept. Select * from emp e where e.sal > (Select avg(em.sal) from emp em where em.d eptno = e. deptno) List all emps who have atleast 1 person reporting to then select e.eno, e.ename fromemp e where exists (Select m.eno from emp where m.mgr = e.eno); Any ----- Select ename, sal from emp where sal >am (1600 ,2999) all

Вам также может понравиться