RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

Size: px
Start display at page:

Download "RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague"

Transcription

1 course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

2 Triggers Triggers Overview Creating triggers Using Triggers Set operators UNION [ALL], INTERSECT, EXCEPT WITH SELECT Statements CASE Expressions M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 2

3

4 Active database = a database that can respond to conditions both inside and outside the database. Possible uses Security monitoring, Alerting, Statistics gathering, Authorization ECA rules (Event Condition Action) Triggers M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 4

5 Trigger = Special type of stored procedure Activated automatically according to events if predefined condition is met on the server Data modification (described later) Events attached to database or session Logging-in/-out Table creation etc. M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 5

6 Rules Event Condition Action Event data modification (INSERT/UPDATE/DELETE) Condition changed data correspond to condition, defined by Boolean SQL expression Action defined trigger body containing additional INSERT/UPDATE/DELETE statements is executed M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 6

7 More detailed rules than integrity constraints Implemented directly in the database Applied equally for all client application and sessions Active database allows better enforce broader variety of integrity requirements than passive database, where additional tests have to be implemented on clients and/or application servers. M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 7

8 Triggers (rules) can be named by any identifies It is advisable to construct names systematically in such a way, that the name suggests the name of the associated table, the operation they react on and other useful information M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 8

9 Two types of triggers (active database rules) Row-level triggers They are activated by the change of individual rows of the associated table If more rows are changed, they can test data of individual rows Statement level They are activated only once by the action itself independently on the data content and changes M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 9

10 Detailed checking of changed data, not reachable by integrity constraints Typically by BEFORE row-level triggers Checking that the user is allowed to execute given statement Typically by BEFORE statement-level triggers Journaling of old table values Typically by AFTER row-level triggers Journaling of the operation history on the table Typically by AFTER statement-level triggers Data replication All modifications are repeated on other (remote) table Typically by AFTER row-level triggers M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 10

11 Addition fixing of application logic Part of the application logic is hidden Changes in data has unpredictable side-effects Worse application debugging It is better to use procedures, that the applications can (or have to due to inability to change data directly) explicitly execute M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 11

12 CREATE [OR REPLACE] TRIGGER trigger_name {BEFORE AFTER} {INSERT DELETE UPDATE [OF column_name]} ON table_name [FOR EACH ROW] [REFERENCING OLD AS old_name NEW AS new_name] [WHEN (condition)] PL/SQL block; Defines what to be done before, resp. after the change of data in the database Row-level triggers are executed repeatedly for each changed row and see the old and new version of the row Statement-level triggers for the statement and don t see changed data M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 12

13 Table actualization is done as follows: 1. BEFORE statement-level triggers 2. BEFORE row-level triggers 3. Row actualization / integrity constraint checking 4. AFTER row-level triggers 5. AFTER statement-level triggers If any of those steps fails, ie. The unhandled exception is thrown, actualization is invalid and is not done There can be defined more triggers of the same type on the given table, but their exact order is not defined M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 13

