Académique Documents
Professionnel Documents
Culture Documents
com/teradata/
5. By default the duplicate rows are eliminated from the answer sets but if at all you want you can get the same by the use of another operator ALL.
If you specify a TOP n or TOP m PERCENT option, then only you can specify an ORDER BY clause otherwise NO. When referencing multiple tables make use of indexes for faster access.
Here is the syntax: CREATE VIEW <view-name> [( <column alias name1>,... ) ] AS LOCK [TABLE | VIEW | ROW ] FOR | IN [READ | WRITE | ACCESS ] MODE NOWAIT SELECT [DISTINCT | ALL ] TOP <n|m> PERCENT [WITH TIES] <column-name> [AS <alias-name> ] [ , <column-name> [AS <alias-name> ] ] FROM <table-name> <JOIN CONDITION | SUB QUERY> [ WHERE <search condition> GROUP BY <grouping specification> [ WITH CHECK OPTION ] HAVING <condition >]
Use the clause WITH CHECK OPTION for updatable Views which helps in restricting the rows that can be updated in the table by an INSERT or UPDATE statement to satisfy the condition in WHERE clause. In other words, use this clause if you want to insert rows that satisfies the WHERE clause, present in the View definition. If you do not specify this clause, rows would be inserted ignoring the WHERE clause but base table checks and constraints remain enforced.
What is equivalent to Oracles Dual table in Teradata? Good question, actually there is no such table present in Teradata. But the same functionality can be derived by the following code. Before that just to remind that the Dual table in Oracle is used for intermediate calculations, like selecting a date and calculating something. In Teradata it is done without the use of any such table. In Oracle if you are using SELECT SYSDATE FROM DUAL In Teradata the same can be achieved by the following shorter command; SELECT DATE Isnt it COOL! How to Change your Password in Teradata This command is pretty similar to the command in Oracle. MODIFY USER userid AS PASSWORD = yournewpassword
Note the two semi-colons, first one is for the triggered action statement and the 2nd one is for the entire CREATE TRIGGER statement.
1. Stored Procedure is a database Object and DDL is used to create it. 2. The set of statements that forms the primary task of a Stored Procedure contains 3. 4. 5. 6. 7. 8.
within, what is called a Stored Procedure body. Stored Procedure body can be either a single state a compound statement. Single statement procedure can contain only one looping mechanism or SQL statement, excluding Cursors. Where as compound statements can have multiple statements but it has to be within the BEGIN and END block. It is not a good practice to use DDL statements within a Stored Procedure. It is stored in USER DATABASE space. Can have parameters like IN, OUT and INOUT.
Example: CREATE PROCEDURE MyFirstProc (IN emp_number INTEGER, IN dept_number INTEGER, OUT dept_name CHAR(10), INOUT errstr VARCHAR(30)) BEGIN INSERT INTO Employee (EmpNo, DeptNo )
VALUES (emp_number, dept_number); SELECT DeptName INTO dept_name FROM Department WHERE DeptNo = dept_number; END; To execute/call the above Stored Procedure: CALL MyFirstProc (495, 211);
Transaction Management
The principle objective of a transaction is to facilitate data completeness when a sequence of events happens. Although it is not necessary that a sequence of events has to take place. A single event can also be considered as a transaction. A single event could be any data manipulation events like INSERTING, UPDATING or DELETING a row or set of rows. Transaction is a logical unit of work. When we say a logical unit, it means the unit of work has a logic involved in it and this unit of work has to be performed in its completeness or not at all. A transaction cannot be completed partially. For example, lets say in an organization there is a change in the employees salary. This revised salary has to be applied to all the employees or none of the employees. Similarly when a bank pays interest on Savings Account, it has to pay interest on all the Savings Account that is present in the books or NONE.