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

PURGE FLASHBACK INNER JOIN FULL OUTER JOIN LEFT OUTER JOIN CROSS JOIN ANTI-JOINS SEMIJOINS

Remueve tabla o ndices del recycle bin y libera todo el espacio asociado con el objeto. No puede hacer rollback. Restaura el estado de una tabla. No preserva ROWID, referential constraints, estadisticas. Recuperar table perdida: FLASHBACK TABLE print_media TO BEFORE DROP; Set de datos que coinciden en ambas tablas Todos los registros de A y de B TableA LEFT OUTER JOIN TableB. Todos los datos de A que estan en B Cartesian Product (from two_rows a CROSS JOIN two_rows b;) NOT IN Exists

CORRELATED SUBQUERY

Nested subquery references a column from a table referred to a parent statement any number of levels above the subquery. . A correlated subquery is evaluated once for each row processed by the parent statement.
SELECT select_list FROM table1 t_alias1 WHERE expr operator (SELECT column_list FROM table2 t_alias2 WHERE t_alias1.column operator t_alias2.column);

UNNESTING OF NESTED SUBQUERIES SCALAR SUBQUERY NONCORRELATED SUBQUERIES

Subqueries are nested when they appear in the WHERE clause of the parent statement.
- Uncorrelated IN subqueries - IN and EXISTS correlated subqueries, as long as they do not contain aggregate functions or a GROUP BY clause Retorna exactamente un valor de una columna
Single-row, single-column subqueries SELECT lname FROM employee WHERE salary > (SELECT AVG(salary) Multiple-row, single-column subqueries SELECT fname, lname FROM employee WHERE dept_id = 30 AND salary >= ALL (SELECT salary FROM employee WHERE dept_id = 30);

FROM employee);

Multiple-column subqueries UPDATE monthly_orders SET (tot_orders, max_order_amt, min_order_amt, tot_amt) = (SELECT COUNT(*), MAX(sale_price), MIN(sale_price), SUM(sale_price) FROM cust_order WHERE order_dt >= TO_DATE('01-JUL-2001','DD-MON-YYYY') AND order_dt < TO_DATE('01-AUG-2001','DD-MON-YYYY') AND cancelled_dt IS NULL) WHERE month = 7 and year = 2001;

WITH CHECK OPTION DEFERRABLE CLAUSE ORDER BY

Equivalent to specifying a check constraint for the view. P revents any changes to the data in the

view that could cause rows to be not included in the view

CHECK CONSTRAINT. NULLIF(E1,E2) NVL2(E1,E2,E3) COALESCE

default is NOT DEFERRABLE: clause to defer checking of this constraint until the transaction is committed; CREATE TABLE or ALTER TABLE statement is committed or the statement will fail. DEFERRABLE : This setting in effect lets you disable the constraint temporarily while making changes to the database that might violate the constraint until all the changes are complete. Asc es default. No pueden ir columnas Long, lob. UNION, INTERSECT, MINUS, or UNION ALL, the ORDER BY clause must specify positions or aliases. Eje. ORDER BY 2 ASC, 3 DESC, 1; Requires a value in the database to comply with a specified condition. .No puede usarse: User, SYSDATE IF E1 = E2 THEN NULL ELSE E1 IF E1 IS NULL THEN E3 ELSE E2 CASE WHEN expr1 IS NOT NULL THEN expr1 ELSE expr2 END

(EXPR1, EXPR2) HIERARCHICAL RETRIEVAL DDL DML DCL TCL SAVEPOINT ROLLUP CUBE

START WITH ; CONNECT BY PRIOR NOCYCLElets the CONNECT BY query recognize that an infinite loop is occurring and stop without error (instead of returning a CONNECT BY loop error).

GROUPING SETS

GROUPING

GROUPING_ID

GRANT

ROLE ROLE WITH THE ADMIN OPTION

WITH GRANT OPTION DICTIONARY

Data Definition Language: statements used to define the database structure or schema. Create, Alter Data Manipulation Language: statements used for managing data within schema objects. Select, insert Data Control Language. Grant, revoke Transaction Control. Commit, rollback, savepoint In a transaction to which you can later roll back n+1. given three expressions (n=3) , n+1 = 3+1 = 4 groupings 2n . All possible combinations. It returns a single row of summary information for each group. Given three expressions (n=3) in the CUBE clause of the simple_grouping_clause, the operation results in 2n = 23 = 8 Extension of the GROUP BY clause that let you specify multiple groupings of data . Precisely specified groups. GROUPING SETS( (channel_desc, calendar_month_desc, co.country_id), (channel_desc, co.country_id) ); Distinguishes superaggregate rows from regular grouped rows. Return Number. 1 si es nulo, 0 para valor. DECODE(GROUPING(department_name), 1, 'All Departments', department_name) Returns a number corresponding to the GROUPING bit vector associated with a row. SELECT channel_id, promo_id, sum(amount_sold) s_sales, GROUPING(channel_id) gc, - System privileges to users and roles. - Roles to users and roles - Object privileges for a particular object to users, roles, and PUBLIC. You can grant an Oracle Database predefined role or a user-defined role GRANT dw_manager TO sh WITH ADMIN OPTION; Specify WITH GRANT OPTION to enable the grantee to grant the object privileges to other users and roles. GRANT UPDATE ON employees TO oe WITH GRANT OPTION; USER_RECYCLEBIN data dictionary review USER TABLES all tables with their name, number of columns, storage information, statistical information etc. (TABS) USER CATALOG tables, views, and synonyms (CAT) USER_UNUSED_COL_TABS You can view all tables with columns marked UNUSED USER COL COMMENTS comments on columns USER CONSTRAINTS constraint definitions for tables USER INDEXES all information about indexes created for tables (IND) USER OBJECTS all database objects owned by the user (OBJ) USER TAB COLUMNS columns of the tables and views owned by the user (COLS) USER TAB COMMENTS comments on tables and views USER TRIGGERS triggers defined by the user USER USERS information about the current user USER VIEWS views defined by the user ALL CATALOG owner, name and type of all accessible tables, views, and synonyms ALL TABLES owner and name of all accessible tables ALL OBJECTS owner, type, and name of accessible database objects ALL TRIGGERS . . . ALL USERS . . . 2