14 {CREATE ALTER} TRIGGER trigger_name ON { table view } [ WITH ENCRYPTION ] { FOR AFTER INSTEAD OF } { [ INSERT ] [, ] [ UPDATE ] [, ] [ DELETE ] } [ WITH APPEND ] AS [{IF UPDATE ( column ) [{ AND OR } UPDATE ( column ) ] IF ( COLUMNS_UPDATED ( bitwise_operator updated_bitmask )}] sql_statement [...] FOR is older equivalent for AFTER, no statement-level triggers The trigger can see and access all changed data using pseudo-tables DELETED AND INSERTED M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 14

15 Table actualization is done as follows : 1. Integrity constraint checking 2. Vytvoření tabulek deleted a inserted 2. Aktualizace (INSTEAD OF trigger) / integrity constraint checking 3. AFTER triggers If the transaction is found to be incorrect the transaction can be rolled back using ROLLBACK TRANSACTION The order of execution for triggers of the same type can be defined using sp_settriggerorder procedure M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 15

16 More types of actualization can be defined for one trigger In Oracle using OR CREATE TRIGGER BEFORE INSERT OR UPDATE ON In the trigger body are defined Boolean predicates INSERTING, UPDATING, DELETING In MS SQL using commas CREATE TRIGGER ON FOR INSERT, UPDATE M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 16

17 INSTEAD OF triggers overrides the implementation of the data actualization itself They are executed instead of INSERT, UPDATE, DELETE operation In Oracle they are allowed only for views, not for tables MS SQL doesn t distinguish between tables and views M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 17

18 Scenario I: Checking if the user is allowed to do given operation Executed usually if possible once before the statement is executed It can be tested if the user is logged from internal secure terminal, in working hours and many other things not available using integrity constraints M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 18

19 Example: CREATE OR REPLACE TRIGGER bef_ins_emp BEFORE INSERT ON Emp BEGIN IF USERENV( TERMINAL ) NOT LIKE PERS% THEN RAISE_APPLICATION_ERROR( , Employees can be hired only from Human resource department ); END IF; END; / M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 19

20 Example: CREATE TRIGGER aft_ins_emp ON Emp AFTER INSERT AS BEGIN IF HOST_NAME() NOT LIKE PERS% RAISERROR( 'Employees can be hired only from Human resource department', 15, 1); ROLLBACK TRANSACTION; END; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 20

21 Scenario II: Computing of functionally dependent values in the table Useful for fast search according to such functional dependent value Not necessary if the database is able to index expressions Executed usually if possible before the actualization on each row M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 21

22 There are defined two records inside rowlevel triggers NEW and OLD. They contain row data before and after change. INSERT triggers only NEW record DELETE triggers only OLD record UPDATE triggers both OLD and NEW records Names of records can be changed using REFERENCING clause M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 22

23 Example: CREATE OR REPLACE TRIGGER bef_ins_upd_emp_row BEFORE INSERT OR UPDATE ON Emp FOR EACH ROW BEGIN -- for searching by total income :NEW.Income := COALESCE(:NEW.Sal,0)+COALESCE(NEW.Comm,0); END; / M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 23

24 Trigger execution can be restricted by a Boolean condition declared in the WHEN condition CREATE OR REPLACE TRIGGER bef_ins_emp_row BEFORE INSERT ON Emp FOR EACH ROW WHEN (NEW.EmpNo IS NULL) -- there is no colon sign in the WHEN clause before NEW and/or OLD BEGIN SELECT SeqEmpNo.nextval INTO :NEW.EmpNo FROM DUAL; END; / M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 24

25 There are two pseudo-tables visible in the body of each trigger: inserted and deleted that contain new and old version of all changed records deleted in AFTER DELETE, UPDATE trigger inserted in AFTER INSERT, UPDATE triggers Can be tested by: IF EXISTS(SELECT * FROM DELETED) IF EXISTS(SELECT * FROM INSERTED) T/F DELETE, T/T UPDATE, F/T INSERT M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 25

26 Example: CREATE TRIGGER aft_ins_upd_emp_row ON Emp AFTER INSERT, UPDATE AS BEGIN -- for searching by total income UPDATE Emp SET Income = COALESCE(Sal,0)+COALESCE(Comm,0) WHERE EpmNo IN (SELECT EmpNo FROM inserted) AND (UPDATED(EmpNo) OR UPDATED(Comm)); END; Have to do it after operation using pseudotables deleted and inserted. M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 26

27 Scenario III: Checking of inserted/updated data Executed if available before the operation and for each row M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 27

28 Example: CREATE OR REPLACE TRIGGER bef_upd_emp_row BEFORE UPDATE ON Emp FOR EACH ROW BEGIN IF :NEW.Sal > :OLD.Sal * 1.1 THEN RAISE_APPLICATION_ERROR( , Salary can be raised at most by 10%. ); END IF; END; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 28

29 Example: CREATE TRIGGER aft_upd_emp_row ON Emp AFTER UPDATE BEGIN IF 0 < ( SELECT COUNT(*) FROM Emp AS NEW INNER JOIN INSERTED AS OLD ON (OLD.EmpNo=NEW.EmpNo) WHERE NEW.Sal > OLD.Sal * 1.1) RAISERROR('Salary can be raised at most by 10%', 15, 1 ); ROLLBACK TRANSACTION; END; Have to do it after operation using pseudo-tables deleted and inserted. M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 29

30 Scenario IV: Journaling of data changes. Should be done after successful change in the main table. It is possible to remember author of the change, time of change, original and new values etc. M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 30

31 Example: CREATE OR REPLACE TRIGGER aft_upd_emp_row AFTER UPDATE ON Emp FOR EACH ROW WHEN (OLD.Sal <> NEW.Sal) BEGIN INSERT INTO Journal(Who, When, EmpNo, OldSal, NewSal) VALUES(USER, SYSDATE, :OLD.EmpNo, :OLD.Sal, :NEW.Sal); END; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 31

32 Example: CREATE TRIGGER aft_upd_emp_row ON Emp AFTER UPDATE AS BEGIN INSERT INTO Journal(Who, When, EmpNo, OldSal, NewSal) SELECT CURRENT_USER, CURRENT_DATE, d.empno, d.sal, e.sal FROM deleted AS d JOIN employee AS e ON d.emp.id=e.emp_id WHERE UPDATED(Sal); END; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 32

33 CREATE [OR REPLACE] TRIGGER trigger_name INSTEAD OF {INSERT DELETE UPDATE [OF column_name]} ON view_name FOR EACH ROW [REFERENCING OLD AS old_name NEW AS new_name] [WHEN (condition)] PL/SQL block; Defines, how the given change should be implemented on underlying tables in the DB M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 33

34 Views USER_TRIGGERS USER_SOURCE Views SYS.TRIGGERS SYS.TRIGGER_EVENTS M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 34

35

36 There are three set operators defined in ANSI SQL UNION [ALL] SELECT FROM WHERE UNION ALL SELECT FROM WHERE UNION ALL If ALL option is not used, the result contains only unique rows, else results are simply concatenated and can contain duplicities Uniqueness of the UNION (and other operators as well) requires either ordering or hashing of operands, if it is possible, it is desirable to avoid unique UNION and use UNION ALL instead. INTERSECT (Unique) intersect of two results of SELECT statement EXCEPT (Oracle uses its proprietary operator MINUS) (Unique) difference of two results of SELECT statement M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 36

37

38 Standard SQL contains support for recursive queries since version ANSI SQL-99 in WITH statement Oracle supports it Since version 9i release 2 MS SQL supports it Since version MS SQL Server 2005 Oracle SQL contains also proprietary extension (with limited capabilities) using special clauses START WITH and CONNECT BY in the SELECT statement M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 38

39 WITH t1[(c11[, ])] AS (SELECT ) [,t2[(c21[, ]) AS (SELECT )] [, ] SELECT FROM t1, t2, WITH construct defines sources t1, t2, used for data selection. Sources t1, t2, are ad-hoc views existing and visible only In the associated SELECT statement Source definitions can (but need not) reference themselves and previous definitions in WITH statement SELECT can (but need not) use defined sources M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 39

40 Example: Highest number of employees in one department WITH x AS ( SELECT DeptNo, COUNT(*) AS Cnt FROM Emp GROUP BY DeptNo) SELECT MAX(Cnt) AS MaxCnt FROM x; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 40

41 Using WITH WITH x AS ( SELECT DeptNo, COUNT(*) AS Cnt FROM Emp GROUP BY DeptNo) SELECT MAX(x.Cnt) FROM x; Without WITH SELECT MAX(x.Cnt) FROM ( SELECT DeptNo, COUNT(*) AS Cnt FROM Emp GROUP BY DeptNo ) x ; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 41

42 Using WITH WITH x AS ( SELECT DeptNo, COUNT(*) AS Cnt FROM Emp GROUP BY DeptNo) SELECT a.deptno, b.deptno, a.cnt FROM x AS a, x AS b WHERE a.cnt=b.cnt AND a.deptno<b.deptno; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 42

43 Example: Table Emp with following structure: EmpNo Employee ID EName Name of the employee Mgr ID of Employee s manager (direct supervisor) We would like to list all employees together with the degree of subordination (level in the company hierarchy). Employees without supervisor have degree (level) equal to one. M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 43

44 Example: WITH e(ename,degree) AS ( -- all employees without supervisor (at level one) SELECT x.ename, 1 AS Degree FROM Emp x WHERE Mgr IS NULL UNION ALL -- recursive part -- all employees at level k+1 (supervised by those at level k) SELECT y.ename, e.degree+1 AS Degree FROM Emp y JOIN e ON y.mgr=e.empno ) SELECT * FROM e; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 44

45 SELECT columns FROM table_name [WHERE condition3] START WITH condition1 CONNECT BY [NOCYCLE] condition2 [ORDER BY ] [ORDER SIBLINGS BY ] Rows complying the condition1 in START WITH are supposed to be rows at level 1 M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 45

46 SELECT columns FROM table_name [WHERE condition3] START WITH condition1 CONNECT BY [NOCYCLE] condition2 [ORDER BY ] [ORDER SIBLINGS BY ] For each row found at level k are recursively searched direct descendants at level k+1, that satisfy condition2 in CONNECT BY clause Condition2 has to deal with parent and descendant rows. Values belonging to parent row are preceded by keyword PRIOR NOCYCLE stops recursion if the node should appear second time in the same path. Without it the reappearance causes error. M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 46

47 SELECT columns FROM table_name [WHERE condition3] START WITH condition1 CONNECT BY [NOCYCLE] condition2 [ORDER BY ] [ORDER SIBLINGS BY ] At the end all rows not satisfying condition3 in WHERE clause are eliminated (descendants were already processed and so they remain in the result even if their predecessor is removed afterwards) M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 47

48 SELECT columns FROM table_name [WHERE condition3] START WITH condition1 CONNECT BY [NOCYCLE] condition2 [ORDER BY ] [ORDER SIBLINGS BY ] Without ORDER BY the order of rows corresponds to preorder search. Each row contains a pseudocolumn LEVEL, with the level in hierarchy. Order of descendants of one particular parent is not defined by default. It can be specified by the ORDER SIBLINGS BY clause M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 48

49 Example: SELECT EName, Level AS Degree FROM Emp e START WITH Mgr IS NULL CONNECT BY PRIOR EmpNo = Mgr; SELECT with padding according to level LPAD(,2*Level) EName AS EName, M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 49

50

51 It is often necessary to return value where the expression used depends on some value Decoding of value using fixed codebook 1 ~ Monday 7 ~ Sunday 0 ~ 0% VAT, 1 ~ 15% VAT, 2 ~ 21% VAT etc. It can be ineffective to create function for each such situation or define the table for those codebooks and complicate queries by additional join (here the set of values is fixes and doesn t change or change minimal in time) M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 51

52 ANSI SQL-92 defines two forms of CASE expression a) simple CASE expression: CASE expression WHEN pattern1 THEN value1 WHEN pattern2 THEN value2 [ELSE default] END Returns value for first match expression=pattern i, resp. default value, resp. NULL M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 52

53 ANSI SQL-92 defines two forms of CASE expression b) searched CASE expression: CASE WHEN condition1 THEN value1 WHEN condition2 THEN value2 [ELSE default] END Return value for first match condition i = TRUE, resp. default value, resp. NULL M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 53

