Interview

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

ORACLE INTERVIEW QUESTIONS

1)What are the different types of statements we have? Explain? A) We are having 5 types of statements..those are 1. Data Definition Language(DDL)- Create,Alter,Rename,Drop,Truncate. 2. Data Retrieved Language(DRL)-Select 3. Data Manipulation Language(DML)-Insert,Delete,Update,Merge 4. Transaction Control Language(TCL)-Commit,Rollback,Savepoint 5. Data Control Language(DCL)-Grant,Revoke. 2) What are the diff. b/w char and varchar2? Explain with example? A) CHAR: Max 2000 Characters VARCHAR2: Max 4000 Characters Fixed Length. Variable Length. EX: ename char(10); Ex: ename varchar2(10); SIVA SIVA RAMANA RAMANA SQL> Select length(ename) from emp; SQL>Select length(ename) from emp; O/p: 10 10 O/P: 4 6 (Char depends upon size we mentioned) (Varchar2 depends upon string we entered.) 3) What is the diff. b/w Commit and Rollback? A) Commit: If we do commit after some transaction all the transactions are perminently effected in the database. Rollback: If we do commit after some transaction all the transactions are not done without saving in the database. 4) What is the diff. b/w delete and drop? A) Delete: The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. Note that this operation will cause all DELETE triggers on the table to fire. Example: SQL> SELECT COUNT(*) FROM emp; COUNT(*) ---------14 SQL> DELETE FROM emp WHERE job = 'CLERK'; 4 rows deleted.

SQL> COMMIT; Commit complete. SQL> SELECT COUNT(*) FROM emp; COUNT(*) ----------10 DROP: The DROP command removes a table from the database. All the tables' rows, indexes and privileges will also be removed. No DML triggers will be fired. The operation cannot be rolled back. Example: SQL> DROP TABLE emp; Table dropped. SQL> SELECT * FROM emp; SELECT * FROM emp * ERROR at line 1: ORA-00942: table or view does not exist 5) what is the diff. b/w delete and truncate? A)DELETE:It will delete rows from the table but it won t delete storage space occupied by the data. It will raise the triggers. TRUNCATE: It will delete rows from the table as well as it will delete storage space occupied by the data. It won t raise the triggers.
Example: SQL> TRUNCATE TABLE emp; Table truncated. SQL> SELECT COUNT(*) FROM emp; COUNT(*) ---------0

6)what is the diff. b/w truncate and drop? A) Truncate: truncate removes rows from table but the structure of table remains as it is and it cannot be rollbacked. Drop: Drop can be used to drop the entire table including data and structure of table.But it cannot be rollbacked.

DELETE,DROP AND TRUNCATE: Command Table structure deleted DROP Y TRUNCATE N DELETE N Records deleted NA Y-all records Y-selectively Auto-commit Y Y N

7)What is the difference b/w DML AND DDL Statements? A) Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples: CREATE - to create objects in the database ALTER - alters the structure of the database DROP - delete objects from the database TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed o RENAME - rename an object
o o o o

Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:
o o o o o

SELECT - retrieve data from the a database INSERT - insert data into a table UPDATE - updates existing data within a table DELETE - deletes all records from a table, the space for the records remain MERGE - UPSERT operation (insert or update) . Even though select is not exactly a DML language command oracle still recommends you to consider SELECT as an DML command.

8) what is the USER? A) users who can assume the identity of other users. Syntax: CREATE USER <user_name> IDENTIFIED BY "<password>" 9) On which statement I can give permissions to other users? A) Data Control Language(DCL)- Grant, Revoke.

10)What is the output for select empno,1,2 from emp? A) EMPNO 1 2

--------- ---------- ---------1 2 1 1 2 2

11) What is the output for select * from emp where 1=1? A) It will display the total emp table. 12) What is the output for select * from emp where 1=2? A) No Rows Returned. 13) I want to print empno,ename,sal in the single column.How you can do it? A) 14) I want to see the column name as Employee number instead of empno while retrieving? How you can do it? A) select empno as "employee-number",ename from emp1; 15)Extract the employee details whose salary is null? A) select * from emp where sal is null; 16) what is the dual table when you can use this one? A) dual is a table which is created by oracle along with the data dictionary. It consists of exactly one column whose name is dummy and one record. The value of that record is X
If your performing on operation which is no where related to table,we can use the Dual table. 17)

You might also like