Showing posts with label PLSQL. Show all posts
Showing posts with label PLSQL. Show all posts

Tuesday, May 24, 2022

Employee who work on concepts of Oracle is called

In software industry , mostly the employees who work on oracle concepts can be classified into two roles. They are Oracle database developers, oracle database administrators. 

Developers use the programming concepts such as SQL , PLSQL and write the programs to process the business logic. They develop the applications to store , retrieve, manipulate the data.   

Administrators use the database administration concepts to manage the database such as user accounts creation, giving roles/privilege's , backups , recovery, export and import of data, fine tuning the database for performances, patching the database with the latest versions, upgradations, migrations etc. 

Query to find the third highest salary

Normally this question is asked check the analytical skills . This is the most commonly asked question the interviews. 


select * from( select ename, sal, dense_rank() over(order by sal desc)r from Employee) where r=3;



Wednesday, August 9, 2017

NIIT SQL/PLSQL Interview Questions

  1. Explain about Oracle Architecture?
  2. What happens when query is executed?Explain.
  3. What is library cache,Data Dictionary?
  4. What is Result Cache?What is deterministic?
  5. What is collection. Have u declared constructor in collections? Which collection have u used?
  6. What is Multiset operator?
  7. How to find lock on table?
  8. If application is working slow. what are the issues? (Data volume is not changed,No network issues).
  9. What is explain plan. How do u read explain plan. What informtion does it show?
  10. What is statistics.
  11. If we create a new table say emp, no statistics is generated, no records are inserted than
  12. whether explain plan will be generated?
  13. What are anyalytical function? LAG,LEAD?
  14. What is overloading? Can procedure be overloaded?
  15. What is pragma Autonomous Transaction?
  16. What is Trigger.Can we commit in trigger? Compound Trigger?
  17. Can we commit in compound triggers?
  18. Can function be called from Trigger?
  19. Information about syntax check in library cache is obtained from?
  20. Information about symantic check in library cache is obtained from?
  21. What is Soft parse,Hard parse?
  22. A table has record with value 20. updating the value as 30, what information would be in undo segment and what in redo logs.
  23. What is the minimum no of redo logs required?
  24. Whether Archiver process is necessary?

Friday, April 14, 2017

Genpact PLSQL/SQL Interview Questions

Tell about your experience and your skills.
SQL Loader how it is used.
when External tables are used.
Difference between external tables and SQL loader.
Can i have the same name for a procudure and function? Explain the reason.
What is bitmap index.
is view updatable.
How to make view non updatable.
What are the conditions in which view is not  updatable.
What is materializabe view, In  which scenario will you use materializable view.
What is instead of trigger.
How do you generated 1 to 9 numbers.
I have a table with values in a column from 1 to 9. I want to show all the values from 1 to 9 in a single one column of a row.
There is a name called 'ALEXANDER'. How do u find the count of A in that name.
From the above question find the count of a with out using regular expression.
What is the difference between RANK and DENSE_RANK.
I have  a histroy table , where it will have the history of the rates daily. I want to keep the data for 90 days and from 91 onwards no need to keep in the table. How will you desing a table.
What is the cost in SQL Explain Plan.
What other things you look while checking the SQL plan.
If the plan Cost is low , does that mean the sql query is faster. Explain .

Tuesday, April 4, 2017

Fidelity Interview Questions

Screening test on call:
What is AWR and ADDM
What is ASH
What is Explain Plan
What are events in oracle
What Bulk collect
What is cursor
What is refcursor


First Round - Face to Face :
What is Collection . Types of Collections in PLSQL? 
Write the syntax of Associative Array.
When should we use Associative array , nested tables?
What is Ref cursor. Can it be passed as parameter in SP and functions? 
Type of ref cursors?
What is explicit Cursor. How to find that data in the cursor is not available.
Query to fetch all the columns of the of highest paying departments.
What is TKPROF ? How to enable the SQL Trace.  Write the statement enable tracing.
On setting the SQL Trace parameter, where does this parameters value is stored in database.
What information are there in TKPROF.
What is normalization. Explain 1st NF,2nd NF, 3rd NF with examples.

Sunday, October 16, 2016

When Compiler Catches Overloading Errors

When Compiler Catches Overloading Errors

I have a procedure INITIALIZE which accepts CHAR as IN parameter , another procedure INITIALIZE accepts VARCHAR2 as IN parameter, Now I'm calling INITIALIZE procedure with IN parameter value as 'AB'. Which procedure will execute?