54 Example: SELECT Course, CASE Day WHEN 1 THEN Monday WHEN 2 THEN Tuesday WHEN 7 THEN Sunday ELSE UNKNOWN DAY END AS Day_of_Week FROM Schedule; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 54

55 Example: Sales split according to VAT type: SELECT CASE WHEN TaxGrp=0 THEN Price ELSE NULL END AS Price_00, CASE WHEN TaxGrp=1 THEN Price*1.15 ELSE NULL END AS Price_15, CASE WHEN TaxGrp=2 THEN Price*1.21 ELSE NULL END AS Price_21 FROM Sales; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 55

56 Oracle implements additional proprietary function DECODE DECODE(expression pattern1, value1, pattern2, value2[, ][, default]) Corresponds to simple CASE expression Less universal (available only in SELECTs) Not portable M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 56

57 Example: SELECT Course, DECODE(Day 1, Monday, 2, Tuesday, 7, Sunday UNKNOWN DAY ) AS Day_of_Week FROM Schedule; Example: SELECT Course, CASE Day WHEN 1 THEN Monday WHEN 2 THEN Tuesday WHEN 7 THEN Sunday ELSE UNKNOWN DAY END AS Day_of_Week FROM Schedule; M. Kopecký Data Security - Triggers, WITH SELECT Statements (NDBI026, Lect. 4) 57

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Views Creating views Using