ALL VIEWS . . . DBA TABLES DBA CATALOG DBA OBJECTS DBA DATA FILES DBA USERS DICTIONARY MULTITABLE INSERT

tables of all users in the database tables, views, and synonyms defined in the database object of all users information about data files information about all users known in the database contains descriptions of data dictionary tables and views.

INSERT ALL

INSERT ALL INTO sales (prod_id, cust_id, time_id, amount) VALUES (product_id, customer_id, weekly_start_date, sales_sun) INTO sales (prod_id, cust_id, time_id, amount) VALUES (product_id, customer_id, weekly_start_date+1, sales_mon) SELECT product_id, customer_id, weekly_start_date, sales_sun, sales_mon, sales_tue, sales_wed, sales_thu, sales_fri, sales_sat FROM sales_input_table; INSERT ALL WHEN order_total < 1000000 THEN INTO small_orders WHEN order_total > 1000000 AND order_total < 2000000 THEN INTO medium_orders WHEN order_total > 2000000 THEN INTO large_orders SELECT order_id, order_total, sales_rep_id, customer_id FROM orders; INSERT ALL WHEN order_total < 100000 THEN INTO small_orders WHEN order_total > 100000 AND order_total < 200000 THEN INTO medium_orders ELSE INTO large_orders SELECT order_id, order_total, sales_rep_id, customer_id FROM orders; MERGE INTO bonuses D USING (SELECT employee_id, salary, department_id FROM employees WHERE department_id = 80) S ON (D.employee_id = S.employee_id) WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01 DELETE WHERE (S.salary > 8000) WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus) VALUES (S.employee_id, S.salary*0.1) WHERE (S.salary <= 8000);
Solo en select. Puede tener mas de un query. WITH subquery_name AS (the aggregation SQL statement) SELECT (query naming subquery_name);

MERGE

WITH (CALLED SUBQUERY FACTORING)

WITH sum_sales AS ( select /*+ materialize */ sum(quantity) all_sales from stores ),number_stores AS ( select /*+ materialize */ count(*) nbr_stores from stores ),sales_by_store AS ( select /*+ materialize */ store_name, sum(quantity) store_sales from store natural join sales ) SELECT store_name FROM store, sum_sales, number_stores, sales_by_store where store_sales > (all_sales / nbr_stores);

EXTRACT (DATETIME) SET UNUSED CLAUSE EXTERNAL TABLE

MULTISET

SELECT EXTRACT(month FROM order_date) Month FROM orders ; SELECT EXTRACT(YEAR FROM DATE '1998-03-07') FROM DUAL; En Alter Table, marca la columna para no ser usado. Despues de marca no se puede acceder a los datos, no sale en describe, se puede crear columna con el mismo nombre de la marcada. You can add, drop, or modify the columns of an external table. you cannot Add a LONG, LOB, or object type column or change the datatype of an external table column to any of these datatypes. - Add a constraint to an external table. - Modify the storage parameters of an external table. - Specify the logging_clause. - Specify MOVE. Combine the results of two nested tables into a single nested table.
CREATE TABLE customers_demo AS SELECT * FROM customers; CREATE TYPE cust_address_tab_typ AS TABLE OF cust_address_typ ALTER TABLE customers_demo ADD (cust_address_ntab cust_address_tab_typ, cust_address2_ntab cust_address_tab_typ) NESTED TABLE cust_address_ntab STORE AS cust_address_ntab_store NESTED TABLE cust_address2_ntab STORE AS cust_address2_ntab_store;

ANY

ALL

Compara con cualquier registro de la consulta. La instruccin es vlida si hay un registro en la subconsulta que permite que la comparacin sea cierta. SELECT * FROM employees WHERE salary = ANY (SELECT salary FROM employees WHERE department_id = 30); Compara con todos los registros de la consulta. La instruccin resulta cierta si es cierta toda comparacin con los registros de la subconsulta. SELECT * FROM employees WHERE salary >= ALL ( 1400, 3000);

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