In fact , the compiler throws PLS-00307: too many declarations of 'INITIALIZE' match this call. See the below demonstration .


Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 
Connected as HR@ORCL
SQL> 
SQL> DECLARE
  2    PROCEDURE initialize ( in_val CHAR) IS
  3    BEGIN
  4    dbms_output.put_line('CHAR data type '||in_val);
  5    END initialize;
  6  
  7    PROCEDURE initialize ( in_val VARCHAR2) IS
  8    BEGIN
  9    dbms_output.put_line('VARCHAR2 data type '||in_val);
 10    END initialize;
 11  
 12  BEGIN
 13    initialize('AB');
 14  END;
 15  
 16  /
DECLARE
  PROCEDURE initialize ( in_val CHAR) IS
  BEGIN
  dbms_output.put_line('CHAR data type '||in_val);
  END initialize;

  PROCEDURE initialize ( in_val VARCHAR2) IS
  BEGIN
  dbms_output.put_line('VARCHAR2 data type '||in_val);
  END initialize;

BEGIN
  initialize('AB');
END;
ORA-06550: line 13, column 3:
PLS-00307: too many declarations of 'INITIALIZE' match this call
ORA-06550: line 13, column 3:
PL/SQL: Statement ignored


The above procedure program throws error PLS-00307, because :

"The PL/SQL compiler catches overloading errors as soon as it can determine that it will be unable to tell which subprogram was invoked. When subprograms have identical headings, the compiler catches the overloading error when you try to compile the subprograms themselves (if they are local) or when you try to compile the package specification that declares them (if they are packaged); otherwise, it catches the error when you try to compile an ambiguous invocation of a subprogram."

Let's correct the above program by changing the synonymous procedures to different procedures, i m changing the CHAR datatype to NUMBER in the first procedure. 

The anonymous block compiles successfully and executes.


SQL> DECLARE
  2    PROCEDURE initialize ( in_val NUMBER) IS
  3    BEGIN
  4    dbms_output.put_line('NUMBER data type '||in_val);
  5    END initialize;
  6  
  7    PROCEDURE initialize ( in_val VARCHAR2) IS
  8    BEGIN
  9    dbms_output.put_line('VARCHAR2 data type '||in_val);
 10    END initialize;
 11  
 12  BEGIN
 13    initialize('AB');
 14  END;
 15  /
VARCHAR2 data type AB
PL/SQL procedure successfully completed

Saturday, October 15, 2016

Invalid objects in Oracle Database

Invalid Objects in Oracle Database :

We always wonder why there are invalids in my schema/database. What has been changed/caused to increase invalids.The reason could be , there is a change in the dependent objects structure. There could be a change in the package which has many referencing/dependent objects.Or there are some errors in your   package/ procedure/ functions by which objects become invalid.

Generally, these invalids are most common in the development database, development would be done my many developers and they would be doing changes to may of the objects which cause invalids. Also in the database where there is a major upgrade or patch deployed, in production databases where there is release happened.

How do I deal with these? Here is what i generally do , when i find invalids.

Find number of the invalid objects:
SELECT COUNT(*) FROM All_Objects WHERE STATUS = 'INVALID';
Find what all objects are invalid :
SELECT * FROM All_Objects WHERE STATUS='INVALID';
To check what object got changed recently:
SELECT * FROM All_Objects ORDER BY last_ddl_time DESC;
with above the query you will get the recently changed objects.
To check the dependent objects of an object:
SELECT * FROM All_Dependencies WHERE NAME ='MOVE_DATA';
To check for the objects with errors:
SELECT * FROM All_Errors;
ALTER ... COMPILE
when you now the objects with errors, the most important thing is resolve them. The dependent object will get compiled only when the referencing object is in valid status.

How to compile an individual/single object manually:
ALTER PACKAGE my_package COMPILE;
ALTER PACKAGE my_package COMPILE BODY;
ALTER PROCEDURE my_procedure COMPILE;
ALTER FUNCTION my_function COMPILE;
ALTER TRIGGER my_trigger COMPILE;
ALTER VIEW my_view COMPILE;
DBMS_UTILITY
I have a huge number of invalid objects in my schema, How do I compile ?
EXEC DBMS_UTILITY.COMPILE_SCHEMA(schema => 'HR',compile_all => FALSE);
compile_all parameter :when false, compiles only invalid objects in a schema; when true, compiles the entire schema.

UTL_RECOMP
An alternative way of compiling objects in a schema level, database level.