More information

Active Databases Part 1: Introduction CS561

Active Databases Part 1: Introduction CS561 Active Databases Part 1: Introduction CS561 1 Active Databases n Triggers and rules are developed for data integrity and constraints n Triggers make passive database active Database reacts to certain situations

More information

Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired.

Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired. Aim:- TRIGGERS Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired. Advantages of database triggers: ---> Data is generated

More information

5 Integrity Constraints and Triggers

5 Integrity Constraints and Triggers 5 Integrity Constraints and Triggers 5.1 Integrity Constraints In Section 1 we have discussed three types of integrity constraints: not null constraints, primary keys, and unique constraints. In this section

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Transactions Transactional

More information

doc. RNDr. Tomáš Skopal, Ph.D. RNDr. Michal Kopecký, Ph.D.

doc. RNDr. Tomáš Skopal, Ph.D. RNDr. Michal Kopecký, Ph.D. course: Database Systems (NDBI025) SS2017/18 doc. RNDr. Tomáš Skopal, Ph.D. RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

More information

RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks)

RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks) 2017 RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks) 2016 Q. What is view? Definition of view: 2 marks) Ans : View: A view is a logical extract of a physical relation i.e. it is derived

More information

Database Management Systems Triggers

Database Management Systems Triggers Database Management Systems Triggers 1 Triggers Active Database Systems Oracle Triggers DB2 Triggers Differences between Oracle and DB2 Trigger Design 2 Database Management Systems Active Database Systems

More information

NULLs & Outer Joins. Objectives of the Lecture :

NULLs & Outer Joins. Objectives of the Lecture : Slide 1 NULLs & Outer Joins Objectives of the Lecture : To consider the use of NULLs in SQL. To consider Outer Join Operations, and their implementation in SQL. Slide 2 Missing Values : Possible Strategies

More information

COSC344 Database Theory and Applications. Lecture 11 Triggers

COSC344 Database Theory and Applications. Lecture 11 Triggers COSC344 Database Theory and Applications Lecture 11 Triggers COSC344 Lecture 11 1 Overview Last Lecture - PL/SQL This Lecture - Triggers - Source: Lecture notes, Oracle documentation Next Lecture - Java

More information

5. Single-row function

5. Single-row function 1. 2. Introduction Oracle 11g Oracle 11g Application Server Oracle database Relational and Object Relational Database Management system Oracle internet platform System Development Life cycle 3. Writing

More information

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement GIFT Department of Computing Science [Spring 2013] CS-217: Database Systems Lab-2 Manual Data Selection and Filtering using the SELECT Statement V1.0 4/12/2016 Introduction to Lab-2 This lab reinforces

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until Databases Relational Model, Algebra and operations How do we model and manipulate complex data structures inside a computer system? Until 1970.. Many different views or ways of doing this Could use tree

More information

New York Oracle Users Group. September 26, 2002 New York, NY

New York Oracle Users Group. September 26, 2002 New York, NY New York Oracle Users Group September 26, 2002 New York, NY Fire and Forget : When to Use Autonomous Transactions Michael Rosenblum Dulcian, Inc. www.dulcian.com ! Definition: Autonomous Transactions "

More information

PL/SQL. Exception. When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number

PL/SQL. Exception. When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number PL/SQL Exception When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number Exceptions must be handled by name. PL/SQL predefines some common Oracle

More information

ORACLE VIEWS ORACLE VIEWS. Techgoeasy.com

