Sei sulla pagina 1di 3

1.

Constraint - rules to restrict value of the db


type - Not Null constraint - prohibits the column containing null values
- Unique constraint - no to rows of a column can have same value
however it may contain nulls
- Primary Key Constraint - conbimes a NOT NULL and UNIQUE constraint in
one declaration
- Foreign Key / referential integrity Constraint - a column is
designated as foreign key and establishes a relationship between that foreign key
and a specified primary key or unique key. The tabke having the primary key is
parent table and table woth foreign key is the child table.
- On delete clause - if the record in the parent table is
delete corresponding child record will also be deleted
- On delete restrict - to ensure that a parent row is not
delete while child already exists
- Check constraint - lets you specify a conndition for each row in the
table must satisfy.

Oracle Database does not support constraints on columns or attributes whose type is
a user-defined object, nested table, VARRAY, REF, or LOB

2. NOVALIDATE is the option used with check constraint which doesn't check for
previous inserted values in the table.
ALTER TABLE test2 ADD ( CONSTRAINT a CHECK ( a <= 5 ) NOVALIDATE );

3. Truncate vs Delete
DDL
- DML
Fast (data doesn't move into redo log buffer) - Slow (data
move to redo log buffer)
doesn't support where clause
- does support where clause
table level or page level lock
- row level lock
Lowers the table High Water Marks
- Doesn't

4. no null values will appear


5. if left table contains a null value than it appears else no null value will
appear

6. Handling Exceptions or error situations in a program


type - System Exceptions
- User/Programmer defined excepions

7. EXCEPTION_INIT - binds a user defined exception with a integer value

8. A bind variable is a placeholder in SQL statement that must be replaced with a


valid value or value address for the statement to execute successfully.

9. Aggreate function - many rows, collapse them into one. sum(), count(), max(),
min(), avg()
Analytical function - function is to analyze the data. They compute aggreate
values based on a group of rows. first_value. last_value
10. Hard parsing - Loading the data into shared pool
Soft parsing - Doesn't require loading of data into shared pool

- Syntax Parsing - Oracle parses the syntax to check for


misspelled SQL keywords.
- Semantic parsing - Oracle verifies all table & column names from
the dictionary and checks to see if you are authorized to see the data.
- Query transformation - Oracle will transform complex SQL into
simpler, equivalent forms and replace aggregations with materialized views, as
appropriate.
- Optimization - Oracle then creates an execution plan, based on
your schema statistics
- create executables - Oracle builds an executable file with
native file calls to service the SQL query.
- fetch rows - Oracle then executes the native calls to the data
files to retrieve the rows and passes them back to the calling program

12. Nested Loop and hash Loop are joining methods in oracle. If there are multiple
tables in the query, after the optimizer determines the access methods most
appropriate for each of the tables, the next step is to deterined the way tables
best be joined together and proper order in which to join them.

Nested Loops Join - as name implies a loop inside a loop. The outer most table is
the driving table which passes rows to inner table based on -1. the join conditions
provided in the query and
-2. the rows confirms to match with the inner query.
These kind of join are robust and acquires very less memory.
The primary measurement for nested loops is the no of blocks accesses required.
helpful -

Hash Joins - Based on table and index statistics, the table that is determined to
return the fewest rows will be hashed in the entirety memory.
Other larger table is read and hash function is applied to the join key column.That
hash value is then used to probe the smaller in memory hash table for the matching
hash bucket where the row data of the first table resides. if match is made the row
is returned else discarded.
helpful - Hash joins are considered more preferable when the row sources are larger
and the result set is larger as well
- if the smaller table can fit in memory, a hash join may be favoured
- Hash joins are only possible if the joins is an equi-join

Sort-merge Join - as the name suggest the table are first sorted individually and
then merged together.
helpful -
Sort-merge joins are typically best suited to queries that have limited data
filtering and return lots of rows.
They are also often a better choice if there are no suitable indexes that can be
used to access the data more directly.
A sort-merge join can be used to handle joins specified with an inequality
condition

Catesian Join - Joining every row of a table with every row of other table.

21. A collection is a data structure that acts like a list or a single-dimensional


array.
37. A record is a composite data structure, which means that it is composed of more
than one elements and component, each with it own value.
Table-based record
Declare
one_book books%rowtype;
Cursor-based record
Declare
Cursor cur is select * from books where author like %sh%;
one_book cur%rowtyep;
Programmer-define record
Declare
TYPE REC is RECORD (
author books.author%type,
category varchar2(10),
tol_pages Number );

my_rec REC;

Potrebbero piacerti anche