Some Basic questions

1. What is an integrity constraint?
Ans: Integrity constraint is a rule that restricts values to a column in a table. More precisely these are ways to validate data as per the business standard before writing to the database.

2. What is referential integrity constraint?
Ans: 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.

3. What is the usage of SAVEPOINTS?
Ans: 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. It can be created using SAVEPOINT <savepoint name>. All savepoints are cleared once commit is performed.

Ans: 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.

5. What are the data types allowed in a table?

6. What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each type?
Ans:  CHAR pads blank spaces to the maximum length. VARCHAR2 does not pad blank spaces. For CHAR the maximum length is 255 and 4000 for VARCHAR2. Starting Oracle 12c, maximum length of VARCHAR2 datatype is 32767

7. How many LONG columns are allowed in a table? Is it possible to use LONG columns in WHERE clause or ORDER BY?
Ans: Only one LONG column is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.

8. What are the pre-requisites to modify datatype of a column and to add a column with NOT NULL constraint?
Ans:     – 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.

9. Where the integrity constraints are stored in data dictionary?
Ans: The integrity constraints are stored in USER_CONSTRAINTS.

10. How will you activate/deactivate integrity constraints?
Ans: The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE CONSTRAINT / DISABLE CONSTRAINT.

11. If unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE?
Ans: It won’t, Because SYSDATE format contains time attached with it.

12. What is a database link?
Ans: Database link is a named path through which a remote database can be accessed.

13. 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?
Ans: Sequence name CURRVAL, sequence name NEXTVAL. It is not possible. Only if you access next value in the session, current value can be accessed.

14. What is CYCLE/NO CYCLE in a Sequence?
Ans: CYCLE specifies that the sequence continue 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.

15. What are the advantages of VIEW?
Ans:  – To protect some of the columns of a table from other users.
– To hide complexity of a query.
– To hide complexity of calculations.
– Inline view can be used to form intermittent data set which can further be selected from

16. Can a view be updated/inserted/deleted? If Yes – under what conditions?
Ans: 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 to all the table. DMLs can only be performed on Key-preserved table and not all the base tables.

17. If a view on a single base table is manipulated will the changes be reflected on the base table?
Ans: Yes. If changes are made to the tables and these tables are the base tables of a view, then the changes will be reference on the view. DMLs performed on such views will be reflected in the base table also.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s