Oracle 面试宝典 - 7

1. What is a CO-RELATED SUBQUERY

A CO-RELATED SUBQUERY is one that has a correlation name as table or view designator in the FROM clause of the outer query and the same correlation name as a qualifier of a search condition in the WHERE clause of the subquery. eg

    SELECT  field1 from table1 X
    WHERE  field2>(select avg(field2) from table1 Y
                                      where
                                      field1=X.field1);

(The subquery in a correlated subquery is revaluated for every row of the table or view named in the outer query.)

2. What are various joins used while writing SUBQUERIES

Self join-Its a join foreign key of a table references the same table.

Outer Join--Its a join condition used where One can query all the rows of one of the tables in the join condition even though they don‘t satisfy the join condition.

Equi-join--Its a join condition that retrieves rows from one or more tables in which one or more columns in one table are equal to one or more columns in the second table.

3. What are various constraints used in SQL

NULL NOT NULL CHECK DEFAULT

4. What are different Oracle database objects

TABLES VIEWS INDEXES SYNONYMS SEQUENCES TABLESPACES etc

5. What is difference between Rename and Alias

Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column which do not exist once the SQL statement is executed.

6. What is a view

A view is stored procedure based on one or more tables, its a virtual table.

7. What are various privileges that a user can grant to another user

SELECT CONNECT RESOURCE

8. What is difference between UNIQUE and PRIMARY KEY constraints

A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.

9. Can a primary key contain more than one columns

Yes

10. How you will avoid duplicating records in a query

By using DISTINCT

11. What is difference between SQL and SQL*PLUS

SQL*PLUS is a command line tool where as SQL and PL/SQL language interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an Oracle database. SQL is a language used to query the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, Edit SQL commands and PL/SQL.

12. Which datatype is used for storing graphics and images

LONG RAW data type is used for storing BLOB‘s (binary large objects).

13. How will you delete duplicating rows from a base table

DELETE FROM table_name A WHERE rowid>(SELECT min(rowid) from table_name B where B.table_no=A.table_no);

CREATE TABLE new_table AS SELECT DISTINCT * FROM old_table;

DROP old_table RENAME new_table TO old_table DELETE FROM table_name A WHERE rowid NOT IN (SELECT MAX(ROWID) FROM table_name GROUP BY column_name)

14. What is difference between SUBSTR and INSTR

SUBSTR returns a specified portion of a string eg SUBSTR(‘BCDEF‘,4) output BCDE INSTR provides character position in which a pattern is found in a string.

eg INSTR(‘ABC-DC-F‘,‘-‘,2) output 7 (2nd occurence of ‘-‘)

15. There is a string ‘120000 12 0 .125‘ ,how you will find the position of the decimal place

INSTR(‘120000 12 0 .125‘,‘.‘,1) output 13

16. There is a ‘%‘ sign in one field of a column. What will be the query to find it.

‘\‘ Should be used before ‘%‘.

17. When you use WHERE clause and when you use HAVING clause

HAVING clause is used when you want to specify a condition for a group function and it is written after GROUP BY clause The WHERE clause is used when you want to specify a condition for columns, single row functions except group functions and it is written before GROUP BY clause if it is used.

18. Which is more faster - IN or EXISTS

EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value.

Appropriate answer will be....

Result of the subquery is small Then "IN" is typicaly more appropriate. and Result of the subquery is big/large/long Then "EXIST" is more appropriate.

19. What is a OUTER JOIN

Outer Join--Its a join condition used where you can query all the rows of one of the tables in the join condition even though they dont satisfy the join condition.

20. How you will avoid your query from using indexes

SELECT * FROM emp Where emp_no+‘ ‘=12345;

i.e you have to concatenate the column name with space within codes in the where condition.

SELECT /*+ FULL(a) */ ename, emp_no from emp where emp_no=1234;

i.e using HINTS

From:http://www.orafaq.com/wiki/Interview_Questions

时间: 2024-08-30 09:41:37

Oracle 面试宝典 - 7的相关文章

Oracle 面试宝典 - 3

1. Describe the difference between a procedure, function and anonymous pl/sql block.  Candidate should mention use of DECLARE statement, a function must return a value while a procedure doesn't have to. 2. What is a mutating table error and how can y

Oracle 面试宝典 - 1

1. Explain the difference between a hot backup and a cold backup and the benefits associated with each. A hot backup is basically taking a backup of the database while it is still up and running and it must be in archive log mode. A cold backup is ta

Oracle 面试宝典 - 5

1. Give one method for transferring a table from one schema to another: There are several possible methods, export-import, CREATE TABLE... AS SELECT, or COPY. 2. What is the purpose of the IMPORT option IGNORE? What is it?s default setting The IMPORT

Oracle 面试宝典 - 2

1. How would you determine the time zone under which a database was operating? SELECT dbtimezone FROM DUAL; 2. Explain the use of setting GLOBAL_NAMES equal to TRUE. It ensure the use of consistent naming conventions for databases and links in a netw

Oracle 面试宝典 - 6

1. How can variables be passed to a SQL routine By use of the & symbol. For passing in variables the numbers 1-8 can be used (&1, &2,...,&8) to pass the values after the command into the SQLPLUS session. To be prompted for a specific varia

Oracle 面试宝典 - 4

1. A tablespace has a table with 30 extents in it. Is this bad? Why or why not. Multiple extents in and of themselves aren?t bad. However if you also have chained rows this can hurt performance. 2. How do you set up tablespaces during an Oracle insta

Oracle 面试宝典 - 8

1. What is a pseudo column. Give some examples It is a column that is not an actual column in the table. eg USER, UID, SYSDATE, ROWNUM, ROWID, NULL, AND LEVEL. Suppose customer table is there having different columns like customer no, payments.What w

Oracle 面试宝典 - General Questions

转自 http://www.orafaq.com/wiki/Interview_Questions Tell us about yourself/ your background. What are the three major characteristics that you bring to the job market? What motivates you to do a good job? What two or three things are most important to

Java面试宝典2013版(超长版)

一. Java基础部分......................................................................................................2 1.一个".java"源文件里能否够包含多个类(不是内部类)?有什么限制?.....2 2.Java有没有goto?........................................................................