Schema Level
EXEC UTL_RECOMP.recomp_serial('HR');
EXEC UTL_RECOMP.recomp_parallel(8, 'HR');

Database Level
EXEC UTL_RECOMP.recomp_serial();
EXEC UTL_RECOMP.recomp_parallel(8);

RECOMP_SERIAL : Compile one by one object.
RECOMP_PARALLEL :Recompile all objects using  parallel threads.

Operational Notes as defined in documentation : https://docs.oracle.com/cd/B28359_01/appdev.111/b28419/u_recomp.htm

This package uses the job queue for parallel recompilation.
This package must be run using SQL*PLUS.
You must be connected AS SYSDBA to run this script.
This package expects the following packages to have been created with VALID status:
STANDARD (standard.sql)
DBMS_STANDARD (dbmsstdx.sql)
DBMS_JOB (dbmsjob.sql)
DBMS_RANDOM (dbmsrand.sql)
There should be no other DDL on the database while running entries in this package. Not following this recommendation may lead to deadlocks.

Tuesday, October 4, 2016

Oracle PLSQL - Difference Between Parameter Modes


Parameter Modes  in PLSQL procedures and functions are IN , OUT, IN OUT. The differences are as follows.


Sunday, September 25, 2016

Oracle PLSQL - Advantages of Using Packages

Advantages of Using Packages

Packages provide an alternative to creating procedures and functions as stand-alone
schema objects, and they offer several benefits.

Modularity and ease of maintenance: You encapsulate logically related programming
structures in a named module. Each package is easy to understand, and the interface
between packages is simple, clear, and well defined.

Easier application design: All you need initially is the interface information in the
package specification. You can code and compile a specification without its body. Then
stored subprograms that reference the package can compile as well. You need not define
the package body fully until you are ready to complete the application.

Hiding information: You decide which constructs are public (visible and accessible) and
which are private (hidden and inaccessible). Declarations in the package specification are
visible and accessible to applications. The package body hides the definition of the private
constructs, so that only the package is affected (not your application or any calling
programs) if the definition changes. This enables you to change the implementation
without having to recompile the calling programs. Also, by hiding implementation details
from users, you protect the integrity of the package.

Added functionality: Packaged public variables and cursors persist for the duration of a
session. Thus, they can be shared by all subprograms that execute in the environment.
They also enable you to maintain data across transactions without having to store it in the
database. Private constructs also persist for the duration of the session but can be accessed
only within the package.

Better performance: When you call a packaged subprogram the first time, the entire
package is loaded into memory. Later calls to related subprograms in the package
therefore require no further disk I/O. Packaged subprograms also stop cascading
dependencies and thus avoid unnecessary compilation.

Overloading: With packages, you can overload procedures and functions, which means
you can create multiple subprograms with the same name in the same package, each taking
parameters of different number or data type.

Friday, August 12, 2016

Cap Gemini -PLSQL interview questions




Capgemini 2nd round


Table A:has col1 with values(a,b,c). Table B -col1 with values (b,c,c,d).
Table A:has col1 with values(a,b,c,null). Table B -col1 with values (b,c,c,d,null).
Queries on union , unionall, interset, minus, data sets include null values.
queries on equijoin, self join, outer joins.
queries in corelated subqueires, sub queries.
queries in not in and not exists. which is faster. is there any differene in the output with the above 2nd dataset
top 10 salaried employees from employee table.
how to eliminate duplicates.
What are constraints. why are they used.
A database in 10g is completely migrated to database in 11g. How will u verify the new database has everything properly.
queries on decode, case.
What is select null+1 from dual
Explain Plan , what do u look for in explain plan
What are hits. Tell me the hints you know.
I have an sql query, It has lot of joins in it. While querying , i got an error, temp space full. How do u overcome this error.
what is looping chain of synonyms.
How bulk collect and forall works.
How do u optimize an sql query.

CapGemini - PLSQL Interview Questions




Capgemini 1st round


Tell me about yourself
what are packages
what is explain plan
i have an sql statement which is well written, bit still very slow in fetching the data.
how do u read an awr report
by default what degree of parallalism will be used
explain bulk collect and forall
what it limit
how do u determine the limit of a bulk collect fetch.
how can i use commit in a trigger.
what are different types of triggers.

Featured Post

Will the data from Oracle Database be lost after formatting the system in which it is installed?

So Someone asked me a question,  Will the data from Oracle Database be lost after formatting the system in which it is installed? Since the ...

Popular Posts