ORACLE VIEWS ORACLE VIEWS. Techgoeasy.com ORACLE VIEWS ORACLE VIEWS Techgoeasy.com 1 Oracle VIEWS WHAT IS ORACLE VIEWS? -A view is a representation of data from one or more tables or views. -A view is a named and validated SQL query which is stored

More information

Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views

Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views Sequence An Oracle sequence is an Oracle database object that can be used to generate unique numbers. You can use sequences to

More information

Enhanced Data Models for Advanced Applications. Active Database Concepts

Enhanced Data Models for Advanced Applications. Active Database Concepts Enhanced Data Models for Advanced Applications Active Database Concepts Topics To Be Discussed Generalized Model for Active Databases and Oracle Triggers Design and Implementation Issues for Active Databases

More information

Objectives. After completing this lesson, you should be able to do the following:

Objectives. After completing this lesson, you should be able to do the following: Objectives After completing this lesson, you should be able to do the following: Describe the types of problems that subqueries can solve Define subqueries List the types of subqueries Write single-row

More information

doc. RNDr. Tomáš Skopal, Ph.D. doc. RNDr. Irena Mlýnková, Ph.D. RNDr. Michal Kopecký, Ph.D.

doc. RNDr. Tomáš Skopal, Ph.D. doc. RNDr. Irena Mlýnková, Ph.D. RNDr. Michal Kopecký, Ph.D. course: Database Systems (NDBI025) SS2017/18 doc. RNDr. Tomáš Skopal, Ph.D. doc. RNDr. Irena Mlýnková, Ph.D. RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics,

More information

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies Databases - 4 Other relational operations and DDL How to write RA expressions for dummies Step 1: Identify the relations required and CP them together Step 2: Add required selections to make the CP Step

More information

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database 11g: SQL and PL/SQL Fundamentals Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle Database 11g: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn In this course, students learn the fundamentals of SQL and PL/SQL

More information

SQL Structured Query Language Introduction

SQL Structured Query Language Introduction SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and

More information

Oracle Syllabus Course code-r10605 SQL

Oracle Syllabus Course code-r10605 SQL Oracle Syllabus Course code-r10605 SQL Writing Basic SQL SELECT Statements Basic SELECT Statement Selecting All Columns Selecting Specific Columns Writing SQL Statements Column Heading Defaults Arithmetic

More information

CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries

CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries T E H U N I V E R S I T Y O H F R G E D I N B U CS2 Current Technologies Lecture 3: SQL - Joins and Subqueries Chris Walton (cdw@dcs.ed.ac.uk) 11 February 2002 Multiple Tables 1 Redundancy requires excess

More information

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] 1. What is DBMS? A Database Management System (DBMS) is a program that controls creation, maintenance and use

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 4 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

SQL Interview Questions

SQL Interview Questions SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic

More information

SYSTEM CODE COURSE NAME DESCRIPTION SEM

SYSTEM CODE COURSE NAME DESCRIPTION SEM Course: CS691- Database Management System Lab PROGRAMME: COMPUTER SCIENCE & ENGINEERING DEGREE:B. TECH COURSE: Database Management System Lab SEMESTER: VI CREDITS: 2 COURSECODE: CS691 COURSE TYPE: Practical

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Schema modification Adding

More information

SQL. Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior

SQL. Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior SQL Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior 1 DDL 2 DATA TYPES All columns must have a data type. The most common data types in SQL are: Alphanumeric: Fixed length:

More information

CHAPTER: 4 ADVANCE SQL: SQL PERFORMANCE TUNING (12 Marks)

CHAPTER: 4 ADVANCE SQL: SQL PERFORMANCE TUNING (12 Marks) (12 Marks) 4.1 VIEW View: Views are virtual relations mainly used for security purpose, and can be provided on request by a particular user. A view can contain all rows of a table or select rows from a

More information

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 6 Using Subqueries and Set Operators Eng. Alaa O Shama November, 2015 Objectives:

More information

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel 1 In this chapter, you will learn: The basic commands

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

Now, we can refer to a sequence without having to use any SELECT command as follows:

Now, we can refer to a sequence without having to use any SELECT command as follows: Enhancement in 11g Database PL/SQL Sequence: Oracle Database 11g has now provided support for Sequence in PL/SQL. Earlier to get a number from a sequence in PL/SQL we had to use SELECT command with DUAL

More information

SQL functions fit into two broad categories: Data definition language Data manipulation language

SQL functions fit into two broad categories: Data definition language Data manipulation language Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition Chapter 7 Beginning Structured Query Language (SQL) MDM NUR RAZIA BINTI MOHD SURADI 019-3932846 razia@unisel.edu.my

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management Tenth Edition Chapter 8 Advanced SQL Objectives In this chapter, you will learn: How to use the advanced SQL JOIN operator syntax About the different

More information

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals NEW Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the fundamentals of SQL and PL/SQL along with the

More information

UNIT-IV (Relational Database Language, PL/SQL)

UNIT-IV (Relational Database Language, PL/SQL) UNIT-IV (Relational Database Language, PL/SQL) Section-A (2 Marks) Important questions 1. Define (i) Primary Key (ii) Foreign Key (iii) unique key. (i)primary key:a primary key can consist of one or more

