Sie sind auf Seite 1von 2

SUB QUERY - sub query or inner query or nested query is a quer in query .

a subqu ery is usually added in WHERE cluase of the sql statement most of the time a subquery is used when you know how to search for a value usin g a SELECT statement but do not know yhe exact value. subquery is the alternate way of returning data from multiple tables. subquery can be used with tha following sql statements along with the compari son operators like =,<,> etc subquery can be used in in these statements SELECT,INSERT,UPDATE,DELETE. CORRELATED QUERY - a query is called correlated query when both the inner query and outer query are independent. for every row processed by the inner query,outer query is processed as well.the inner query is depends on outer query before it can be processed eg: SELECT p.product_name from product.p where p.product_id = (SELECT o.product_id from order_items WHERE o.product_i d = p.product_id); SQL JOINS - sqql joins are used to relate information in different tables.a join condition is a part of the sql querry that retrieves rows from two or more tables.a sql join conditi on is used in the sql WHERE clause of SELECT,UPDATE,DELETE statement sql joins can be classified into equi and non equi joins EQUI JOINS - it isthe simple sql join condition which uses the equal sign as the comparison operator two types of equi joins are there sql outer and sql inner joins SQL NON-EQUI JOINS - it is a sql join condition which makes use of some comparis on operator other than the equal sign like <,>,<= etc SQL INNER JOIN - all the rows returned by the sql query satisfy the sql join con dition specified eg: if we want to display a product information for each order the query will b e as : SELECT order_id,product_name,unit_price FROM product,order_items WHERE order_items,product_id=product.product_id; SQL OUTER JOIN - yhe sql join condition returns all rows from both tables which satisfy th join condition along with ows which do not satisfy the join condition from on ethe tables. the sql outer join operator in oracle is (+) and is used on one side of the join condition only, eg: SELECT order_id,product_name,unit_price FROM order_items.o,product.p WHERE o.product_id(+) p.product_id; SQL SELF JOIN - a self join is a type of sql join which is used to join a table to table to itself, particular when the table has foreign key that refrences it's own primary key .it is necessary t o ensure that the join statement defines an alias for both copies of the table to avoid column ambiguity eg: SELECT first_name,last_name,subject FROM student_details

WHERE a.manger_id = b.sales_person_id; SQL NON EQUI JOIN - a non equi join sql join whose condition is established usin g all compaison operators exceptsthe equal(=) operator eg:SELECT first_name,last_name,subject FROM student_details WHERE subject !='economies' ; SQL VIEWS - a VIEW is a virtual table,through which a selective portion of the d ata from on eor more tables can be seen.views do not contain data of their own they are used to restrict access to database or to hide data incompexity.a view is stored as SELECT statement in the database. SYNTAX: CREATE VIEW view_name AS SELECT column_list FROM table_name[where condition] P/SQL Blocks- pis a procedural extentfor oracle structured querylanguage . pl/sq l is not a separate lang rather a technology meeans that ou will not have avy separate place or prompt for executing your pl/ sql blocks and subbprogram .pl/sql technology is like an engine that executes pl/sql blocks.this engine can't started in oracl e server or in other application development tools. CURSORS - for every SQL statement execution certain area in memory is allocated. pl/sql allows you to name this area.these private sql area is called content are a or cursor.acursor acts as a handle or point into the content area.a pl/sql pro gram controls the context area using the cursor.cursor represents a structure in memory and is different with cusor variable when you declare cursor,you get a pointer variable which does not point anything when the curso is opened memory is allocated and the cursor structure is created .the cursor variable points the cusor.when t he cursor is closed memory allocated is released.cursor allows programmer to ret rieve data from a table and perform action an that data one row at a time IMPLICIT CURSOR - for sql.querries returning single rows pl/sql declares implici t cursor.implicit cursors are simple SELECT statements and are writtenin the B EGIN block of the pl/sql .implicit cursor are easy to code,and the retrieve exac tly one row.pl/sql implicitly declares cursors for all DML statements.the most c ommonly raised exeptions are NO_DATA_FOUND or TOO_MANY_ROWS EXPLICIT CURSOR - explicit cursors are used in queries that return multiple rows .the set of rows fetched by a query is called active set.the size of the active set meets the search criteria in the select st atement.explixit cursor is declared in the declare section od pl/sql program.SYN TAX <cursor-name>IS<select statement>

Das könnte Ihnen auch gefallen