Monday, October 25, 2010

Oracle :CONSTRAINTS

CONSTRAINTS
12. What is an Integrity Constraint ?
Integrity constraint is a rule that restricts values to a column in a table.
13. What is Referential Integrity ?
Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the referenced table.
14. What are the usage of SAVEPOINTS ?
SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.
15. What is ON DELETE CASCADE ?
When ON DELETE CASCADE is specified ORACLE maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or unique key value is removed.
16. What are the data types allowed in a table ?
CHAR,VARCHAR2,NUMBER,DATE,RAW,LONG and LONG RAW.
17. What is difference between CHAR and VARCHAR2 ? What is the maximum SIZE allowed for each type ?
CHAR pads blank spaces to the maximum length. VARCHAR2 does not pad blank spaces. For CHAR it is 255 and 2000 for VARCHAR2.
18. How many LONG columns are allowed in a table ? Is it possible to use LONG columns in WHERE clause or ORDER BY ?
Only one LONG columns is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.
19. What are the pre requisites ?
To modify datatype of a column. To add a column with NOT NULL constraint. To Modify the datatype of a column the column must be empty. to add a column with NOT NULL constrain, the table must be empty.
20. Where the integrity constrints are stored in Data Dictionary ?
The integrity constraints are stored in USER_CONSTRAINTS.
21. How will you a activate/deactivate integrity constraints ?
The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE constraint/DISABLE constraint.
22. If an unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE ?
It won't, Because SYSDATE format contains time attached with it.
23. What is a database link ?
Database Link is a named path through which a remote database can be accessed.
24. How to access the current value and next value from a sequence ? Is it possible to access the current value in a session before accessing next value ?
Sequence name CURRVAL, Sequence name NEXTVAL. It is not possible. Only if you access next value in the session, current value can be accessed.
25. What is CYCLE/NO CYCLE in a Sequence ?
CYCLE specifies that the sequence continues to generate values after reaching either maximum or minimum value. After pan ascending sequence reaches its maximum value, it generates its minimum value. After a descending sequence reaches its minimum, it generates its maximum. NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or minimum value.
26. What are the advantages of VIEW ?
To protect some of the columns of a table from other users. To hide complexity of a query. To hide complexity of calculations.
27. Can a view be updated/inserted/deleted? If Yes under what conditions ?
A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from one or more tables then insert, update and delete is not possible.
28.If a View on a single base table is manipulated will the changes be reflected on the base table ?
If changes are made to the tables which are base tables of a view will the changes be reference on the view.

1 comments:

Xicron Solution said...

http://xicrontechnology.blogspot.com/

Post a Comment