More information

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity COSC 416 NoSQL Databases Relational Model (Review) Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was proposed by E. F. Codd

More information

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals

More information

Programming the Database

Programming the Database Programming the Database Today s Lecture 1. Stored Procedures 2. Functions BBM471 Database Management Systems Dr. Fuat Akal akal@hacettepe.edu.tr 3. Cursors 4. Triggers 5. Dynamic SQL 2 Stored Procedures

More information

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 2 Data Definition Language (DDL) Eng. Alaa O Shama October, 2015 Objective To be familiar

More information

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger Data Integrity IT 4153 Advanced Database J.G. Zheng Spring 2012 Overview Three basic types of data integrity Integrity implementation and enforcement Database constraints Transaction Trigger 2 1 Data Integrity

More information

1 Prepared By Heena Patel (Asst. Prof)

1 Prepared By Heena Patel (Asst. Prof) Topic 1 1. What is difference between Physical and logical data 3 independence? 2. Define the term RDBMS. List out codd s law. Explain any three in detail. ( times) 3. What is RDBMS? Explain any tow Codd

More information

Chapter 2. DB2 concepts

Chapter 2. DB2 concepts 4960ch02qxd 10/6/2000 7:20 AM Page 37 DB2 concepts Chapter 2 Structured query language 38 DB2 data structures 40 Enforcing business rules 49 DB2 system structures 52 Application processes and transactions

More information

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL)

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 3 Database Programming PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL) AGENDA 3. Declaring Variables/Constants 4. Flow Control

More information

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved. Database Foundations 6-3 Roadmap You are here Introduction to Oracle Application Express Structured Query Language (SQL) Data Definition Language (DDL) Data Manipulation Language (DML) Transaction Control

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management Tenth Edition Chapter 8 Advanced SQL SQL Join Operators Join operation merges rows from two tables and returns the rows with one of the following:

More information

RDBMS - PL SQL - Topic 5 - MSBTE QUESTIONS AND ANSWERS

RDBMS - PL SQL - Topic 5 - MSBTE QUESTIONS AND ANSWERS RDBMS - PL SQL - Topic 5 - MSBTE QUESTIONS AND ANSWERS SUMMER 2017 Q. Describe Exception handling. Explain with example. 4 Marks Exception Handling: Exception is nothing but an error. Exception can be

More information

Question: Which statement would you use to invoke a stored procedure in isql*plus?

Question: Which statement would you use to invoke a stored procedure in isql*plus? What are the two types of subprograms? procedure and function Which statement would you use to invoke a stored procedure in isql*plus? EXECUTE Which SQL statement allows a privileged user to assign privileges

More information

RESTRICTING AND SORTING DATA

RESTRICTING AND SORTING DATA RESTRICTING AND SORTING DATA http://www.tutorialspoint.com/sql_certificate/restricting_and_sorting_data.htm Copyright tutorialspoint.com The essential capabilities of SELECT statement are Selection, Projection

More information

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine. 1 PL/SQL INTRODUCTION SQL does not have procedural capabilities. SQL does not provide the programming techniques of condition checking, looping and branching that is required for data before permanent

More information

Lab # 4. Data Definition Language (DDL)

Lab # 4. Data Definition Language (DDL) Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 4 Data Definition Language (DDL) Eng. Haneen El-Masry November, 2014 2 Objective To be familiar with

More information

INDEX. 1 Introduction. 2 Types of Cursors 2.1 Explicit cursor 2.2 Attributes 2.3 Implicit cursor 2.4 Attributes. 3 Parameterized cursor

INDEX. 1 Introduction. 2 Types of Cursors 2.1 Explicit cursor 2.2 Attributes 2.3 Implicit cursor 2.4 Attributes. 3 Parameterized cursor INDEX 1 Introduction 2 Types of Cursors 2.1 Explicit cursor 2.2 Attributes 2.3 Implicit cursor 2.4 Attributes 3 Parameterized cursor INTRODUCTION what is cursor? we have seen how oracle executes an SQL

More information

What are temporary tables? When are they useful?

What are temporary tables? When are they useful? What are temporary tables? When are they useful? Temporary tables exists solely for a particular session, or whose data persists for the duration of the transaction. The temporary tables are generally

More information

Misc. Triggers Views Roles Sequences - Synonyms. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering

Misc. Triggers Views Roles Sequences - Synonyms. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Database Lab (ECOM 4113) Lab 9 Misc. Triggers Views Roles Sequences - Synonyms Eng. Mohammed Alokshiya December 7, 2014 Views

More information

Triggers- View-Sequence

Triggers- View-Sequence The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Database Lab (ECOM 4113) Lab 9 Triggers- View-Sequence Eng. Ibraheem Lubbad Triggers: A trigger is a PL/SQL block or

More information

Introduction to Computer Science and Business

Introduction to Computer Science and Business Introduction to Computer Science and Business The Database Programming with PL/SQL course introduces students to the procedural language used to extend SQL in a programatic manner. This course outline

More information

