Merge and truncate in sql, PL-SQL Programming

MERGE and TRUNCATE in SQL

SQL has two more table update operators, MERGE and TRUNCATE. MERGE, like INSERT, takes a source table s and uses it to update a target table t. Briefly, a MERGE statement specifies a matching condition to determine which rows of s have at least one matching row in t (under that specified matching condition). It then specifies an open-ended series of conditions to be applied to each row of s paired with actions to be applied on t.

WHEN MATCHED AND c1 THEN x1 specifies that action x1, necessarily an UPDATE or DELETE, is to be applied on t for each matching row in s that satisfies the condition c1. WHEN NOT MATCHED AND c2 THEN x2 specifies that action x2, necessarily an INSERT, is to be applied on t for each non-matching row in s that satisfies the condition c2. The curiously named TRUNCATE statement deletes all the rows from its specified target, bypassing any triggered actions, including compensatory actions, specified for that target. The target must be a base table.

Posted Date: 1/18/2013 11:40:57 PM | Location : United States







Related Discussions:- Merge and truncate in sql, Assignment Help, Ask Question on Merge and truncate in sql, Get Answer, Expert's Help, Merge and truncate in sql Discussions

Write discussion on Merge and truncate in sql
Your posts are moderated
Related Questions
LEVEL You use the LEVEL with the SELECT CONNECT BY statement to categorize rows from a database table into a tree structure. The LEVEL returns the level number of a node in a

Keyword and Parameter Description: label_name: This is an undeclared identifier which labels an executable statement or the PL/SQL block. You can use a GOTO statement to

Parameter and Keyword Description: cursor_name: This identifies an explicit cursor formerly declared within the present scope. cursor_variable_name: These identif

%TYPE: This attribute gives the datatype of a formerly declared collection, cursor variable, object, field, record, database column, or variable. Datatype: This is simply

Example of GROUP BY and COLLECT Operator Example: Using GROUP BY and COLLECT to obtain C_ER2 SELECT CourseId, CAST ( COLLECT (ROW (StudentId, Mark)) AS ROW (Studen

Deriving Predicates from Predicates in SQL The corresponding section in the theory book describes how predicates can be derived from predicates using (a) the logical connectiv

set serveroutput on declare a number(5); b number(5); c number(5); begin a:=&a; b:=&b; c:=a/b; dbms_output.put_line(c); exception when zero_d

Manipulating Collections Within PL/SQL, the collections add procedural power and flexibility. The biggest benefit is that your program can compute subscripts to process the spec

CURRVAL and NEXTVAL The series is a schema object which generates the sequential numbers. Whenever you form a sequence, you can specify its primary value and an increment. T

Projection in SQL - correct version Student StudentId is enrolled on some course. SELECT DISTINCT StudentId FROM IS_ENROLLED_ON In more complicated examples it is someti