Introduction p. 1 The Logical and Physical View of Tables p. 1 Database Types p. 4 NULLs p. 6 DDL and DML Statements p. 7 Column and Table Constraint

Introduction p. 1 The Logical and Physical View of Tables p. 1 Database Types p. 4 NULLs p. 6 DDL and DML Statements p. 7 Column and Table Constraint Preface p. xv Introduction p. 1 The Logical and Physical View of Tables p. 1 Database Types p. 4 NULLs p. 6 DDL and DML Statements p. 7 Column and Table Constraint Clauses p. 7 Sample Database p. 9 A Quick

More information

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C 0 0 3 2 LIST OF EXPERIMENTS: 1. Creation of a database and writing SQL queries to retrieve information from the database. 2. Performing Insertion,

More information

CHAPTER4 CONSTRAINTS

CHAPTER4 CONSTRAINTS CHAPTER4 CONSTRAINTS LEARNING OBJECTIVES After completing this chapter, you should be able to do the following: Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN KEY,

More information

To understand the concept of candidate and primary keys and their application in table creation.

To understand the concept of candidate and primary keys and their application in table creation. CM0719: Database Modelling Seminar 5 (b): Candidate and Primary Keys Exercise Aims: To understand the concept of candidate and primary keys and their application in table creation. Outline of Activity:

More information

D B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity

D B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity SQL language: basics Creating a table Modifying table structure Deleting a table The data dictionary Data integrity 2013 Politecnico di Torino 1 Creating a table Creating a table (1/3) The following SQL

More information

SQL:1999 and Recent Developments in SQL Standardisation

SQL:1999 and Recent Developments in SQL Standardisation SQL:1999 and Recent Developments in SQL Standardisation by Hugh Darwen IBM United Kingdom Limited Hugh_Darwen@uk.ibm.com 22 May, 2001 (Cambridge University) (c) Hugh Darwen 2001 1 The Parts of SQL Part

More information

Slides by: Ms. Shree Jaswal

Slides by: Ms. Shree Jaswal Slides by: Ms. Shree Jaswal A trigger is a statement that is executed automatically by the system as a side effect of a modification to the database. To design a trigger mechanism, we must: Specify the

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2017 CS 348 (Intro to DB Mgmt) SQL

More information

Oracle Database 10g: Introduction to SQL

Oracle Database 10g: Introduction to SQL ORACLE UNIVERSITY CONTACT US: 00 9714 390 9000 Oracle Database 10g: Introduction to SQL Duration: 5 Days What you will learn This course offers students an introduction to Oracle Database 10g database

More information

DB2 SQL Class Outline

DB2 SQL Class Outline DB2 SQL Class Outline The Basics of SQL Introduction Finding Your Current Schema Setting Your Default SCHEMA SELECT * (All Columns) in a Table SELECT Specific Columns in a Table Commas in the Front or

More information

Where are we? Week -4: Data definition (Creation of the schema) Week -3: Data definition (Triggers) Week -1: Transactions and concurrency in ORACLE.

Where are we? Week -4: Data definition (Creation of the schema) Week -3: Data definition (Triggers) Week -1: Transactions and concurrency in ORACLE. Where are we? Week -4: Data definition (Creation of the schema) Week -3: Data definition (Triggers) Week -2: More SQL queries Week -1: Transactions and concurrency in ORACLE. But don t forget to work on

More information

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database 11g: Program with PL/ SQL. Version: Demo

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database 11g: Program with PL/ SQL. Version: Demo Vendor: Oracle Exam Code: 1Z0-144 Exam Name: Oracle Database 11g: Program with PL/ SQL Version: Demo QUESTION NO: 1 View the Exhibit to examine the PL/SQL code: SREVROUPUT is on for the session. Which

More information

Sql Server Syllabus. Overview

Sql Server Syllabus. Overview Sql Server Syllabus Overview This SQL Server training teaches developers all the Transact-SQL skills they need to create database objects like Tables, Views, Stored procedures & Functions and triggers

More information

SQL. Char (30) can store ram, ramji007 or 80- b

SQL. Char (30) can store ram, ramji007 or 80- b SQL In Relational database Model all the information is stored on Tables, these tables are divided into rows and columns. A collection on related tables are called DATABASE. A named table in a database

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague seminář: Administrace Oracle (NDBI013) LS2017/18 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Database structure Database

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2016 CS 348 (Intro to DB Mgmt) SQL

More information

SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database.

SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database. SQL SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database. SQL*Plus SQL*Plus is an application that recognizes & executes SQL commands &

More information

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data 1 Writing Basic SQL SELECT Statements Objectives 1-2 Capabilities of SQL SELECT Statements 1-3 Basic SELECT Statement 1-4 Selecting All Columns 1-5 Selecting Specific Columns 1-6 Writing SQL Statements

More information

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 304 Introduction to Database Systems SQL DDL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Overview Structured Query Language or SQL is the standard query language

More information

CSE 530A. Inheritance and Partitioning. Washington University Fall 2013

CSE 530A. Inheritance and Partitioning. Washington University Fall 2013 CSE 530A Inheritance and Partitioning Washington University Fall 2013 Inheritance PostgreSQL provides table inheritance SQL defines type inheritance, PostgreSQL's table inheritance is different A table

More information

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value Databases - 3 Null, Cartesian Product and Join Null Null is a value that we use when Something will never have a value Something will have a value in the future Something had a value but doesn t at the

More information

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value Databases - 3, Cartesian Product and Join is a value that we use when Something will never have a value Something will have a value in the future Something had a value but doesn t at the moment is a reserved

More information

Chapter 7. Advanced SQL. Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel

Chapter 7. Advanced SQL. Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel Chapter 7 Advanced SQL Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel 1 In this chapter, you will learn: About the relational set operators UNION, UNION ALL, INTERSECT,

More information

INTRODUCTION TO MYSQL MySQL : It is an Open Source RDBMS Software that uses Structured Query Language. It is available free of cost. Key Features of MySQL : MySQL Data Types: 1. High Speed. 2. Ease of

More information

Relational Database Management Systems Mar/Apr I. Section-A: 5 X 4 =20 Marks

Relational Database Management Systems Mar/Apr I. Section-A: 5 X 4 =20 Marks Relational Database Management Systems Mar/Apr 2015 1 I. Section-A: 5 X 4 =20 Marks 1. Database Database: Database is a collection of inter-related data which contains the information of an enterprise.

More information

Table of Contents. Oracle SQL PL/SQL Training Courses

Table of Contents. Oracle SQL PL/SQL Training Courses Table of Contents Overview... 7 About DBA University, Inc.... 7 Eligibility... 8 Pricing... 8 Course Topics... 8 Relational database design... 8 1.1. Computer Database Concepts... 9 1.2. Relational Database

More information

ACCESS isn t only a great development tool it s

ACCESS isn t only a great development tool it s Upsizing Access to Oracle Smart Access 2000 George Esser In addition to showing you how to convert your Access prototypes into Oracle systems, George Esser shows how your Access skills translate into Oracle.

More information

Data Organization and Processing I

Data Organization and Processing I Data Organization and Processing I Data Organization in Oracle Server 11g R2 (NDBI007) RNDr. Michal Kopecký, Ph.D. http://www.ms.mff.cuni.cz/~kopecky Database structure o Database structure o Database

More information

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management 12 Advanced Topics Objectives Use indexes to improve database performance Examine the security features of a DBMS Discuss entity, referential, and legal-values integrity Make changes to the structure of

More information

An Introduction to Structured Query Language

An Introduction to Structured Query Language An Introduction to Structured Query Language Alexandra Roatiş David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Winter 2016 CS 348 SQL Winter

More information

Working with DB2 Data Using SQL and XQuery Answers

Working with DB2 Data Using SQL and XQuery Answers Working with DB2 Data Using SQL and XQuery Answers 66. The correct answer is D. When a SELECT statement such as the one shown is executed, the result data set produced will contain all possible combinations

More information

Topics Fundamentals of PL/SQL, Integration with PROIV SuperLayer and use within Glovia

Topics Fundamentals of PL/SQL, Integration with PROIV SuperLayer and use within Glovia Topics Fundamentals of PL/SQL, Integration with PROIV SuperLayer and use within Glovia 1. Creating a Database Alias 2. Introduction to SQL Relational Database Concept Definition of Relational Database

More information

ORACLE: PL/SQL Programming

ORACLE: PL/SQL Programming %ROWTYPE Attribute... 4:23 %ROWTYPE... 2:6 %TYPE... 2:6 %TYPE Attribute... 4:22 A Actual Parameters... 9:7 Actual versus Formal Parameters... 9:7 Aliases... 8:10 Anonymous Blocks... 3:1 Assigning Collection

More information

Chapter 14. Active Databases. Database Systems(Part 2) p. 200/286

Chapter 14. Active Databases. Database Systems(Part 2) p. 200/286 Chapter 14 Active Databases Database Systems(Part 2) p. 200/286 Active Data? With the help of constraints (primary key, foreign key, check clauses) we increased the data semantics Anything that the database

More information

Real-World Performance Training SQL Introduction

Real-World Performance Training SQL Introduction Real-World Performance Training SQL Introduction Real-World Performance Team Basics SQL Structured Query Language Declarative You express what you want to do, not how to do it Despite the name, provides

More information

Constraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2

Constraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2 CMPT 354 Constraints Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers John Edgar 2 firstname type balance city customerid lastname accnumber rate branchname phone

More information

2. Programming written ( main theme is to test our data structure knowledge, proficiency

2. Programming written ( main theme is to test our data structure knowledge, proficiency ORACLE Job Placement Paper Paper Type : General - other 1. Tech + Aptitude written 2. Programming written ( main theme is to test our data structure knowledge, proficiency sorting searching algorithms

More information

ORACLE Job Placement Paper. Paper Type : General - other

ORACLE Job Placement Paper. Paper Type : General - other ORACLE Job Placement Paper Paper Type : General - other 1. Tech + Aptitude written 2. Programming written ( main theme is to test our data structure knowledge, proficiency sorting searching algorithms

More information