Apps DBA Interview



 Oracle Apps DBA Interview Questions – I

1.  I am applying a patch, can I open another session and run adadmin?
Ans:  Yes, unless you are running a process where workers are involved

2.  I am applying a patch, can I open another session in another node and run adpatch?
Ans:  No

3.  Output & logfiles for requests executed on source instance not working on cloned instance?
Ans: Check whether apps listener is running

4.  What happens if you don’t give cache size while defining concurrent manager?
Ans: Most often when a request goes “inactive/no manager” and is then processed a short time later, the solution is to either increase the cache size for your Standard manger, or increase the actual number of Standard Manager processes that can run. Cache Size is set in the Concurrent/Manager/Define form. Basically, this regulates how many requests a manager will pick up for each sleep cycle.

5.  Why should Apps & Applsys passwords always be the same?
Ans: The need to have the same password for Apps and Applsys is because when you sign on to apps, intially it connects to a public schema called APPLSYSPUB. This validates AOL username and password that we enter (operations/welcome using guest user account. Once this is verified we select responsibility, this is validated by APPLSYS schema and then it connects to APPS schema.  Since it uses both applsys and apps during signon process this expects both the password to be identical. Try changing apps password to something else and try to login, the validation at the last stage would fail. This would result in failure of application login.
Apps is a universal schema has synonyms to all base product tables and sequences. This also has code objects for all products (triggers, views, packages, synonyms etc.).  Applsys schema has applications technology layer products like FND and AD etc.

6.  How to Complie Invalid Objects?
Ans: alter package <package_name> compile ;alter package <packae_ame> compile body;alter view <view_name> compile;
SQL>EXEC UTL_RECOMP.RECOMP_PARALLEL(4);
SQL>@$ORACLE_HOME/rdbms/admin/utlrp.sql

7.  Why DB-CM-ADMIN are always insatlled on the same machine in Oracle Applications in Multi Node Installation?
Ans: There is no restriction to install all of them on a single machine,but if we install them on 3 different machines then when we will run any AD utility on admin node or perform any upgradation it needs to access the database so there will be lot of overhead in accessing the database node on network so to avoid this overhead we install them on same machine. Similar is the case when we run any concurrent request on the CM node as Concurrent manager also updates the database objects.

8.  What URL you use to access Disco viewer & Disco plus.
Ans:  http://hostname.domain/discoverer4i/viewer
http://hostname.domainname:port/discoverer/viewer (10gAS)
http://hostname.domainname:http_port/discoverer/viewer ( R12)
http://hostname.domainname:port/discoverer/plus (10gAS)

9.  What is Yellow Bar Warning?
Ans: Oracle Applications Release 11.5.1 (11i) requires that its code run in a trusted mode, and uses J-Initiator to run Java applets on a desktop client. If an applet is “trusted,” however, Java will extend the privileges of the applet. The Yellow Warning Bar is a warning that your applet is not running in a trusted mode. To indicate that an applet is trusted, it must be digitally signed using a digital Certificate, so Oracle Applications requires that all Java archive files must be digitally signed.

10.  How to find if any service is listening on particular port or not?
Ans: netstat -an | grep {port no}

11.  How can u change the logfiles location suppose CM logfile location is APPLCSF
Ans: Change the Configuration File parameters change s_applcsf,s_appllog,s_applout variables in XML file and run the autoconfig.

12.  Conflict resolution managers resolves the conflicts yes , but hw it knows tht there are conficts?why conflicts occur?
Ans: Concurrent managers read request to start concurrent programs running. The Conflict Resolution Manager checks concurrent program definitions for incompatibility rules. If a program is identified as Run Alone, then the Conflict Resolution Manager prevents the concurrent managers from starting other programs in the same conflict domain.
When a program lists other programs as being incompatible with it, the Conflict Resolution Manager prevents the program from starting until any incompatible programs in the same domain have completed running.

13.  What is adovars.env file ?
Ans: The adovars.env file, located in $APPL_TOP/admin, specifies the location of variousfiles such as Java files, HTML files, and JRE (Java Runtime Environment) files. It is called from the main applications environment file.

14.  How to find the wordsize (32-bit or 64-bit) of Oracle Database
Ans: $cd $ORACLE_HOME/rdbms/bin
$file oracle

15.  How to Compile JSP’s without using ADADMIN
Ans:  perl -x $JTF_TOP/admin/scripts/ojspCompile.pl –compile

16.  What is wdbsvr.app file used for? What’s full path of this file? What’s significance of this file ?
Ans:  $IAS_ORACLE_HOME/Apache/modplsql/cfg
This file is used by mod_plsql component of Apache to connect to database. So when you type url http://hostname:port/pls/SID , whenever Apache(11i Web Server) finds that request is for /pls/ then Apache delegates this request to mod_pls component which in turn pick this file & check if there is any DAD with name SID

17.  Whats main concurrent Manager types.
Ans:  ICM – Internal Concurrent Manager which manages concurrent ManagersStandard Managers – Which Manage processesing of requests.
CRM – Conflict Resolution Managers , resolve conflicts in case of incompatibility.Transactions Managers – These managers are process for particler business Applications.Custom Concurrent Managers – The managers defined by the users.

18.  what are .rf9 files?
Ans:  These files are used during restart of patch in case of patch failure because of some reason.
Located in $APPL_TOP/admin/<SID>/restart this folder also contains .bak ,.bk2 filesSAMPLE FILE (adwork012.rf9)
%%% restart file format 11.5.A
Location: $APPL_TOP/admin/<SID>/log contains .req files

19.  Where is appsweb.cfg or appsweb_$CONTEXT.cfg stored & why its used?
Ans:  This file is defined by environment variable FORMS60_WEB_CONFIG_FILE This is usually in directory $OA_HTML/bin or $FNS_TOP/Resource on forms tier. This file is used by any forms client session. When a user try to access forms , f60webmx picks up this file and based on this configuration file creates a forms session to user/client.

20.  Can you clone from multi node system to single node system & vice versa?
Ans:  Yes, This is now supported via Rapid Clone

21.  Does rapid clone takes care of oraInventory after clone?
Ans:  Yes, Rapid Clone will automatically Update Global oraInventory during configuration phase.

22.  What is .dbc file , where its stored , whats use of .dbc file ?
Ans:  dbc file called as database connect descriptor file which stores database connection information used by application tier to connect to database.  This file is in directory $FND_TOP/secure also called as FND_SECURE

23.  What are the ways to reduce patch timing?
Ans:  Merging patches via admrgpch
Use various adpatch options like nocompiledb or nocompilejsp
Use defaults file
Staged APPL_TOP during upgrades
Increase batch size (Might result into negative )

24.  How you put Applications 11i in Maintenance mode?
Ans:  Use adadmin to change Maintenance mode is Oracle Apps. With AD.I you need to enable maintenance mode in order to apply apps patch via adpatch utility. If you don’t want to put apps in maintenance mode you can use adpatch options=hotpatch feature.
Also you can use the script $AD_TOP/patch/115/sql/ adsetmmd.sql

25.  What are various options available with adpatch?
Ans:  Various options available with adpatch depending on your AD version are autoconfig, check_exclusive, checkfile, compiledb, compilejsp, copyportion, databaseprtion,generateportion, hotpatch, integrity, maintainmrc, parallel, prereq, validate

26.  adident utility is used for what ?
Ans:  adident utility in oracle apps is used to find version of any file . AD Identification.
for ex. “adident Header <filename>

27.  What is adsplice utility?
Ans:  adsplice in oracle apps is utility to add a new product.

28.  How can you licence a product after installation?
Ans:  You can use ad utility adlicmgr to licence product in Oracle Apps.

29.  What is MRC? What you do as Apps DBA for MRC?
Ans:  MRC also called as Multiple Reporting Currency in oracle Apps. Default you have currency in US Dollars but if your organization operating books are in other currency then you as apps dba need to enable MRC in Apps. How to enable MRC coming soon…

30.  Whats is JVM(Java Virtual Machine) and which component uses JVM ?
Ans:  JVM stands for Java Virtual Machine, JVM acronym for Java Virtual Machine which executes instructions generated by Java compiler. So user click on any Self Service Request or any program which uses Java, then Apache forwards this request to mod_jserv (mod_oc4j in 10g AS) & mod_jserv caters this request with help of JVM.

Oracle Apps DBA Interview Questions – II

31.  Where to find Apps 11i JVM logs?
Ans:  JVM log location is defined in java.sh ( found in $IAS_ORACLE_HOME/Apache/Apache/bin) Oracle Apps 11i JVM log file directory is defined by parameter JVMLOGDIR ($IAS_ORACLE_HOME/Apache/Jserv/logs/jvm ) and log file are defined by STDOUTLOG & STDERRLOG. Example of JVM log files are OACoreGroup.0.stderr ,OACoreGroup.0.stdout, DiscoGroup.0.stdout, DiscoGroup.0.stderr,XmlSvcsGrp.0.stderr, XmlSvcsGrp.0.stdout where 0 denotes first JVM & 1 denotes second JVM. stderr records error encountered in JVM & stdout records other information like GC ..

32.  How to check JDBC Connection?
Ans:  select count(*),module from v$session where program like ‘%JDBC%’ group

33.  What is error_log in Apache,what entries are recored in access_log ? Where is default location of this file?
Ans:  Error_log will contain all the errors/warnings faced Apache web server in Oracle Apps 11i.  This file location is defined in httpd.conf with default location at $IAS_ORACLE_HOME/Apache/Apache/logs.

34.  What is access_log in apache , what entries are recored in access_log ? Where is default location of this file?
Ans:  access_log in Oracle Application Server records all users accessing oracle applications 11i.  This file location is defined in httpd.conf with default location at $IAS_ORACLE_HOME/Apache/Apache/logs.

35.  Where is Jserv configuration files stored?
Ans:  Jserv configuration files are stored in $IAS_ORACLE_HOME/Apache/Jserv/etc

36.  What are main configuration files in Web Server (Apache)?
Ans:  Main configuration files in Oracle Apps Web Server are
httpd.conf,
httpd_pls.conf,
jserv.conf,
jserv.properties,
zone.properties

37.  What is session time out parameter & where all you define these values?
Ans:  In Apps there are two broad categories of session
- Self Service Application Session ( Server by Web Server iAS Apache & Jserv, like iRecruitment,iProcurement)
- Forms session ( served by your form session, like system Administrator)
What is Session Idle time ?
If Oracle Apps client is not doing any activity for some time session during that time is called as Idle Session & because of security reason, performance issues and to free up system resource Oracle Applications terminates client session( both forms & self service) after idle time value is reached to the one mentioned in configuration file.
From FND.G or 11.5.9 or with introduction of AppsLocalLogin.jsp to enter into application, profile option “ICX Session Timeout” is used only to determine Forms Session Idle timeout value .
This might be confusing as earlier this profile option used to control forms as well as self service application(with session.timeout) session.timeout is used to control Idle session timeout for Self Service Applications ( Served by Jserv via JVM )
From where ICX : Session Timeout & session.timeout get values ?
Autoconfig determines value for profile option “ICX: Session Timeout” and “session.timeout” from entry in context file ( $APPL_TOP/admin/SID_hostname.xml ) with parameter s_sesstimeout
where value mentioned is in milliseconds so profile option ICX: Session Timeout value should be s_sesstimeout/ (1000 * 60) which means here its 10 Minutes. This value is also set in
zone.properties in $IAS_ORACLE_HOME/Apache/Jserv/etc where number mentioned is in milli second i.e. 600000 ( equal to 10 Minutes)session.timeout = 600000 session.timeout mentioned in zone.properties is in milli secondsICX Session Time out mentioned in profile option ICX: Session Timeout is in minutes so ICX session timeout=30 & session.timeout= 1800,000 are same 30 minutes

38.  What is your Oracle Apps 11i Webserver Version and how to find it?
Ans:
cd $IAS_ORACLE_HOME/Apache/Apache/bin
./httpd -version
Server version: Oracle HTTP Server Powered by Apache/1.3.19
Server built: Dec 1- 2010 14:59:13 (iAS 1.0.2.2.2 rollup 5)

39.  How to determine Oracle Apps 11i Version?
Ans:  SQL>select RELEASE_NAME from fnd_product_groups;

40.  What is content of dbc file & why its important?
Ans:  DBC file is quite important as whenever Java or any other program like forms want to connect to database it uses dbc file. Typical entry in dbc file is GUEST_USER_PWD ,APPS_JDBC_URL ,DB_HOST

41.  There are lot of dbc file under $FND_SECURE, How its determined that which dbc file to use from $FND_SECURE?
Ans:  This value is determined from profile option “Applications Database ID”

42.  What is RRA/FNDFS?
Ans:  Report Review Agent(RRA) also referred by executable FNDFS is default text viewer in Oracle Applications 11i for viewing output files & log files.

43.  What is PCP is Oracle Applications 11i?
PCP is acronym for Parallel Concurrurent Processing. Usually you have one Concurrent Manager executing your requests but if you can configure Concurrent Manager running on two machines (Yes you need to do some additional steps in order to configure Parallel Concurrent Processing) .So for some of your requests primary CM Node is on machine1 and secondary CM node on machine2 and for some requests primary CM is on machine2 & secondary CM on machine1.

44.  What is use of Apps listener?
Ans:  Apps Listener usually running on All Oracle Applications 11i Nodes with listener alias as APPS_$SID is mainly used for listening requests for services like FNDFS & FNDSM.
FNDFS – FND File Server also known as RRA Reports Review Agent is used to view text files in Oracle 11i.
FNDSM – FND Service Manager is a concurrent manager in GSM, and serves requests like CM’s

45.  How will you find Invalid Objects in database?
Ans:
sql>select count(*) from dba_objects where status like ‘INVALID’;

46.  What is difference between adpatch & opatch?
Ans:  adpatch is utility to apply oracle applications patches whereas opatch is utility to apply database patches

47.  What is forms server executable Name?
Ans:  f60srvm

48.  What are different modes of forms in which you can start Forms Server and which one is default?
Ans:  You can start forms server in SOCKET or SERVLET by defualt Forms are configured to start in socket mode


49.  Where is HTML Cache stored in Oracle Apps Server?
Ans:  Oracle HTML Cache is available at $COMMON_TOP/_pages for some previous versions you might find it in $OA_HTML/_pages

50.  What is 0 & Y in FNDCPASS, FNDLOAD or WFLOAD?
Ans:  0 & Y are flags for FND Executable like FNDCPASS & FNDLOAD where 0 is request id (request ID 0 is assigned to request ID’s which are not submitted via Submit Concurrent Request Form.  ‘Y’ indicates the method of invocation. i.e. it is directly invoked from the command-line not from the Submit Request Form.

51.  What is TWO_TASK in Oracle Database?
Ans:  TWO_TASK mocks your tns alias which you are going to use to connect to database. Lets assume you have database client with tns alias defined as PROD to connect to Database PROD on machine appsdbatraining.com listening on port 1521. Then usual way to connect is sqlplus username/passwd@PROD ; now if you don’t want to use @PROD then you set  TWO_TASK=PROD and then can simply use sqlplus username/passwd then sql will check that it has to connect to tnsalias define by value PROD i.e. TWO_TASK

52.  What is GWYUID?
Ans:  GWYUID , stands for Gateway User ID and password. Usually like APPLSYSPUB/PUB

53.  Where GWYUID defined & what is its used in Oracle Applications?
Ans:  GWYUID is defined in dbc i.e. Database Connect Descriptor file . It is used to connect to database by thin clients.

54.  How to check number of forms users at any time?
Ans:  Forms Connections initiate f60webmx connections so you can use
ps -ef | grep f60webmx | wc -l

55.  What is FNDLOAD and what it is used for?


56.  How can you check which node is running what service?
Ans:  select * from fnd_nodes;

57.  What is difference between Socket & Servlet Mode in Apps Forms?


58.  What is make program in Unix?
Ans:  make is utility in Unix/Linux to maintain , update & generate an file mainly executable.

59.  What are .ldt & .lct files which you see in apps patch or with FNDLOAD?


60.  What are .odf file in apps patch?
Ans:  odf stands for Object Description Files used to create tables & other database objects.

Oracle Apps DBA Interview Questions – III

1.  How to determine Oracle Apps 11i Version?
Ans : select RELEASE_NAME from fnd_product_groups;
You should see output like
RELEASE_NAME….
11.5.10.2

2.  How to find Database version?
Ans : SQL> select * from v$version;
The command returns the release information, such as the following:Oracle9i Enterprise Edition Release 9.2.0.7.0 – ProductionPL/SQL Release 9.2.0.7.0 – ProductionCORE 9.2.0.7.0 ProductionTNS for 32-bit Windows: Version 9.2.0.7.0 – ProductionNLSRTL Version 9.2.0.7.0 – Production

3.  How to find opatch Version?
Ans : opatch is utility to apply database patch , In order to find opatch version execute”$ORACLE_HOME/OPatch/opatch version”

4.  How to find out invalid objects in the database?
Ans : select count(*) from dba_objects where status =’INVALID’

5.  How you will see hidden files in linux/solaris?
Ans : ls -la

6.  How to find that the database is 64-bit/32-bit?
Ans : $RDBMS_ORACLE_HOME/bin/file oracle

7.  What is top command?
Ans : top is a operating system command, it will display top 10 processes which are taking high cpu and memory.

8. What is a patch?
Ans : A patch can be a solution for a bug/it can be a new feature.

9. What are the different types of patches?
Ans : one-off, mini packs, family packs, maintenance packs, roll-up patches, consolidated patches.

10. What is a one off patch?
Ans : An one-off patch is a small patch of (20-90K size) without any pre-req’s

11. What is a mini pack?
Ans : A mini pack is one which will upgrade any product patch-set level to next level like AD.H to AD.I

12. What is Family pack?
Ans : A Family pack is one which will upgrade the patch-set level of all the products in that family to particular patch-set level.

13. What is Maintenance pack?
Ans : A maintenance pack will upgrade applications from one version to another like 11.5.8 to 11.5.9

14. What is a Roll-up patch?
Ans: A roll-up patch is one which will deliver bug fixes identified after the release of any major application versions like 11.5.8/11.5.9

15. What is consolidated patch?
Ans: Consolidated patches will come into pictures after upgrades from one version of applications to another, all post upgrade patches will a consolidated and given as consolidated patch.

16. How u will find whether a patch is applied/not?
Ans : Query ad_bugs.

17. What is the other table where u can query what are the patches applied?
Ans : Ad_applied_patches

18. What is the difference between ad_bugs and ad_applied_patches?
Ans: A patch can deliver solution for more than one bug, so ad_applied_patches may not give u the perfect information as in case of ad_bugs.

19. How u apply a patch?
Ans : adpatch

20. What inputs you need to apply a patch other than driver name and etc?
Ans : apps and system passwords

21. What are the table u r adpatch will create and when?
Ans : Adpatch will create FND_INSTALL_PROCESSES and AD_DEFERRED_JOBS table when it will apply d,g and u drivers

22. What is the significance of FND_INSTALL_PROCESSES and AD_DEFERRED_JOBS table?
Ans: FND_INSTALL_PROCESSES table will store the worker information like what job is assigned to which worker and its status. AD_DEFERRED_JOBS will come into picture when some worker is failed, it will be moved to AD_DEFERRED_JOBS table, from where again adpatch will take that job and try to resign, after doing this 3 times if still that worker is failing, then adpatch will stop patching and throw the error that perticular worker has failed. We need to trouble shoot and restrart the worker.

23. If it is a multinode installation which driver we need to apply on which node?
Ans: c,d,g on concurrent node and c, g on web node. If it is u-driver we need to apply on all nodes.

24.While applying a application patch is that necessary that u r database and listener should be up?
Ans: Yes . why because adpatch will connect to database and update so many tables etc…..

25. While applying a patch if that patch is failing because of a pre-req then how you will apply that pre-req patch and resume with the current patch?
Ans: We need to take the backup of FND_INSTALL_PROCESSES and AD_DEFERRED_JOBS tables and restart directory at APPL_TOP/amdin/SID and then use adctrl to quit all the workers. Then apply the pre-req patch , after that rename u r restart directory to its original name and create FND_INSTALL_PROCESSES and AD_DEFERRED_JOBS tables from the bcakup tables. Start adpatch session and take the options want to continue previous session.

26. What is adctrl?
Ans: Adctrl is one of the adutilities, which is used to check the status of workers and to manage the workers.

27. Can u name some of the menu options in adctrl?
Ans: Check the status of workers, tell manager that worker has quited, restart a failed worker etc….

28. How to skip a worker and why?
Ans: We can skip a worker using option 8 in adctrl which is hidden. We will go for skipping a worker when we have executed the job which the worker is supposed to do.

29. How adpatch knows what are the pre-req’s for the patch which it is applying?
Ans: With every patch a file called b.ldt file will be delivered which contain the pre-req information. adpatch load this into databse using FNDLOAD and check , whether those pre-req patches were applied or not.

30. What is FNDLOAD?
Ans: FNDLOAD is a utility which is similar to sqlloder but loads code objects into database, where as SQLLOADER loads data objects into database.

31. What c-driver will do?
Ans:  C-drive copies the files from patch unzipped directory to required location in u r application file system. Before copying it will check the file version of the existing file at the file system with the file version of the file in the patch. If the patch file version is higher than what it is at file system level then only c-driver will copy that files.

32. How adpatch will know the file versions of the patch delivered files?
Ans:  With each patch a file with name f.ldt is delivered , which contain the file versions of the files delivered with the patch. Adpatch will use this file to compare the file versions of files its delivering with the file on file system.

33. What is the adpatch log file location?
Ans : APPL_TOP/admin/SID/log

34. What is the worker log file name and its location?
Ans : adwork01,adwork02…… and location is APPL_TOP/admin/SID/log

35. How u will know what are the files the patch is going to change just my unzipping the patch?
Ans:  When u unzip a patch it will keep all the files related to a particular product under that directory inside u r patch directory for example if the patch delivering files related to FND product then it will create a sub directory under the patch directory with the name FND in which it will put all related files to that product

36. What is the significance of backup directory under u r patch directory?
Ans:  When we apply a patch it will keep the copy of the files which its going to change in file system.

37. What are the different modes you can run your adpatch?
Ans:
1.Interactive – default mode
2.Non interactive – Use defaults files to store prompt values
(adpatch defaultsfile= interactive=no)
3. Test – Without actually applying a patch just to check what doing.(adpatch apply=no)
4. Pre-install – (adpatch preinstall=y)
This mode will be usefull to discrease upgrade downtime as its applies bus fixes without running SQL,EXEC and generate portion of patch.

38. How u will monitor u r applications as well as database?
Ans:  We have our custom scripts which is sheduled to run at a specific time which will monitor whether applications and databases are up/not. And it will mail us if some processes is not running. And we have one script which will check database alert log for ORA errors and mails it to us . Based on this we will react.

39. What are the latest ORA errors u have encountered?
Ans:  Useually we will get the ORA errors like unable to extend the tablespace by so and so size. And we will check those tablespaces for space, if space is not there we will resize the datafile and add one more datafile.

40. Which table u will query to check the tablespace space issues?
Ans : bytes column in dba_free_spaces and dba_data_files

41. Which table u will query to check the temp tablespace space issues?
Ans : dba_temp_files

42. What is temp tablespace? And what is the size of temp tablespace in u r instances?
Ans : Temp tablespace is used by so many application programs for sorting and other stuff. Its size is between 3 to 10 GB.

43. What is autoconfig?
Ans : Autoconfig is an adutility which is used to main application environment and configuration files.

44. What are the parameter autoconfig will ask for?
Ans : Context file name and apps password

45. What is context file?
Ans : Context file is a central repositary, which stores all application configuration information. The name is like _ .xml

46. How you will find autoconfig is enabled/not for u r applications?
Ans: 1. Open any env / configuration files, the first few lines will tell u that this files are maintained by autoconfig.2. If contextname.xml file is there in APPL_TOP/admin

47. How autoconfig will create env and configuration files?
Ans: Autoconfig will go to each and every top template directory take the templates from there and fill the values from xml file and create the required files.

48. In how many phases autoconfig will run?
Ans : Autoconfig will run in 3 phases.
1.INIT – Instantiate the drivers and templates
2.SETUP – Fill the templated with values from xml and create files
3.PROFILE – Update the profile values in database.

49. What is the location of adconfig log file?
Ans : APPL_TOP/admin//log/

50. Is it possiable to restore a autoconfig run?
Ans :  Partially. Adconfig will create a restore.sh script at $APPL_TOP/admin//out/. This restore.sh will copy the backed up files before autoconfig run to its original locations. But the profile values updated in the database can’t be restored back.

51. How to run autoconfig in test mode?
Ans :  adchkcfg.sh script at AD_TOP/bin. This script will run autoconfig in test mode and create the difference file which tells us what is going to change , when u actually run autoconfig.

52. How to find autoconfig is enabled or not for database?
Ans:  If we have appsutil directory under RDBMS_ORACLE_HOME
53. When a patch delivers java files what extra file u will get when u unzip the patch, other then u r dirver and readme files?
Ans : j.zip52.

54. What is apps.zip/appsbrog2.zip file?
Ans : apps.zip/appsbrog2.zip is the patchable archive of all java class files required for oracle application.Apps.zip was used to old application version, but from 11.5.8 onwards its appsbrog2.zip

55. What is the location of apps.zip/appsbrog2.zip?
Ans : AU_TOP/java and JAVA_TOP

56. What is for “validating apps schema” option in adadmin?
Ans: It will check for the corrupted objects in apps schema

57. What is “compile apps schema” option in adadmin?
Ans : It will compile the invalid database objects.

58. How to find invalid objects in database?
Ans : select count(*) from dba_objects where status=’INVALID’;

59. How to find MRC is enabled or not?
Ans: In adadmin if covert to MRC options is there , then MRC is not enabled,If maintain MRC options is there , then MRC is enabled.

60. How to find Multi-Org is enabled or not?
Ans: In adadmin if covert to Multi org option is there, then Multi-org is not enabled. If maintain multi-org options is there, then Multi-org is enabled.

61. What is mean by MRC?
Ans: MRC stands for Multiple reporting Currency, this should be enabled to see the reports in different currencies like (rupees,yaans etc).

62. What is Multi-Org?
Ans: If this is enabled we can store multiple organization information in a single oracle application instance.

Oracle Apps DBA Interview Questions – IV

1. What is the configuration file for adutilities (like adadmin,adconfig etc)?
Ans: adconfig.txt @APPL_TOP/admin

2. What is adrelink?
Ans : adrelink will relink the executables with the libraries. Generally we will go for adrelink when some patch delivers some library files, or when executables were corrupted.

 3. How to find the version of a file?
Ans : 1. adident Header 2. strings -a filename grep Header

4. What is adodfcmp utility?
Ans : This utility is used to recreate/repair corrupted database objects from odf(object defination files) files.

5. How you will change apps password?
Ans: FNDCPASS 0 y apps/ system/ SYSTEM APPLSYS

6. What if apps password is changed with alter command?
Ans: Applications won’t work.

7. What is the difference between alter and FNDCPASS in changing apps password?
Ans : FNDCPASS will update some fnd tables other than standard tables.

8. Where the FNDCPASS utility is located?
Ans : Concurrent node @FND_TOP/bin

9. How to find out what component of u r oracle applications were installed on which node?
Ans : Xml file (context file)

10. How to find the version of httpd/Apache web server?
Ans : $IAS_ORACLE_HOME/Apache/bin/httpd –version

11. What is the configuration file for httpd and what is the location of it?
Ans : httpd.conf @IAS_ORACLE_HOME/Apache/Apache/conf

12. Where you will see when you have some problem with u r webserver(httpd/Apache)?
Ans : access_log & error_log @IAS_ORACLE_HOME/Apache/Apache/logs

13. When Apache starts what other components its start?
Ans : PL/SQL Listener, Servlet Engine, OJSP Engine

14. What is jserv?
Ans : jserv is nothing but servlet engine which will run u r servlets. It’s a module of apache which supports servlets.

15. What is self service application?
Ans : Whatever part of u r oracle application u r able to see through web browser is self service.

16. Where u will see when u r not able to get self service applications?
Ans : access_log,error_log, error_pls, jserv.log, wdbsvr.app(for apps password)

17. What is the location of jserv.log?
Ans : IAS_ORACLE_HOME/Apache/Jserv/log

18. What is the location of wdbsvr.app?
Ans : IAS_ORACLE_HOME/Apache/modplsql/cfg

19. What are jserv.conf and jserv.properties files?
Ans : These are the configuration files which were used to start jvm’s(servlet engine) by apache.

20. What is mean by clearing cache and bouncing apache?
Ans :
1. Stop apache (adapcctl.sh stop apps)
2. Clear cache – Go to $COMMON_TOP/html/_pages and delete _oa_html directory
(rm –r _oa__html)
3. Start apache (adapcctl.sh start apps)

21. What is forms configuration file and its location?
Ans : appsweb_contextname.cfg @$COMMON_TOP/html/bin

22. What are the different modes u can start u r form server?
Ans : socket and servlet

23. What is the difference beween socket and servlet mode?
Ans :
In socket mode forms sessions are represented by f60webmx
In servlet mode forms sessions are represented by apache processes.

24. What is forms metric server and client?
Ans : When there are more than one form sever instances then forms metric server and clinet will be used to load balance.

25. Where the forms server related errors will be logged?
Ans : access_log and error_log

26. What is report server configuration and log file name and its location?
Ans : Configuration file – REP_.ora
Log file – REP_.log @806_ORACLE_HOME/reports60/server

27. What is CGIcmd.dat file and its location?
Ans : CGIcmd.dat file is the run time parameter file the report server located @ 806_ORACLE_HOME/reports60/server

28. What is the significance of DISPLAY variable?
Ans : Vnc server should be up and running at the specified port value in DISPLAY variable, otherwise reportserver may not able to show the graphics in Reports.

29. Where is the concurrent manager log file located?
Ans : $COMMON_TOP/admin//log or $APPLCSF/$APPLLOG

30. Is apps password necessary to start all the components of oracle application?
Ans : No. Only to start/stop concurrent managers apps password is needed.

31. What is a concurrent manager?
Ans : A concurrent manager is one which runs concurrent requests.

32. What are the different types of concurrent managers?
Ans :
1. Internal concurrent manager – Will start all other managers and monitor
2. Standard Manager – All concurrent request by default will to go this
3. Conflict resolution manager – Concurrent programs with incompatabilites will be handled by this
4. Transaction manager – Handle all transaction requests

33. What are actual and target count in ‘Adminster Concurrent Managers form’?
Ans : Target is the no. of concurrent processes a manager is supposed to start(specified in the defination of concurrent manager).Actual is the no. of processes a manager started actually.
Target and Actual should be always same.

34. What if Target and Actual are not same?
Ans : It means at operating system level resources are low to accomidate the required processes for concurrent managers.

35. What are work shifts?
Ans : Work shifts are nothing but timings at which the concurrent manager is supposed to run.

36. What if internal concurrent manager target and actual are not same?
Ans : we need to bounce the concurrent manager using adcmctl.sh

37. How to bounce a single concurrent manager?
Ans : From frontend using ‘Administer Concurrent Manager form’.

38. When we change apps password , is it necessary to bounce application?
Ans : Only we need to bounce concurrent managers.

39. What is dbc file and its location?
Ans : dbc file contain database connection information. DBC file is used by oracle applications to connect to database. Its location is $FND_TOP/secure

40. What is the other script by which u can start apache other than adapcctl.sh?
Ans : apachectl @IAS_ORACLE_HOME/Apache/bin

41. What is the configuration file for PL/SQL listener?
Ans : httpd_pls.conf @IAS_ORACLE_HOME/Apache/Apache/conf

42. How to skip copy portion while applying a patch?
Ans : Adpatch options=nocopyportion

43. How to merge patches and what type of patches can be merged?
Ans : admrgpch. We can merge any kind of application patches, if any of the patch contain a u-driver then merged patch will contain u_merged.drv otherwise c_merged.drv, d_merged.drv and g_merged.drv

44. What is the Tiered architecture of u r instance?
Ans : Two Tier: Web and Forms on one node and Conc, admin and report on other node.

45. How to find formserver version?
Ans: f60gen and press enter, it will tell u the formserver version or we can find out from the frondend using help menu.

46. What is RRA?
Ans: RRA stands for Report Review Agent. RRA is nothing but FNDFS which is part of apps listener. RRA job is to pick the log/out file from the file system and show on the editor when u press view log/out button in ‘View concurrent request form’.

47. What is apps listener?
Ans : Apps lintener is the combination of FNDFS and FNDSM. FNDSM is service manager which will monitor application services on that node when GSM:enable profile value is ‘Y’.

48. What is GSM?
Ans : GSM stands for Generic service Manager, which will monitor application processes like web, forms etc and restarts any of this processes if goes down.

49. How to find the application version like 11.5.8/11.5.9….?
Ans : select release_name from fnd_product_groups;

50. How to find the database/sqlplus version?
Ans : select banner from v$version;

51. How to find out what are the languages enabled in u r applications?
Ans : Query fnd_languages

52. What is the size of u r database?
Ans: 200 to 500 GB

53. How to find operating system version?
Ans : uname –a

54. What are the problems u have faced while shutting down applications?
Ans : While shutting down application generally concurrent manager won’t go down because some or the other request may be running. We will see what are the concurrent requests running by querying fnd_concurrent_requests, fnd_concurrent_program_vl, v$session,v$process and v$sqltext. If that request is only doing some select statement then we will kill those requests, otherwise we will check what time it will take to complete by querying the previous runs of that request and then we will decide what to do.

55. What are the problems u have faced while starting up applications?
Ans : Most of the time we will encounter problem with starting up concurrent managers. Reasons , database listener may be down or FNDSM entries are wrong in tnsnames.ora of 806_ORACLE_HOME.

56. How to find the locks and what is the resolution?
Ans : we can find general locks with the following query:
select * from sys.dba_dml_locks order by session_id.
We can find the dead locks with the following query:
select * from v$lock where lmode > 0 and id1 in (select distinct id1 from v$lock where request > 0)
If it’s a dead lock, we need to kill that session.

57. How to kill a database session?
Ans : alter system kill session ‘&sid,&sno’;

58. How to find adconfig is enabled for oracle operating system user/database?
Ans : If appsutil directory is there in RDBMS_ORACLE_HOME

59. Which files tell u the database health?
Ans : alert log file @RDBMS_ORACLE_HOME/admin//bdump

60. How to apply a rdbms patch?
Ans : Using opatch

61. How to find opatch is enabled or not for u r database?
Ans: If Opatch directory exists under RDBMS_ORACLE_HOME.

Oracle Apps DBA Interview Questions – V

1. What is the pre-req for applying a rdbms patch?
Ans : OraInventory should be set in file oraInst.loc @/var/opt/oracle or /etc

2. What is OraInventroy?
Ans: The oraInventory is the location for the OUI (Oracle Universal Installer)’s bookkeeping. The orainventory stores information about: All Oracle software products installed in all ORACLE_HOMES on a machine Other non-Oracle products, such as the Java Runtime Environment (JRE).  In a 11i Application system the RDBMS and iAS ORACLE_HOMEs are registered in the oraInventory. The 806 ORACLE_HOME, which is not managed through OUI, is not.

3. What are different types of inventories?
Ans:  The Global orainventory (or Central inventory) The Local inventory (or Home inventory)

4. What is Global orainventory?
Ans : The Global oraInventory is the part of the XML inventory that contains the high level list of all oracle products installed on a machine. There should therefore be only one per machine. Its location is defined by the content of oraInst.loc.The Global OraInventory records the physical location of Oracle products installed on the machine, such as ORACLE_HOMES (RDBMS and IAS) or JRE. It does not have any information about the detail of patches applied to each ORACLE_HOMEs.The Global OraInventory gets updated every time you install or de-install an ORACLE_HOME on the machine, be it through OUI Installer, Rapid Install, or Rapid Clone.
Note: If you need to delete an ORACLE_HOME, you should always do it through the OUI de-installer in order to keep the Global OraInventory synchronized.

5. What is local Orainventory?
Ans : There is one Local OraInventory per ORACLE_HOME. It is physically located inside the ORACLE_HOME at $ORACLE_HOME/inventory and contains the detail of the patch level for that ORACLE_HOME.The Local OraInventory gets updated whenever a patch is applied to the ORACLE_HOME, using OUI.

6. What is rapid clone?
Ans : Rapid Clone is the new cloning utility introduced in Release 11.5.8. Rapid Clone leverages the new installation and configuration technology utilized by Rapid Install
7. How do I determine if my system is rapid clone enabled?
Ans : First, verify that your system is AutoConfig enabled. Then, verify that you have applied the latest Rapid Clone patch.

8. Explain the cloning process?
Ans :
1. Run adpreclone as applmgr and oracle user on source Perl adpreclone.pl dbTier as oracle user Perl adpreclone.pl appsTier as applmgr user
2. Take the cold/hotbackup of source database
3. Copy the five directories appl,comn,ora , db,data to target
4. Rename the directories, and change the permisssion
5. Set the inventory in oraInst.loc
6. Run perl adcfgclone.pl dbTier as oracle user,if the backup type is cold
7. If the backup type is hotbackup then Perl adcfgclone.pl dbTechStack. Create the control file on target from the control script trace file from source Recover the database Alter database open resetlogs
8. Run autoconfig with the ports changed as per requirement in xml.
9. Run perl adcfgclone.pl appsTier as applmgr
10. Run autoconfig with the ports changed as per requirement in xml.

9. What is the location of adpreclone.pl for oracle user?
Ans : RDBMS_ORACLE_HOME/appsutil/scripts/

10. What is the location of adpreclone.pl for applmgr user?
Ans : $COMMON_TOP/admin/scripts/

11. What is the location of adcfgclone.pl for oracle user?
Ans : $RDBMS_ORACLE_HOME/appsutil/clone/bin

12. What is the location of adcfgclone.pl for applmgr user?
Ans : $COMMON_TOP/clone/bin

13. What is statspack?
Ans : Statspack is a database utility to gather database and session level performance information.

14. How to install statspack?
Ans : Run the script spcreate.sql @RDBMS_ORACLE_HOME/rdbms/admin
Note more details on statspack refer metalink noteid: 149113.1

15. How to enable trace at database level?
Ans : set init.ora parameter sql_trace

16. How to enable trace for a session?
Ans: Alter system set sql_trace=true;
Execute the sql query
Alter system set sql_trace=false;
This will create a trace file at
$RDBMS_ORACLE_HOME/admin/contextname/udump with the spid of the current sql session.

17. How to enable trace for other session?
Ans : exec sys.dbms_system.set_sql_trace_in_session(sid,serial#,true/false)
Eg: To enable trace for sql session with sid 8SQL> exec sys.dbms_system.set_sql_trace_in_session(8,121,true);
PL/SQL procedure successfully completed.
To disable trace
SQL> exec sys.dbms_system.set_sql_trace_in_session(8,121,false);

18.What is the location of inint.ora ?
Ans : $RDBMS_ORACLE_HOME/dbs

19. What is that trace files contains and the utiliy used to read them?
Ans : Trace file contains the detail diagnostics of a sql statement like explain plan, physical reads, logical reads, buffer gets etc. Tkprof utility is used to convert trace file into readable format.

20. What is the syntax for tkprof?
Ans: tkprof explain=apps/ sys=no

21. How do we find adpreclone is run in source or not ?
Ans: If clone directory exists under RDBMS_ORACLE_HOME/appsutil for oracle user and $COMMON_TOP for applmgr user.

22. Which files it will call when we run adcmctl.sh start apps/apps?
A: It will call FNDLIBR executable, which will be located in $FND_TOP/bin.

23. How to find trace file for a given concurrent request id?
Ans : Go to $RDBMS_ORACLE_HOME/admin//udump
grep “ “ *

24. What is a database link? How to create it?
Ans : If we want to access objects of another database from this database then we need a database link from this database to the other.
1.Login as oracle user
2.sqlplus “/as sysdba”
3. create database link connect to identified by using ”;
Ex
SQL> create database link TEST1_TO_TEST2 connect to apps identified by apps using ‘TEST2′;
Database link created.
SQL> select name from v$database@ TEST1_TO_TEST2;
NAME
———
TEST2
SQL>select db_link from dba_db_links;
4. Add destination database tns entry in tnsnames.ora

25. How many clonings u have done?
Ans : If u r very much confident on cloning processes then say 5 to 8 otherwise just 2 or 3.

26. What u know abt RMAN?
Ans : If u r good at RMAN then say yes, otherwise say we are not using RMAN for backup/recovery , why because we are using netapp snap technology for backups.

27. What is netapp?
Ans : Netapp is a storage technology.

28. What is form server url?
Ans :http://hostname.domain:/dev60cgi/f60cgi

29. What is jinitiator?
Ans : Oracle jinitiator is the one which provide the required jvm to run forms interface/applet. When we access forms applet first time , oracle jinitiator will be installed automatically.

30. What is discoverer server?
Ans : Discoverer server is reporting tools which allows novoice user to use oracle application reports. Discoverer will come along with oracle applications when installed.

31. What is discoverer viewer url?
Ans: /discoverer4i/viewer152. What is discoverer plus url?
Ans : Ans : Aoljtest is a web based utility to test the availability of the different components of oracle applications like jserv,modplsql,jsp,forms etc
URL: /OA_HTML/jsp/fnd/aoljtest.jsp

32. What is adsplicer?
Ans : Adsplicer is a uitility used to register off cycle products.

33. What is licence manager?
Ans : Licence manager(adlicmgr) utility is used to licence/unlicence , enable new languages,enbale country specific functionality.

34. What is tnsping?
Ans : tnsping is command used to check the connectivity to the database server node from other nodes.
Ex: tnsping
Note: Tns entry should be there in tnsnames.ora for the database we are trying to work this command.

35. How to compile a form using f60gen?
Ans:
f60gen module=/TEST/testappl/au/11.5.0/forms/F/ARXTWMAI.fmb userid=APPS/APPS output_file=/TEST/testappl/ar/11.5.0/forms/F/ARXTWMAI.fmx module_type=form batch=yes compile_all=special

36: This is the temporary file location for the pl/sql temp files. If this variable was not set then the concurrent programs may errored out. 161. What is mean by enabling maintanance mode?
Ans: Maintanance mode is the adadmin option introduced from AD.I. When maintanance mode is enabled user may able to login to application but they only get profile option in the frontend navigation menu.

37. Is that necessary to enable maintanance mode while applying a patch?
Ans : We can even apply a patch without enabling maintanance mode with the following option
Adpatch options=hotpatch

38. How to find out oracle application framework version?
Ans : 1. Through aoljtest2. cd $COMMON_TOP/html/3. adident Header OA.jsp

39. How to find out what are the rdbms patches applied to an oracle home?
Ans:
1. opatch lsinventory
2. $RDBMS_ORACLE_HOME/.patch_storage directory contains the directories with the rdbms patch number, which are applied to this oracle home.

40. What is the command line utility to submit a concurrent request?
Ans : CONSUB

41. What is the significance of utl_file_dir parameter in init.ora file?
Ans : The value of this parameter is the group of directories to which u r database can write, means u r database packages have permission to write to flat files in these directories.

42. How you will find out discoverer version?
Ans : cd $806_ORACLE_HOME/discwb4/lib strings libd* grep ‘Version:’

43. While applying a rdbms patch using opatch you are getting the error, unable to read inventory/inventory is corrupted/ORACLE_HOME is not not registered, what you will do, and how you will apply the patch?
Ans: We will check the inventory directory permission, try to apply the patch after giving 777 permissions to that inventory directory. If still it won’t work we will apply patch with the following command:
Opatch apply no_inventory

44. Have you applied rdbms patches and for what?
Ans : We got ORA-7445 error in alert log, for which oracle recommended to apply a rdbms patch.

45. What are the patch errors , you have encountered?
Ans :
1)Patch fails with the error, unable to generate perticular form, do u want to continue. We continue patching by saying “yes”, then we manually regenarate the form using f60gen utility.
2) Unable to generate jar files under JAVA_TOP AutoPatch error: Failed to generate the product JAR files Solution:Run adjkey -initialize ———–to creat identitydb.obj file which will beused by adjava to sign jar files.

46. What is adjkey? What files it will create?
Ans : adjkey is an adutility which will create digital signature, which will be used to sign all t” admin? mailto:adsign.txt@APPL_TOP>adsign.txt@APPL_TOP/adminappltop.cer@APPL_TOP/adminidentitydb.obj@applmgr home

47. What are the post installation task?
Ans : Running adjkey –initialize and then runnning adadmin to regerate jar files.

48. What are the clone errors, you have encountered?
Ans : Error:
RC-50013: Fatal: Failed to instantiate driver/u01/fms2c/appfms2c/fms2cora/iAS/appsutil/driver/instconf.drvCauseThe source instance has files that adpreclone flags as ‘autoconfigable’ but in reality they are not. So adpreclone.pl adds these files into the instconf.drv. Then when adcfgclone.pl is run on target it looks for the template file to instantiate for these files and since there isn’t a template file adcfgclone.pl fails. SolutionModify the target’s instconf.drv and remove the offending lines. Then rerun adcfgclone.pl

49. What are the real time problems you have encountered and how you trouble shooted that?
Ans:1. Concurrent Program is erroing out with snapshot too old error. To resolve this we have added space to temp tablespace.2. Concurrent Program is erroing out with unable to extent a perticular tablespace by so and so extents. To resolve this we have added on more data file to that tablespace.3. When we are trying to start apache with adapcctl.sh script after a autoconfig run, its saying that “node id is not matching with the application server id”. To resolve this we have updated the server id column in fnd_nodes table with the server id value in dbc file.

50. How you will find workflow version?
Ans : Run wfver.sql@FND_TOP/sql script as apps user

51 . When forms are running in servlet mode then the environment variables required for forms must be defined in what file and its location?
Ans : formsservlet.ini@$APACHE_TOP/Jserv/etc.

52. How to find out which patch driver is applied(like c,d,g or u)?
Ans: query ad_patch_drivers.

53. How to find out whether a language patch is applied for a perticular patch?
Ans : Query ad_patch_driver_langs.

54. How to validate that sysadmin password is correct or not from backend?
Ans: select fnd_web_sec.validate_login(‘SYSADMIN’,'Qwert8765′) from dual;

55. How to compile jsp’s(other than from adadmin)?
Ans: Force compilation of all jsps using the following command ojspCompile.pl –compile –flush

56. How to rotate logs for apache logs?
Ans: Using rotatelogs executable in httpd.conf file. Use Errorlog for error_log file rotation. Transferlog for other log files.

57. Other way of checking whether MRC is enabled or not besides using adadmin?
Ans : select multi_currency_flag from fnd_product_groups;

58. How to compile rdf?
Ans: Either using adadmin or rwcon60

59. How to change file/directory owner in linux/solaris?
Ans : chown – R :
Ex: chown – R applmgr:dba testappl

60. How to change the permission of file/directory in linux/solaris?
Ans : chmod –R
Ex : chmod –R 755 testappl

61. What are the files which contain apps password?
Ans : 1. wdbsrv.app@IAS_ORACLE_HOME/Apache/modplsql/cfg
2. CGIcmd.dat@806_ORACLE_HOME/reports60/server
3. wfmail.cfg@FND_TOP/resource – optional
4. CatalogLoader.conf@OA_JAVA – optional
5. CatalogLoader.xml@OA_HTML – optional

62. What is the script to find out ICM status?
Ans : afimchk.sql@FND_TOP/sql

63. What is the script to list the concurrent request status?
Ans: afrqrun.sql@FND_TOP/sql

64. What is the script that Lists managers that currently are running a request?
Ans : afcmrrq.sql@FND_TOP/sql

65. How can I determine whether a template is customizable or non-customizable?
Ans : If a keyword “LOCK” is present at the end of the file entry in the respective driver, then it is a non-customizable template. If the “LOCK” keyword is not seen, then that template can be customized.

66. How to find out JDBC version :
Ans : In the middle tier, edit the jserv.properties file located in the IAS_ORACLE_HOME/Apache/Jserv/etc directory- Locate the wrapper.classpath that is pointing to the jdbc zip file/opt/oracle/apps/$TWO_TASK/comn/java/jdbc14.zip

67. How to findout XML Parser Version
Ans : SQL> select WF_EVENT_XML.XMLVersion() XML_VERSION from sys.dual;

68.  How to find out WorkFlow Version
Ans :
SQL> select TEXT Version from WF_RESOURCES where TYPE = ‘WFTKN’ and NAME = ‘WF_VERSION’;

69.  How to find a file version in Application DB:
select v.version,v.CREATION_DATE,c.CREATION_DATE from AD_FILES c,AD_FILE_VERSIONS v where c.FILENAME like ‘ARPURGEB.pls’ AND c.file_id = v.file_id AND c.app_short_name = ‘AR’;
When a copy driver (C) or the copy portion of a unified driver (U) are aborted for any reason, upon reapplying, the CREATION_DATE and/or LAST_UPDATE_DATE columns in the patching history tables (Ex: AD_FILE_VERSIONS)are not updated to show the proper installation date but are left with the 01-01-1950 date. you can resolve the issuse by applying the latest ad.I patch.

70.  How to check whether the product is install,shared and Not installed in Apps.?
Ans : SQL>select t.application_name, t.application_id, i.patch_level, decode(i.status,’I’,’Fully Installed’,‘N’,’Not Installed’,’S’,’Shared’,’Undetermined’) statusfrom fnd_product_installations i, fnd_application_vl twhere i.application_id = t.application_idorder by t.application_id;

Oracle Apps DBA Interview Questions – VI

Q: Why we need to put maintenance mode when we are applying a patch?
A: Maintenance mode provides a clear separation between normal runtime operation of Oracle Applications and system downtime for
maintenance. Enabling the maintenance mode feature shuts down the Workflow Business Events System and sets up function security so
that no Oracle Applications functions are available to users. Used only during AutoPatch sessions, maintenance mode ensures
optimal performance and reduces downtime when applying a patch. For more information, refer to Preparing your System for Patching
in Oracle Applications Maintenance Utilities.

Q: After applying patch why we need to take snapshot and what is the use of it?
A: Snapshot is a view of the system at specific time. In apps, Patch Wizard uses Global snapshot to determine which patches have
been applied to the system and Autopatch uses APPL_TOP snapshot to determine what patches have been applied to that APPL_TOP.
Snapshot actually records the list of files,file versions and bug fixes. Both snapshot are views, they are created once during
installation and then updated during patching. APPL_TOP snapshot information is stored in the AD_SNAPSHOTS, AD_SNAPSHOT_FILES, and
AD_SNAPSHOT_BUGFIXES tables

Q: Whether we can apply 2 patches at a time without merging them, why?
A: We can’t apply 2 patches at a time because when patch started it will create 2 tables in db (AD_DEFERRED_JOBS AND
FND_INSTALL_PROCESSES). If you apply patches at a time both will try to create those 2 tables in db, so both will fail.

Q. After applying patch whether we can revert it back?
A: No, as it is going to update some tables in db.

Q. Whether we need to run adpreclone everytime when we clone, why?
A: We have to run adpreclone if there are changes in any customizations or any other tablespaces like if applied any AD patches,
Big Patches, Minipacks, ATG patches, Tech Stack, and AD Patches. If there are no changes, then i don’t think there is any need to
preclone it again.
Example: When you run adpreclone.pl, it essentially does an “alter database backup controlfile to trace” and stores the information from
that in a file within ${ORACLE_HOME}/appsutil. This represents all of the datafiles in the database at that particular time. The information
gathered at this time represents the state of the source at this time. If you does not run adpreclone.pl again when u do clone next time,
Your backup (your target) represents an earlier time (prior to the addition of that datafile), so the “create controlfile” step
that adcfgclone is doing is going to fail.

Q: What are the main tables related to concurrent managers?
A: FND_NODES
FND_CONCURRENT_PROCESSES (fcproc)
FND_CONCURRENT_REQUESTS (fcr)
FND_CONCURRENT_QUEUES (fcq)
FND_CONCURRENT_PROGRAMS (fcprog)
FND_EXECUTABLES
FND_CP_SERVICES
FND_CONCURRENT_QUEUE_SIZE
FND_CONCURRENT_QUEUE_CONTENT
FND_CONCURRENT_PROGRAM_SERIAL
FND_CONCURRENT_TIME_PERIODS
FND_CONCURRENT_PROCESSORS

Q: What is FNDFS?
A: Report Review Agent(RRA) also referred by executable FNDFS is default text viewer in Oracle Applications 11i for viewing
output files and log files. As most of Applications DBA’s are not clear about Report Server and RRA.

Q: What is FNDSM ?? It has seperate name, what it is?
A: FNDSM is executable & core component in GSM. GSM stands for Generic Service Management Framework. Oracle E-Business Suite
consist of various compoennts like Forms, Reports, Web Server, Workflow, Concurrent Manager .. Earlier each service used to start
at their own but managing these services (given that) they can be on various machines distributed across network. So Generic
Service Management is extension of Concurrent Processing which manages all your services , provide fault tolerance (If some
service is down ICM through FNDSM & other processes will try to start it even on remote server) With GSM all services are
centrally managed via this Framework.

Q: How to check whether ICM is up and running from backend?
A: ps -ef | grep LIB
ps –ef | grep CPMGR
ps –ef | grep FNDCPMBR
$FND_TOP/sql/afcmstat.sql — Displays all the defined managers, their maximum capacity, pids, and their status.
afimchk.sql — Displays the status of ICM and PMON method in effect, the ICM’s log file, and determines if the concurrent manger
monitor is running.
afcmcreq.sql — Displays the concurrent manager and the name of its log file that processed a request.
afrqwait.sql — Displays the requests that are pending, held, and scheduled.
afrqstat.sql — Displays of summary of concurrent request execution time and status since a particular date.
afqpmrid.sql — Displays the operating system process id of the FNDLIBR process based on a concurrent request id. The process id
can then be used with the ORADEBUG utility.
afimlock.sql — Displays the process id, terminal, and process id that may be causing locks that the ICM and CRM are waiting to
get. You should run this script if there are long delays when submitting jobs, or if you suspect the ICM is in a gridlock with
another oracle process.

Q: Which component is responsible for PCP failover?
A: When PCP is enabled, can you check that FNDSM is running on all your CCM nodes? That process is mainly reponsible to getting
the failovers to happen and also start up CCMs

Q: Where custom top information will be there?
A: $APPL_TOP/APPLSYS.env file.

Q: What will happen when we run adpreclone?
A: It will collect all info of the environment and store in seperate template files.

Q: Which two parameters are required when we do clone using RMAN?
A: DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT

Q: How to clean FND_NODES table?
A: EXEC FND_CONC_CLONE.SETUP_CLEAN.

Q. Is that necessary to shutdown database while applying a database patch?
Ans: Yes.



*********************************END*********************************


                     


*********************SQL Interview****************************



                  SQL Interview Questions & Answers...



I have tried to put some questions regarding SQL has been put in this article. Oracle DBA Aspirants should have basic knowledge of SQL and Pl/SQL. Structured Query Language (SQL) is a language that provides an interface to relational database systemsSQL was developed by IBM in the 1970s for use in System R, and is a de facto standard, as well as an ISO and ANSI standard. Basically SQL comprises of DML, DCL, DDL commands.

1. What is SQL ?

Structured Query Language (SQL) is a language that provides an interface to relational database systems. The proper pronunciation of SQL is "ess cue ell," and not "sequel" as is commonly heard.

SQL was developed by IBM in the 1970s for use in System R, and is a de facto standard, as well as an ISO and ANSI standard.
In common usage SQL also encompasses DML (Data Manipulation Language), for INSERTs, UPDATEs, DELETEs and DDL (Data Definition Language), used for creating and modifying tables and other database structures.

The development of SQL is governed by standards. A major revision to the SQL standard was completed in 1992, called SQL2. SQL3 support object extensions and are (partially?) implemented in Oracle8 and 9i.

Example SQL statements:

CREATE TABLE table1 (column1 NUMBER, column2 VARCHAR2(30));
INSERT INTO table1 VALUES (1, 'XYZ');
SELECT * FROM table1 WHERE column2 = 'XYZ';

2. What are the difference between DDL, DML and DCL commands?

DDL - Data Definition Language: statements 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
COMMENT - add comments to the data dictionary
RENAME - rename an object

DML - Data Manipulation Language: statements used for managing data within schema objects. Some examples:
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)
CALL - call a PL/SQL or Java subprogram
EXPLAIN PLAN - explain access path to data
LOCK TABLE - control concurrency

DCL - Data Control Language. Some examples:

GRANT - gives user's access privileges to database
REVOKE - withdraw access privileges given with the GRANT command

TCL - Transaction Control: statements used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.

COMMIT - save work done
SAVEPOINT - identify a point in a transaction to which you can later roll back
ROLLBACK - restore database to original since the last COMMIT
SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use
DML are not auto-commit. i.e. you can roll-back the operations, but DDL are auto-commit



3. Difference between TRUNCATE, DELETE and DROP commands?

The DELETE command is used to remove some or all 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.

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

TRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUNCATE is faster and doesn't use as much undo space as a DELETE.
SQL> TRUNCATE TABLE emp;Table truncated.

SQL> SELECT COUNT(*) FROM emp;


  COUNT(*)

----------

         0


               

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.

SQL> DROP TABLE emp;
Table dropped.

From Oracle 10g a table can be "undropped". Example:

SQL> FLASHBACK TABLE emp TO BEFORE DROP;

Flashback complete.

PS: DELETE will not free up used space within a table. This means that repeated DELETE commands will severely fragment the table and queries will have to navigate this "free space" in order to retrieve rows.

4. How does one escape special characters when writing SQL queries?

Escape quotes
Use two quotes for every one displayed. Examples:

SQL> SELECT 'Frank''s Oracle site' AS text FROM DUAL;

 TEXT

 --------------------

 Franks's Oracle site


 SQL> SELECT 'A ''quoted'' word.' AS text FROM DUAL;

 TEXT

 ----------------

 A 'quoted' word.


 SQL> SELECT 'A ''''double quoted'''' word.' AS text FROM DUAL;

 TEXT

 -------------------------

 A ''double quoted'' word.

Escape wildcard characters
The LIKE keyword allows for string searches. The '_' wild card character is used to match exactly one character, while '%' is used to match zero or more occurrences of any characters. These characters can be escaped in SQL. Examples:

SELECT name FROM emp

 WHERE id LIKE '%/_%' ESCAPE '/';

SELECT name FROM emp

 WHERE id LIKE '%\%%' ESCAPE '\';

Escape ampersand (&) characters in SQL*Plus
When using SQL*Plus, the DEFINE setting can be changed to allow &'s (ampersands) to be used in text:

SET DEFINE ~

SELECT 'Lorel & Hardy' FROM dual;

Other methods:
Define an escape character:

SET ESCAPE '\'

SELECT '\&abc' FROM dual;

Don't scan for substitution variables:

SET SCAN OFF

SELECT '&ABC' x FROM dual;

Use the 10g Quoting mechanism:

Syntax

 q'[QUOTE_CHAR]Text[QUOTE_CHAR]'

 Make sure that the QUOTE_CHAR doesnt exist in the text.

SELECT q'{This is Orafaq's 'quoted' text field}' FROM DUAL;

5.Can one select a random collection of rows from a table?

The following methods can be used to select a random collection of rows from a table:
The SAMPLE Clause

From Oracle 8i, the easiest way to randomly select rows from a table is to use the SAMPLE clause with a SELECT statement. Examples:

SELECT * FROM emp SAMPLE(10);

In the above example, Oracle is instructed to randomly return 10% of the rows in the table.

SELECT * FROM emp SAMPLE(5) BLOCKS;

This example will sample 5% of all formatted database blocks instead of rows.
This clause only works for single table queries on local tables. If you include the SAMPLE clause within a multi-table or remote query, you will get a parse error or "ORA-30561: SAMPLE option not allowed in statement with multiple table references". One way around this is to create an inline view on the driving table of the query with the SAMPLE clause. Example:

SELECT t1.dept, t2.emp

  FROM (SELECT * FROM dept SAMPLE(5)) t1,

       emp t2

 WHERE t1.dep_id = t2.dep_id;

If you examine the execution plan of a "Sample Table Scan", you should see a step like this:

TABLE ACCESS (SAMPLE) OF 'EMP' (TABLE)

ORDER BY dbms_random.value()
This method orders the data by a random column number. Example:

SQL> SELECT * FROM (SELECT ename

  2                   FROM emp

  3                  ORDER BY dbms_random.value())

  4   WHERE rownum <= 3;

ENAME

----------

WARD

MILLER

TURNER

The ORA_HASH() function
The following example retrieves a subset of the data in the emp table by specifying 3 buckets (0 to 2) and then returning the data from bucket 1:

SELECT * FROM emp WHERE ORA_HASH(empno, 2) = 1;

6. How does one eliminate duplicates rows from a table?

Choose one of the following queries to identify or remove duplicate rows from a table leaving only unique records in the table:
Method 1:

Delete all rowids that is BIGGER than the SMALLEST rowid value (for a given key):

SQL> DELETE FROM table_name A WHERE ROWID > (

  2    SELECT min(rowid) FROM table_name B

  3    WHERE A.key_values = B.key_values);

Method 2:
This method is usually faster. However, remember to recreate all indexes, constraints, triggers, etc. on the table when done.

SQL> create table table_name2 as select distinct * from table_name1;

SQL> drop table table_name1;

SQL> rename table_name2 to table_name1;

Method 3:

SQL> delete from my_table t1

SQL> where  exists (select 'x' from my_table t2

SQL>                 where t2.key_value1 = t1.key_value1

SQL>                   and t2.key_value2 = t1.key_value2

SQL>                   and t2.rowid      > t1.rowid);

7. How does one get the time difference between two date columns?

Oracle allows two date values to be subtracted from each other returning a numeric value indicating the number of days between the two dates (may be a fraction). This example will show how to relate it back to a time value.
Let's investigate some solutions. Test data:

SQL> CREATE TABLE dates (date1 DATE, date2 DATE);

Table created.

SQL>

SQL> INSERT INTO dates VALUES (SYSDATE, SYSDATE-1);

1 row created.

SQL> INSERT INTO dates VALUES (SYSDATE, SYSDATE-1/24);

1 row created.

SQL> INSERT INTO dates VALUES (SYSDATE, SYSDATE-1/60/24);

1 row created.

SQL> SELECT (date1 - date2) FROM dates;

DATE1-DATE2

-----------

          1

 .041666667

 .000694444

Solution 1

SQL> SELECT floor(((date1-date2)*24*60*60)/3600)

  2         || ' HOURS ' ||

  3         floor((((date1-date2)*24*60*60) -

  4         floor(((date1-date2)*24*60*60)/3600)*3600)/60)

  5         || ' MINUTES ' ||

  6         round((((date1-date2)*24*60*60) -

  7         floor(((date1-date2)*24*60*60)/3600)*3600 -

  8         (floor((((date1-date2)*24*60*60) -

  9         floor(((date1-date2)*24*60*60)/3600)*3600)/60)*60) ))

 10         || ' SECS ' time_difference

 11    FROM dates;

TIME_DIFFERENCE

--------------------------------------------------------------------------------

24 HOURS 0 MINUTES 0 SECS

1 HOURS 0 MINUTES 0 SECS

0 HOURS 1 MINUTES 0 SECS

Solution 2

SQL> SELECT to_number( to_char(to_date('1','J') +

  2         (date1 - date2), 'J') - 1)  days,

  3         to_char(to_date('00:00:00','HH24:MI:SS') +

  4         (date1 - date2), 'HH24:MI:SS') time

  5   FROM dates;

      DAYS TIME

---------- --------

         1 00:00:00

         0 01:00:00

         0 00:01:00

The SYSDATE pseudo-column shows the current system date and time. Adding 1 to SYSDATE will advance the date by 1 day. Use fractions to add hours, minutes or seconds to the date. Look at these examples:

SQL> select sysdate, sysdate+1/24, sysdate +1/1440, sysdate + 1/86400 from dual;

SYSDATE              SYSDATE+1/24         SYSDATE+1/1440       SYSDATE+1/86400

-------------------- -------------------- -------------------- --------------------

03-Jul-2002 08:32:12 03-Jul-2002 09:32:12 03-Jul-2002 08:33:12 03-Jul-2002 08:32:13

The following format is frequently used with Oracle Replication:

select sysdate NOW, sysdate+30/(24*60*60) NOW_PLUS_30_SECS from dual;

NOW                  NOW_PLUS_30_SECS

-------------------- --------------------

03-JUL-2005 16:47:23 03-JUL-2005 16:47:53

Here are a couple of examples:

Description
Date Expression
Now
SYSDATE
Tomorow/ next day
SYSDATE + 1
Seven days from now
SYSDATE + 7
One hour from now
SYSDATE + 1/24
Three hours from now
SYSDATE + 3/24
An half hour from now
SYSDATE + 1/48
10 minutes from now
SYSDATE + 10/1440
30 seconds from now
SYSDATE + 30/86400
Tomorrow at 12 midnight
TRUNC(SYSDATE + 1)
Tomorrow at 8 AM
TRUNC(SYSDATE + 1) + 8/24
Next Monday at 12:00 noon
NEXT_DAY(TRUNC(SYSDATE), 'MONDAY') + 12/24
First day of the month at 12 midnight
TRUNC(LAST_DAY(SYSDATE ) + 1)
The next Monday, Wednesday or Friday at 9 a.m
TRUNC(LEAST(NEXT_DAY(sysdate,MONDAY' ' ),NEXT_DAY(sysdate,WEDNESDAY), NEXT_DAY(sysdate,FRIDAY ))) + (9/24)

8. How does one add a day/hour/minute/second to a date value?

The SYSDATE pseudo-column shows the current system date and time. Adding 1 to SYSDATE will advance the date by 1 day. Use fractions to add hours, minutes or seconds to the date. Look at these examples:

SQL> select sysdate, sysdate+1/24, sysdate +1/1440, sysdate + 1/86400 from dual;

SYSDATE              SYSDATE+1/24         SYSDATE+1/1440       SYSDATE+1/86400

-------------------- -------------------- -------------------- --------------------

03-Jul-2002 08:32:12 03-Jul-2002 09:32:12 03-Jul-2002 08:33:12 03-Jul-2002 08:32:13

The following format is frequently used with Oracle Replication:

select sysdate NOW, sysdate+30/(24*60*60) NOW_PLUS_30_SECS from dual;

NOW                  NOW_PLUS_30_SECS

-------------------- --------------------

03-JUL-2005 16:47:23 03-JUL-2005 16:47:53

Here are a couple of examples:

Description
Date Expression
Now
SYSDATE
Tomorow/ next day
SYSDATE + 1
Seven days from now
SYSDATE + 7
One hour from now
SYSDATE + 1/24
Three hours from now
SYSDATE + 3/24
An half hour from now
SYSDATE + 1/48
10 minutes from now
SYSDATE + 10/1440
30 seconds from now
SYSDATE + 30/86400
Tomorrow at 12 midnight
TRUNC(SYSDATE + 1)
Tomorrow at 8 AM
TRUNC(SYSDATE + 1) + 8/24
Next Monday at 12:00 noon
NEXT_DAY(TRUNC(SYSDATE), 'MONDAY') + 12/24
First day of the month at 12 midnight
TRUNC(LAST_DAY(SYSDATE ) + 1)
The next Monday, Wednesday or Friday at 9 a.m
TRUNC(LEAST(NEXT_DAY(sysdate,MONDAY' ' ),NEXT_DAY(sysdate,WEDNESDAY), NEXT_DAY(sysdate,FRIDAY ))) + (9/24)

9. How does one code a matrix/crosstab/pivot report in SQL?

Newbies frequently ask how one can display "rows as columns" or "columns as rows". Look at these example crosstab queries (also sometimes called transposed, matrix or pivot queries):

SELECT  *

  FROM  (SELECT job,

                sum(decode(deptno,10,sal)) DEPT10,

                sum(decode(deptno,20,sal)) DEPT20,

                sum(decode(deptno,30,sal)) DEPT30,

                sum(decode(deptno,40,sal)) DEPT40

           FROM scott.emp

       GROUP BY job)

ORDER BY 1;

JOB           DEPT10     DEPT20     DEPT30     DEPT40

--------- ---------- ---------- ---------- ----------

ANALYST                    6000

CLERK           1300       1900        950

MANAGER         2450       2975       2850

PRESIDENT       5000

SALESMAN                              5600

Here is the same query with some fancy headers and totals:

SQL> ttitle "Crosstab Report"

SQL> break on report;

SQL> compute sum of dept10 dept20 dept30 dept40 total on report;

SQL>

SQL> SELECT     *

  2    FROM     (SELECT job,

  3                  sum(decode(deptno,10,sal)) DEPT10,

  4                  sum(decode(deptno,20,sal)) DEPT20,

  5                  sum(decode(deptno,30,sal)) DEPT30,

  6                  sum(decode(deptno,40,sal)) DEPT40,

  7                  sum(sal)                   TOTAL

  8             FROM emp

  9            GROUP BY job)

 10  ORDER BY 1;


Mon Aug 23                                                             page    1

                                Crosstab Report


JOB           DEPT10     DEPT20     DEPT30     DEPT40      TOTAL

--------- ---------- ---------- ---------- ---------- ----------

ANALYST                    6000                             6000

CLERK           1300       1900        950                  4150

MANAGER         2450       2975       2850                  8275

PRESIDENT       5000                                        5000

SALESMAN                              5600                  5600

          ---------- ---------- ---------- ---------- ----------

sum             8750      10875       9400                 29025

Here's another variation on the theme:

SQL> SELECT DECODE(MOD(v.row#,3)

  2                 ,1, 'Number: '  ||deptno

  3                 ,2, 'Name: '    ||dname

  4                 ,0, 'Location: '||loc

  5                 ) AS "DATA"

  6    FROM dept,

  7         (SELECT rownum AS row# FROM user_objects WHERE rownum < 4) v

  8   WHERE deptno = 30

  9  /

DATA

--------------------------------------- ---------

Number: 30

Name: SALES

Location: CHICAGO

10. Can one retrieve only rows X to Y from a table?

SELECT * FROM (

   SELECT ename, rownum rn

            FROM emp WHERE rownum < 101

) WHERE  RN between 91 and 100 ;

11. Can one retrieve only the Nth row from a table?

SELECT * FROM t1 a

WHERE  n = (SELECT COUNT(rowid)

              FROM t1 b

             WHERE a.rowid >= b.rowid);

12. How can one dump/ examine the exact content of a database column?

Table data can be extracted from the database as octal, decimal or hex values:

SELECT DUMP(col1, 10)

FROM tab1

WHERE cond1 = val1;

DUMP(COL1)

-------------------------------------

Typ=96 Len=4: 65,66,67,32

For this example, type=96 is indicating a CHAR column. The last byte in the column is 32, which is the ASCII code for a space. This tells us that this column is blank-padded.

13. How does one add a column to the middle of a table?

Oracle only allows columns to be added to the end of an existing table. Example:

SQL> CREATE TABLE tab1 ( col1 NUMBER );

Table created.


SQL> ALTER TABLE tab1 ADD (col2 DATE);

Table altered.


SQL> DESC tab1

Name                                      Null?    Type

----------------------------------------- -------- ----------------------------

COL1                                               NUMBER

COL2                                               DATE

14. How does one code a hierarchical tree-structured query?

The SCOTT/TIGER database schema contains a table EMP with a self-referencing relation (EMPNO and MGR columns). This table is perfect for testing and demonstrating tree-structured queries as the MGR column contains the employee number of the "current" employee's boss.
The LEVEL pseudo-column is an indication of how deep in the tree one is. Oracle can handle queries with a depth of up to 255 levels. Look at this example:

SQL> SELECT     level, empno, ename, mgr

  2    FROM     emp

  3  CONNECT BY PRIOR empno = mgr

  4    START WITH mgr IS NULL

  5  /

     LEVEL      EMPNO ENAME             MGR

---------- ---------- ---------- ----------

         1       7839 KING

         2       7566 JONES            7839

         3       7788 SCOTT            7566

...

One can produce an indented report by using the level number to substring or lpad() a series of spaces, and concatenate that to the string. Look at this example:

SQL> SELECT     LPAD(' ', LEVEL * 2) || ename

  2    FROM     emp

  3  CONNECT BY PRIOR empno = mgr

  4    START WITH mgr IS NULL;

LPAD(,LEVEL*2)||ENAME

------------------------------------------------------

  KING

    JONES

      SCOTT

...

Use the "start with" clause to specify the start of the tree. More than one record can match the starting condition. One disadvantage of having a "connect by prior" clause is that you cannot perform a join to other tables. The "connect by prior" clause is rarely implemented in the other database offerings. Trying to do this programmatically is difficult as one has to do the top level query first, then, for each of the records open a cursor to look for child nodes.
One way of working around this is to use PL/SQL, open the driving cursor with the "connect by prior" statement, and the select matching records from other tables on a row-by-row basis, inserting the results into a temporary table for later retrieval.

NOTE: Tree-structured queries are definitely non-relational (enough to kill Codd and make him roll in his grave). Also, this feature is not often found in other database offerings.

15. How does one count/sum data values in a column?

Use this simple query to count the number of data values in a column:

select my_table_column, count(*)

from   my_table

group  by my_table_column;

16. How does one drop/ rename a columns in a table?

Drop a column
From Oracle 8i one can DROP a column from a table. Look at this demonstrating the ALTER TABLE table_name DROP COLUMN column_name; command.

Workarounds for older releases:

Rename a column

From Oracle 9i one can RENAME a column from a table. Look at this example:

ALTER TABLE tablename RENAME COLUMN oldcolumn TO newcolumn;

Workarounds for older releases:
Use a view with correct column names:

rename t1 to t1_base;

create view t1 >column list with new name> as select * from t1_base;

Recreate the table with correct column names:

create table t2 >column list with new name> as select * from t1;

drop table t1;

rename t2 to t1;

17. How does one implement IF-THEN-ELSE logic in a SELECT statement?

Here is the syntax for the CASE-statement:

CASE exp WHEN comparison_exp1 THEN return_exp1

        [WHEN comparison_exp2 THEN return_exp2

         WHEN comparison_exp3 THEN return_exp3

          ELSE else_exp

        ]

END

And for DECODE:

DECODE( col | exprn, srch1, rslt1 [, srch2, rslt2,...,] [,default] )

18. How does one prevent Oracle from using an Index?

In certain cases, one may want to disable the use of a specific, or all indexes for a given query. Here are some examples:
Adding an expression to the indexed column

SQL>select count(*) from t where empno+0=1000;

  COUNT(*)

----------

         1


Execution Plan

--------------------------------------------- ----- --------

   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=3)

   1    0   SORT (AGGREGATE)

   2    1     TABLE ACCESS (FULL) OF 'T' (Cost=2 Card=1 Bytes=3)

Specifying the FULL hint to force full table scan

SQL>select /*+ FULL(t) */ * from t where empno=1000;

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO GRADE

---------- ---------- --------- ---------- --------- ---------- ---------- ---------- ----------

      1000 Victor     DBA             7839 20-MAY-03      11000          0         10 JUNIOR


Execution Plan

--------------------------------------------- ----- --------

   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=41)

   1    0   TABLE ACCESS (FULL) OF 'T' (Cost=2 Card=1 Bytes=41)

Specifying NO_INDEX hint

SQL>select /*+ NO_INDEX(T) */ count(*) from t where empno=1000;

  COUNT(*)

----------

         1


Execution Plan

--------------------------------------------- ----- --------

   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=3)

   1    0   SORT (AGGREGATE)

   2    1     TABLE ACCESS (FULL) OF 'T' (Cost=2 Card=1 Bytes=3)

Using a function over the indexed column

SQL>select count(*) from t where to_number(empno)=1000;

  COUNT(*)

----------

         1


Execution Plan

--------------------------------------------- ----- --------

   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=3)

   1    0   SORT (AGGREGATE)

   2    1     TABLE ACCESS (FULL) OF 'T' (Cost=2 Card=1 Bytes=3)

19. How does one select EVERY Nth row from a table?

SELECT *

FROM   emp

WHERE  (ROWID,0) IN (SELECT ROWID, MOD(ROWNUM,4)

                     FROM   emp);

20.How does one select the LAST N rows from a table?

Get the bottom 10 employees based on their salary

SELECT ename, sal

  FROM ( SELECT ename, sal, RANK() OVER (ORDER BY sal) sal_rank

           FROM emp )

 WHERE sal_rank <= 10;

Select the employees getting the lowest 10 salaries

SELECT ename, sal

  FROM ( SELECT ename, sal, DENSE_RANK() OVER (ORDER BY sal) sal_dense_rank

           FROM emp )

 WHERE sal_dense_rank <= 10;

21. How does one select the TOP N rows from a table?

Get the top 10 employees based on their salary

SELECT ename, sal

  FROM ( SELECT ename, sal, RANK() OVER (ORDER BY sal DESC) sal_rank

           FROM emp )

 WHERE sal_rank <= 10;

Select the employees making the top 10 salaries

SELECT ename, sal

  FROM ( SELECT ename, sal, DENSE_RANK() OVER (ORDER BY sal DESC) sal_dense_rank

           FROM emp )

 WHERE sal_dense_rank <= 10;

22. How to generate a text graphs (histograms) using SQL?

SELECT d.dname AS "Department",

             LPAD('+', COUNT(*), '+') as "Graph"

  FROM emp e, dept d

 WHERE e.deptno = d.deptno

 GROUP BY d.dname;

Sample output:

Department     Graph

-------------- --------------------------------------------------

ACCOUNTING     +++

RESEARCH       +++++

SALES          ++++++

In the above example, the value returned by COUNT(*) is used to control the number of "*" characters to return for each department. We simply pass COUNT(*) as an argument to the string function LPAD (or RPAD) to return the desired number of *'s.

23. What is the difference between VARCHAR, VARCHAR2 and CHAR data types?

Both CHAR and VARCHAR2 types are used to store character string values, however, they behave very differently. The VARCHAR type should not be used:
CHAR

CHAR should be used for storing fix length character strings. String values will be space/blank padded before stored on disk. If this type is used to store varibale length strings, it will waste a lot of disk space.

SQL> CREATE TABLE char_test (col1 CHAR(10));

Table created.


SQL> INSERT INTO char_test VALUES ('qwerty');

1 row created.


SQL> SELECT col1, length(col1), dump(col1) "ASCII Dump" FROM char_test;

COL1       LENGTH(COL1) ASCII Dump

---------- ------------ ------------------------------------------------------------

qwerty               10 Typ=96 Len=10: 113,119,101,114,116,121,32,32,32,32

Note: ASCII character 32 is a blank space.
VARCHAR

Currently VARCHAR behaves exactly the same as VARCHAR2. However, this type should not be used as it is reserved for future usage.

SQL> CREATE TABLE varchar_test (col1 VARCHAR2(10));

Table created.


SQL> INSERT INTO varchar_test VALUES ('qwerty');

1 row created.


SQL> SELECT col1, length(col1), dump(col1) "ASCII Dump" FROM varchar_test;

COL1       LENGTH(COL1) ASCII Dump

---------- ------------ ------------------------------------------------------------

qwerty                6 Typ=1 Len=6: 113,119,101,114,116,121

VARCHAR2
VARCHAR2 is used to store variable length character strings. The string value's length will be stored on disk with the value itself.

SQL> CREATE TABLE varchar2_test (col1 VARCHAR2(10));

Table created.


SQL> INSERT INTO varchar2_test VALUES ('qwerty');

1 row created.


SQL> SELECT col1, length(col1), dump(col1) "ASCII Dump" FROM varchar2_test;

COL1       LENGTH(COL1) ASCII Dump

---------- ------------ ------------------------------------------------------------

qwerty                6 Typ=1 Len=6: 113,119,101,114,116,121



1.What is the SQL?
SQL stands for Structure Query Language. SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database.

2.What is SQL*Plus?
SQL*Plus is an application that recognizes & executes SQL commands & specialized SQL*Plus commands that can customize reports, provide help & edit facility & maintain system variables.

3.What is NVL?
NVL : Null value function converts a null value to a non-null value for the purpose of evaluating an expression. Numeric Functions accept numeric I/P & return numeric values. They are MOD, SQRT, ROUND, TRUNC & POWER.

4. What is Date Functions?
Date Functions are ADD_MONTHS, LAST_DAY, NEXT_DAY, MONTHS_BETWEEN & SYSDATE.

5.What is Character Functions?

Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional functions are GREATEST & LEAST. Group Functions returns results based upon groups of rows rather than one result per row, use group functions. They are AVG, COUNT, MAX, MIN & SUM.

6. What is TTITLE and BTITLE?
TTITLE & BTITLE are commands to control report headings & footers.

7. What is COLUMN?
COLUMN command define column headings & format data values.

8.What is BREAK?
BREAK command clarify reports by suppressing repeated values, skipping lines & allowing for controlled break points.

9. What is COMPUTE?
command control computations on subsets created by the BREAK command.

10. What is SET?
SET command changes the system variables affecting the report environment.

11. What is SPOOL?
SPOOL command creates a print file of the report.

12.What is a JOIN?
JOIN is the form of SELECT command that combines info from two or more tables.
Types of Joins are Simple (Equijoin & Non-Equijoin), Outer & Self join.
Equijoin returns rows from two or more tables joined together based upon a equality condition in the WHERE clause.
Non-Equijoin returns rows from two or more tables based upon a relationship other than the equality condition in the WHERE clause.
Outer Join combines two or more tables returning those rows from one table that have no direct match in the other table.
Self Join joins a table to itself as though it were two separate tables.

13. What is Union?
Union is the product of two or more tables.

14. What is Intersect?
Intersect is the product of two tables listing only the matching rows.

15. What is Minus?
Minus is the product of two tables listing only the non-matching rows.

16.What is Correlated Subquery?
Correlated Subquery is a subquery that is evaluated once for each row processed by the parent statement. Parent statement can be Select, Update or Delete. Use CRSQ to answer multipart questions whose answer depends on the value in each row processed by parent statement.

17. What is Multiple columns?
Multiple columns can be returned from a Nested Subquery.

18.What is Sequences?
Sequences are used for generating sequence numbers without any overhead of locking. Drawback is that after generating a sequence number if the transaction is rolled back, then that sequence number is lost.

19.What is Synonyms?
Synonyms is the alias name for table, views, sequences & procedures and are created for reasons of Security and Convenience.
Two levels are Public - created by DBA & accessible to all the users. Private - Accessible to creator only. Advantages are referencing without specifying the owner and Flexibility to customize a more meaningful naming convention.

20.What is Indexes?
Indexes are optional structures associated with tables used to speed query execution and/or guarantee uniqueness. Create an index if there are frequent retrieval of fewer than 10-15% of the rows in a large table and columns are referenced frequently in the WHERE clause. Implied tradeoff is query speed vs. update speed. Oracle automatically update indexes. Concatenated index max. is 16 columns.

21.What is Data types?
Max. columns in a table is 255. Max. Char size is 255, Long is 64K & Number is 38 digits.
Cannot Query on a long column.
Char, Varchar2 Max. size is 2000 & default is 1 byte.
Number(p,s) p is precision range 1 to 38, s is scale -84 to 127.
Long Character data of variable length upto 2GB.
Date Range from Jan 4712 BC to Dec 4712 AD.
Raw Stores Binary data (Graphics Image & Digitized Sound). Max. is 255 bytes.
Mslabel Binary format of an OS label. Used primarily with Trusted Oracle.

22. Order of SQL statement execution?
Where clause, Group By clause, Having clause, Order By clause & Select.

23.What is Transaction?
Transaction is defined as all changes made to the database between successive commits.

24.What is Commit?
Commit is an event that attempts to make data in the database identical to the data in the form. It involves writing or posting data to the database and committing data to the database. Forms check the validity of the data in fields and records during a commit. Validity check are uniqueness, consistency and db restrictions.

25.What is Posting?
Posting is an event that writes Inserts, Updates & Deletes in the forms to the database but not committing these transactions to the database.

26.What is Rollback?
Rollback causes work in the current transaction to be undone.

27.What is Savepoint?
Savepoint is a point within a particular transaction to which you may rollback without rolling back the entire transaction.

28. What is Set Transaction?
Set Transaction is to establish properties for the current transaction.

29.What is Locking?
Locking are mechanisms intended to prevent destructive interaction between users accessing data. Locks are used to achieve.

30. What is Consistency?
Consistency : Assures users that the data they are changing or viewing is not changed until the are thro' with it.

31.What is SQL Integrity?
Assures database data and structures reflects all changes made to them in the correct sequence. Locks ensure data integrity and maximum concurrent access to data. Commit statement releases all locks. Types of locks are given below.
Data Locks protects data i.e. Table or Row lock.
Dictionary Locks protects the structure of database object i.e. ensures table's structure does not change for the duration of the transaction.
Internal Locks & Latches protects the internal database structures. They are automatic.
Exclusive Lock allows queries on locked table but no other activity is allowed.
Share Lock allows concurrent queries but prohibits updates to the locked tables.
Row Share allows concurrent access to the locked table but prohibits for a exclusive table lock.
Row Exclusive same as Row Share but prohibits locking in shared mode.
Shared Row Exclusive locks the whole table and allows users to look at rows in the table but prohibit others from locking the table in share or updating them.
Share Update are synonymous with Row Share.

32.What is SQL Deadlock?
Deadlock is a unique situation in a multi user system that causes two or more users to wait indefinitely for a locked resource. First user needs a resource locked by the second user and the second user needs a resource locked by the first user. To avoid dead locks, avoid using exclusive table lock and if using, use it in the same sequence and use Commit frequently to release locks.

33. What is Mutating SQL Table?
Mutating Table is a table that is currently being modified by an Insert, Update or Delete statement. Constraining Table is a table that a triggering statement might need to read either directly for a SQL statement or indirectly for a declarative Referential Integrity constraints. Pseudo Columns behaves like a column in a table but are not actually stored in the table. E.g. Currval, Nextval, Rowid, Rownum, Level etc.

34.What is SQL*Loader?
SQL*Loader is a product for moving data in external files into tables in an Oracle database. To load data from external files into an Oracle database, two types of input must be provided to SQL*Loader : the data itself and the control file. The control file describes the data to be loaded. It describes the Names and format of the data files, Specifications for loading data and the Data to be loaded (optional). Invoking the loader sqlload username/password controlfilename <options>.

35.The most important DDL statements in SQL are?
CREATE TABLE - creates a new database table

ALTER TABLE - alters (changes) a database table

DROP TABLE - deletes a database table

CREATE INDEX - creates an index (search key)

DROP INDEX - deletes an index

36. Operators used in SELECT statements are?
= Equal
<> or != Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern

37.SELECT statements in SQL?
SELECT column_name(s) FROM table_name
SELECT DISTINCT column_name(s) FROM table_name
SELECT column FROM table WHERE column operator value
SELECT column FROM table WHERE column LIKE pattern
SELECT column,SUM(column) FROM table GROUP BY column
SELECT column,SUM(column) FROM table GROUP BY column HAVING SUM(column) condition value
Note that single quotes around text values and numeric values should not be enclosed in quotes. Double quotes may be acceptable in some databases.

38.The SELECT INTO Statement is most often used to create backup copies of tables or for archiving records?
SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source
SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source WHERE column_name operator value

39.The INSERT INTO Statements in SQL?
INSERT INTO table_name VALUES (value1, value2,....)
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)

40. The Update Statement in SQL.?
UPDATE table_name SET column_name = new_value WHERE column_name = some_value

41. The Delete Statements in SQL.?
DELETE FROM table_name WHERE column_name = some_value

Delete All Rows:
DELETE FROM table_name or DELETE * FROM table_name

41. Sort the Rows in SQL.?
Sort the Rows:
SELECT column1, column2, ... FROM table_name ORDER BY columnX, columnY, ..
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC, columnY ASC

42.The IN operator may be used if you know the exact value you want to return for at least one of the columns.?
SELECT column_name FROM table_name WHERE column_name IN (value1,value2,..)

43. BETWEEN ... AND operators in SQL.?
SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2 The values can be numbers, text, or dates.
44.What is the use of CASCADE CONSTRAINTS?
When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.
45.What Is SQL?
SQL (pronounced as the letters S-Q-L or as sequel) is an abbreviation for Structured Query Language. SQL is a language designed specifically for communicating with databases. SQL is designed to do one thing and do it well—provide you with a simple and efficient way to read and write data from a database.

46.Which command displays the SQL command in the SQL buffer, and then executes it?
 RUN
47.What is the difference between Truncate & Drop?
48.Explain SQL Having?

49.Difference between SQL Having & Where?

50.Difference between SQL IN/SQL Exists?
 51.Difference between SQL NOT IN/SQL NOT Exists?
52.Difference between SQL UNION/SQL UNION ALL?

53.Explain SQL TOP.?

54.How to delete duplicate records in a table?

55.How to find duplicate records with the number they are duplicated?
SELECT Id, count (*) as num_records
from table 
group by id 
having count (*) > 1
56.What is a PRIMARY KEY?
The PRIMARY KEY is the column(s) used to uniquely identify each row of a table.
57.What is a FOREIGN KEY?
A FOREIGN KEY is one or more columns whose values are based on the PRIMARY or CANDIDATE KEY values from the database.
58.What is a UNIQUE KEY?
A UNIQUE KEY is one or more columns that must be unique for each row of the table.
59.What is the difference between UNIQUE and PRIMARY KEY?
The UNIQUE KEY column restricts entry of duplicate values but entry of NULL value is allowed. In case of PRIMARY KEY columns entry of duplicate as well as <null> value is also restricted.
60.Difference between Unique Key and Primary Key.?

61.Difference between Cast & Convert.?


62.Explain SQL Group by and give examples.?

63.How can you call a PL/SQL procedure from SQL?
By use of the EXECUTE (short form EXEC) command.

64.Which is the subset of SQL commands used to manipulate Oracle Database structures?
Data Definition Language (DDL)

65.Write a query to select the Nth highest salary from a table.?

66.Write a query to select the 2nd highest salary from a table.?

67.Write a query to select the second highest salary from a table.?
SELECT max(salary) AS salary_2
FROM emp
WHERE salary < (SELECT max(salary) AS salary_1                              
FROM emp)
68.Write a query to select the 5th highest salary from a table.?
SELECT min(salary) AS high5 
FROM employee 
WHERE salary IN(SELECT DISTINCT TOP 5 salary                              
FROM employee                              
ORDER BY salary DESC)
69.What command is used to get back the privileges offered by the GRANT command?
Revoke
70.How do you execute a host operating system command from within SQL?
By use of the exclamation point “!” (in UNIX and some other OS) or the HOST (HO) command.

71.What command is used to create a table by copying the structure of another table?

CREATE TABLE .. AS SELECT command

72.Give examples of Create Table?

73.

74.What is the difference between Delete and Truncate command in SQL?
Delete command and truncate command both will delete the data, however the truncate command can not be rolled back as delete can be. TRUNCATE is a DDL command whereas DELETE is a DML command. The delete command can be used for selected records using the where clause but with the truncate command we have to loose data. DELETE statement is a logged operation and hence takes more time then truncate. 

75.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 variable, place the ampersanded variable in the code itself: “select * from dba_tables where owner=&owner_name;” . Use of double ampersands tells SQLPLUS to resubstitute the value for each subsequent use of the variable, a single ampersand will cause a reprompt for the value unless an ACCEPT statement is used to get the value from the user. 

76.What SQLPlus command is used to format output from a select?
This is best done with the COLUMN command. 

77.Can Primary key is a Foreign Key on the same table?
Yes 

78.You want to determine the location of identical rows in a table before attempting to place a unique index on the table, how can this be done?
Oracle tables always have one guaranteed unique column, the rowid column. If you use a min/max function against your rowid and then select against the proposed primary key you can squeeze out the rowids of the duplicate rows pretty quick.
 For example:- select rowid from emp e
where e.rowid > (select min(x.rowid)
from emp x
where x.emp_no = e.emp_no);

79.What is the use of the DROP option in the ALTER TABLE command?
It is used to drop constraints specified on the table. 

80.What is a Cartesian product?
A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows where x, y, z correspond to the number of rows in each table involved in the join. 

81.How do you prevent output from coming to the screen?
The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns off screen output. This option can be shortened to TERM. 

82.What is the use of CASCADE CONSTRAINTS?
When this clause is used with the DROP command, a parent table can be dropped even when a child table exists. 

83.Which function is used to find the largest integer less than or equal to a specific value?
FLOOR 
 Consider the below DEPT and EMPLOYEE table and answer the below queries.
 DEPT
DEPTNO (NOT NULL , NUMBER(2)),
DNAME (VARCHAR2(14)),
LOC (VARCHAR2(13)
 EMPLOYEE
EMPNO (NOT NULL , NUMBER(4)),
ENAME (VARCHAR2(10)),
JOB (VARCHAR2(9)),
MGR (NUMBER(4)),
HIREDATE (DATE),
SAL (NUMBER(7,2)),
COMM (NUMBER(7,2)),
DEPTNO (NUMBER(2))
 MGR is the EMPno of the Employee whom the Employee reports to.
DEPTNO is a foreign key.

84. List all the Employees who have at least one person reporting to them.?
SELECT ENAME FROM EMPLOYEE WHERE EMPNO IN (SELECT MGR FROM EMPLOYEE);
85. List the highest salary paid for each job.?
SELECT JOB, MAX(SAL) FROM EMPLOYEE GROUP BY JOB
86. In which year did most people join the company? Display the year and the number of Employees.?
SELECT TO_CHAR(HIREDATE,'YYYY') "YEAR", COUNT(EMPNO) "NO. OF EMPLOYEES"
FROM EMPLOYEE
GROUP BY TO_CHAR(HIREDATE,'YYYY')
HAVING COUNT(EMPNO) = (SELECT MAX(COUNT(EMPNO))
FROM EMPLOYEE
GROUP BY TO_CHAR(HIREDATE,'YYYY'));
87. Write a correlated sub-query to list out the Employees who earn more than the average salary of their department.?
SELECT ENAME,SAL
FROM EMPLOYEE E
WHERE SAL > (SELECT AVG(SAL)
FROM EMPLOYEE F
WHERE E.DEPTNO = F.DEPTNO);
88. Find the nth maximum salary.?
 SELECT ENAME, SAL
FROM EMPLOYEE A
WHERE &N = (SELECT COUNT (DISTINCT(SAL))
FROM EMPLOYEE B
WHERE A.SAL<=B.SAL);
89. Select the duplicate records (Records, which are inserted, that already exist) in the EMPLOYEE table.?
SELECT * FROM EMPLOYEE A
WHERE A.EMPNO IN (SELECT EMPNO                                         
FROM EMPLOYEE                                  
GROUP BY EMPNO                                          
HAVING COUNT(EMPNO)>1)
AND A.ROWID!=MIN (ROWID));
90. Write a query to list the length of service of the Employees (of the form n years and m months).?
SELECT ENAME "EMPLOYEE",TO_CHAR(TRUNC(MONTHS_BETWEEN(SYSDATE,HIREDATE)/12))
||' YEARS '|| TO_CHAR(TRUNC(MOD(MONTHS_BETWEEN
(SYSDATE, HIREDATE),12)))||' MONTHS ' "LENGTH OF SERVICE"
FROM EMPLOYEE;


1. How can variables be passed to a SQL routine?
Level: Low
Expected answer: 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 variable, place the ampersanded variable in the code itself:

"select * from dba_tables where owner=&owner_name;" . Use of double ampersands tells SQLPLUS to resubstitute the value for each subsequent use of the variable, a single ampersand will cause a reprompt for the value unless an ACCEPT statement is used to get the value from the user.
2. You want to include a carriage return/linefeed in your output from a SQL script, how can you do this?
Level: Intermediate to high
Expected answer: The best method is to use the CHR() function (CHR(10) is a return/linefeed) and the concatenation function "||". Another method, although it is hard to document and isn?t always portable is to use the return/linefeed as a part of a quoted string.
3. How can you call a PL/SQL procedure from SQL?
Level: Intermediate
Expected answer: By use of the EXECUTE (short form EXEC) command.
4. How do you execute a host operating system command from within SQL?
Level: Low
Expected answer: By use of the exclamation point "!" (in UNIX and some other OS) or the HOST (HO) command.
5. You want to use SQL to build SQL, what is this called and give an example
Level: Intermediate to high
Expected answer: This is called dynamic SQL. An example would be:

set lines 90 pages 0 termout off feedback off verify off

spool drop_all.sql

select ?drop user ?||username||? cascade;? from dba_users

where username not in ("SYS?,?SYSTEM?);

spool off

Essentially you are looking to see that they know to include a command (in this case DROP USER...CASCADE;) and that you need to concatenate using the ?||? the values selected from the database.

6. What SQLPlus command is used to format output from a select?

Level: low

Expected answer: This is best done with the COLUMN command.

7. You want to group the following set of select returns, what can you group on?

Max(sum_of_cost), min(sum_of_cost), count(item_no), item_no

Level: Intermediate

Expected answer: The only column that can be grouped on is the "item_no" column, the rest have aggregate functions associated with them.
8. What special Oracle feature allows you to specify how the cost based system treats a SQL statement?
Level: Intermediate to high
Expected answer: The COST based system allows the use of HINTs to control the optimizer path selection. If they can give some example hints such as FIRST ROWS, ALL ROWS, USING INDEX, STAR, even better.
9. You want to determine the location of identical rows in a table before attempting to place a unique index on the table, how can this be done?
Level: High
Expected answer: Oracle tables always have one guaranteed unique column, the rowid column. If you use a min/max function against your rowid and then select against the proposed primary key you can squeeze out the rowids of the duplicate rows pretty quick. For example:

select rowid from emp e

where e.rowid > (select min(x.rowid)

from emp x

where x.emp_no = e.emp_no);

In the situation where multiple columns make up the proposed key, they must all be used in the where clause.
10. What is a Cartesian product?
Level: Low
Expected answer: A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows where x, y, z correspond to the number of rows in each table involved in the join.
11. You are joining a local and a remote table, the network manager complains about the traffic involved, how can you reduce the network traffic?
Level: High
Expected answer: Push the processing of the remote data to the remote instance by using a view to pre-select the information for the join. This will result in only the data required for the join being sent across.

12. What is the default ordering of an ORDER BY clause in a SELECT statement?

Level: Low

Expected answer: Ascending
13. What is tkprof and how is it used?
Level: Intermediate to high
Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.
14. What is explain plan and how is it used?
Level: Intermediate to high
Expected answer: The EXPLAIN PLAN command is a tool to tune SQL statements. To use it you must have an explain_table generated in the user you are running the explain plan for. This is created using the utlxplan.sql script. Once the explain plan table exists you run the explain plan command giving as its argument the SQL statement to be explained. The explain_plan table is then queried to see the execution plan of the statement. Explain plans can also be run using tkprof.
15. How do you set the number of lines on a page of output? The width?
Level: Low
Expected answer: The SET command in SQLPLUS is used to control the number of lines generated per page and the width of those lines, for example SET PAGESIZE 60 LINESIZE 80 will generate reports that are 60 lines long with a line width of 80 characters. The PAGESIZE and LINESIZE options can be shortened to PAGES and LINES.

16. How do you prevent output from coming to the screen?

Level: Low

Expected answer: The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns off screen output. This option can be shortened to TERM.
17. How do you prevent Oracle from giving you informational messages during and after a SQL statement execution?
Level: Low
Expected answer: The SET options FEEDBACK and VERIFY can be set to OFF.
18. How do you generate file output from SQL?
Level: Low
Expected answer: By use of the SPOOL command
19. What is normalization? Explain different levels of normalization?

Check out the article Q100139 from Microsoft knowledge base and of course, there's much more information available in the net. It'll be a good idea to get a hold of any RDBMS fundamentals text book, especially the one by C. J. Date. Most of the times, it will be okay if you can explain till third normal form.

20. What is denormalization and when would you go for it?

As the name indicates, denormalization is the reverse process of normalization. It's the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.

21. How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?

One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships. One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships. Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.
It will be a good idea to read up a database designing fundamentals text book.

22. What's the difference between a primary key and a unique key?

Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

23. What are user defined datatypes and when you should go for them?

User defined datatypes let you extend the base SQL Server datatypes by providing a descriptive name, and format to the database. Take for example, in your database, there is a column called Flight_Num which appears in many tables. In all these tables it should be varchar(8). In this case you could create a user defined datatype called Flight_num_type of varchar(8) and use it across all your tables.
See sp_addtype, sp_droptype in books online.

24. What is bit datatype and what's the information that can be stored inside a bit column?

Bit datatype is used to store boolean information like 1 or 0 (true or false). Untill SQL Server 6.5 bit datatype could hold either a 1 or 0 and there was no support for NULL. But from SQL Server 7.0 onwards, bit datatype can represent a third state, which is NULL.

25. Define candidate key, alternate key, composite key?

A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys.
A key formed by combining at least two or more columns is called composite key.

26. What are defaults? Is there a column to which a default can't be bound?

A default is a value that will be used by a column, if no value is supplied to that column while inserting data. IDENTITY columns and timestamp columns can't have defaults bound to them. See CREATE DEFUALT in books online.

27. What is a transaction and what are ACID properties?

A transaction is a logical unit of work in which, all the steps must be performed or none. ACID stands for Atomicity, Consistency, Isolation, Durability. These are the properties of a transaction. For more information and explanation of these properties, see SQL Server books online or any RDBMS fundamentals text book.

28. Explain different isolation levels ?

An isolation level determines the degree of isolation of data between concurrent transactions. The default SQL Server isolation level is Read Committed. Here are the other isolation levels (in the ascending order of isolation): Read Uncommitted, Read Committed, Repeatable Read, Serializable. See SQL Server books online for an explanation of the isolation levels. Be sure to read about SET TRANSACTION ISOLATION LEVEL, which lets you customize the isolation level at the connection level.
CREATE INDEX myIndex ON myTable(myColumn)

29. What type of Index will get created after executing the above statement?

Non-clustered index. Important thing to note: By default a clustered index gets created on the primary key, unless specified otherwise.

30. What's the maximum size of a row?

8060 bytes. Don't be surprised with questions like 'what is the maximum number of columns per table'. Check out SQL Server books online for the page titled: "Maximum Capacity Specifications".

31. Explain Active/Active and Active/Passive cluster configurations?

Hopefully you have experience setting up cluster servers. But if you don't, at least be familiar with the way clustering works and the two clusterning configurations Active/Active and Active/Passive. SQL Server books online has enough information on this topic and there is a good white paper available on Microsoft site.

32. Explain the architecture of SQL Server?

This is a very important question and you better be able to answer it if consider yourself a DBA. SQL Server books online is the best place to read about SQL Server architecture. Read up the chapter dedicated to SQL Server Architecture.

33. What is lock escalation?

Lock escalation is the process of converting a lot of low level locks (like row locks, page locks) into higher level locks (like table locks). Every lock is a memory structure too many locks would mean, more memory being occupied by locks. To prevent this from happening, SQL Server escalates the many fine-grain locks to fewer coarse-grain locks. Lock escalation threshold was definable in SQL Server 6.5, but from SQL Server 7.0 onwards it's dynamically managed by SQL Server.

34. What's the difference between DELETE TABLE and TRUNCATE TABLE commands?

DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won't log the deletion of each row, instead it logs the deallocation of the data pages of the table, which makes it faster. Of course, TRUNCATE TABLE can be rolled back.

35. Explain the storage models of OLAP?

Check out MOLAP, ROLAP and HOLAP in SQL Server books online for more infomation.

36. What are the new features introduced in SQL Server 2000 (or the latest release of SQL Server at the time of your interview)? What changed between the previous version of SQL Server and the current version?

This question is generally asked to see how current is your knowledge. Generally there is a section in the beginning of the books online titled "What's New", which has all such information. Of course, reading just that is not enough, you should have tried those things to better answer the questions. Also check out the section titled "Backward Compatibility" in books online which talks about the changes that have taken place in the new version.

37. What are constraints? Explain different types of constraints?

Constraints enable the RDBMS enforce the integrity of the database automatically, without needing you to create triggers, rule or defaults.
Types of constraints: NOT NULL, CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY
For an explanation of these constraints see books online for the pages titled: "Constraints" and "CREATE TABLE", "ALTER TABLE"

38. Whar is an index? What are the types of indexes? How many clustered indexes can be created on a table? I create a separate index on each column of a table. what are the advantages and disadvantages of this approach?

Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quicker.

Indexes are of two types. Clustered indexes and non-clustered indexes. When you craete a clustered index on a table, all the rows in the table are stored in the order of the clustered index key. So, there can be only one clustered index per table. Non-clustered indexes have their own storage separate from the table data storage. Non-clustered indexes are stored as B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and it's row locater. The row located could be the RID or the Clustered index key, depending up on the absence or presence of clustered index on the table.
If you create an index on each column of a table, it improves the query performance, as the query optimizer can choose from all the existing indexes to come up with an efficient execution plan. At the same t ime, data modification operations (such as INSERT, UPDATE, DELETE) will become slow, as every time data changes in the table, all the indexes need to be updated. Another disadvantage is that, indexes need disk space, the more indexes you have, more disk space is used.

39. What is RAID and what are different types of RAID configurations?

RAID stands for Redundant Array of Inexpensive Disks, used to provide fault tolerance to database servers. There are six RAID levels 0 through 5 offering different levels of performance, fault tolerance. MSDN has some information about RAID levels and for detailed information, check out the RAID advisory board's homepage

40. What are the steps you will take to improve performance of a poor performing query?

This is a very open ended question and there could be a lot of reasons behind the poor performance of a query. But some general issues that you could talk about would be: No indexes, table scans, missing or out of date statistics, blocking, excess recompilations of stored procedures, procedures and triggers without SET NOCOUNT ON, poorly written query with unnecessarily complicated joins, too much normalization, excess usage of cursors and temporary tables.
Some of the tools/ways that help you troubleshooting performance problems are: SET SHOWPLAN_ALL ON, SET SHOWPLAN_TEXT ON, SET STATISTICS IO ON, SQL Server Profiler, Windows NT /2000 Performance monitor, Graphical execution plan in Query Analyzer.
Download the white paper on performance tuning SQL Server from Microsoft web site. Don't forget to check out sql-server-performance.com

41. What are the steps you will take, if you are tasked with securing an SQL Server?

Again this is another open ended question. Here are some things you could talk about: Preferring NT authentication, using server, databse and application roles to control access to the data, securing the physical database files using NTFS permissions, using an unguessable SA password, restricting physical access to the SQL Server, renaming the Administrator account on the SQL Server computer, disabling the Guest account, enabling auditing, using multiprotocol encryption, setting up SSL, setting up firewalls, isolating SQL Server from the web server etc.
Read the white paper on SQL Server security from Microsoft website. Also check out My SQL Server security best practices

42. What is a deadlock and what is a live lock? How will you go about resolving deadlocks?

Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other's piece. Each process would wait indefinitely for the other to release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user's process.
A livelock is one, where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.
Check out SET DEADLOCK_PRIORITY and "Minimizing Deadlocks" in SQL Server books online. Also check out the article Q169960 from Microsoft knowledge base.

43. What is blocking and how would you troubleshoot it?

Blocking happens when one connection from an application holds a lock and a second connection requires a conflicting lock type. This forces the second connection to wait, blocked on the first.
Read up the following topics in SQL Server books online: Understanding and avoiding blocking, Coding efficient transactions.

44. Explain CREATE DATABASE syntax?

Many of us are used to craeting databases from the Enterprise Manager or by just issuing the command: CREATE DATABAE MyDB. But what if you have to create a database with two filegroups, one on drive C and the other on drive D with log on drive E with an initial size of 600 MB and with a growth factor of 15%? That's why being a DBA you should be familiar with the CREATE DATABASE syntax. Check out SQL Server books online for more information.

45. How to restart SQL Server in single user mode? How to start SQL Server in minimal configuration mode?

SQL Server can be started from command line, using the SQLSERVR.EXE. This EXE has some very important parameters with which a DBA should be familiar with. -m is used for starting SQL Server in single user mode and -f is used to start the SQL Server in minimal confuguration mode. Check out SQL Server books online for more parameters and their explanations.

46. As a part of your job, what are the DBCC commands that you commonly use for database maintenance?

DBCC CHECKDB, DBCC CHECKTABLE, DBCC CHECKCATALOG, DBCC CHECKALLOC, DBCC SHOWCONTIG, DBCC SHRINKDATABASE, DBCC SHRINKFILE etc. But there are a whole load of DBCC commands which are very useful for DBAs. Check out SQL Server books online for more information.

47. What are statistics, under what circumstances they go out of date, how do you update them?

Statistics determine the selectivity of the indexes. If an indexed column has unique values then the selectivity of that index is more, as opposed to an index with non-unique values. Query optimizer uses these indexes in determining whether to choose an index or not while executing a query.
Some situations under which you should update statistics: 1) If there is significant change in the key values in the index 2) If a large amount of data in an indexed column has been added, changed, or removed (that is, if the distribution of key values has changed), or the table has been truncated using the TRUNCATE TABLE statement and then repopulated 3) Database is upgraded from a previous version
Look up SQL Server books online for the following commands: UPDATE STATISTICS, STATS_DATE, DBCC SHOW_STATISTICS, CREATE STATISTICS, DROP STATISTICS, sp_autostats, sp_createstats, sp_updatestats

48. What are the different ways of moving data/databases between servers and databases in SQL Server?

There are lots of options available, you have to choose your option depending upon your requirements. Some of the options you have are: BACKUP/RESTORE, dettaching and attaching databases, replication, DTS, BCP, logshipping, INSERT...SELECT, SELECT...INTO, creating INSERT scripts to generate data.

49. Explian different types of BACKUPs avaialabe in SQL Server? Given a particular scenario, how would you go about choosing a backup plan?

Types of backups you can create in SQL Sever 7.0+ are Full database backup, differential database backup, transaction log backup, filegroup backup. Check out the BACKUP and RESTORE commands in SQL Server books online. Be prepared to write the commands in your interview. Books online also has information on detailed backup/restore architecture and when one should go for a particular kind of backup.

50. What is database replicaion? What are the different types of replication you can set up in SQL Server?

Replication is the process of copying/moving data between databases on the same or different servers. SQL Server supports the following types of replication scenarios:
* Snapshot replication
* Transactional replication (with immediate updating subscribers, with queued updating subscribers)
* Merge replication
See SQL Server books online for indepth coverage on replication. Be prepared to explain how different replication agents function, what are the main system tables used in replication etc.

51. How to determine the service pack currently installed on SQL Server?

The global variable @@Version stores the build number of the sqlservr.exe, which is used to determine the service pack installed. To know more about this process visit SQL Server service packs and versions.

52. What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?

Cursors allow row-by-row prcessing of the resultsets.
Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.
Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.
Most of the times, set based operations can be used instead of cursors. Here is an example:
If you have to give a flat hike to your employees using the following criteria:
Salary between 30000 and 40000 -- 5000 hike
Salary between 40000 and 55000 -- 7000 hike
Salary between 55000 and 65000 -- 9000 hike
In this situation many developers tend to use a cursor, determine each employee's salary and update his salary according to the above formula. But the same can be achieved by multiple update statements or can be combined in a single UPDATE statement as shown below:

UPDATE tbl_emp SET salary =
CASE WHEN salary BETWEEN 30000 AND 40000 THEN salary + 5000
WHEN salary BETWEEN 40000 AND 55000 THEN salary + 7000
WHEN salary BETWEEN 55000 AND 65000 THEN salary + 10000
END

Another situation in which developers tend to use cursors: You need to call a stored procedure when a column in a particular row meets certain condition. You don't have to use cursors for this. This can be achieved using WHILE loop, as long as there is a unique key to identify each row. For examples of using WHILE loop for row by row processing, check out the 'My code library' section of my site or search for WHILE.

53. Write down the general syntax for a SELECT statements covering all the options?

Here's the basic syntax: (Also checkout SELECT in books online for advanced syntax).

SELECT select_list
[INTO new_table_]
FROM table_source
[WHERE search_condition]
[GROUP BY group_by__expression]
[HAVING search_condition]
[ORDER BY order__expression [ASC | DESC] ]


54. What is a join and explain different types of joins?

Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.
Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.
For more information see pages from books online titled: "Join Fundamentals" and "Using Joins".

55. Can you have a nested transaction?

Yes, very much. Check out BEGIN TRAN, COMMIT, ROLLBACK, SAVE TRAN and @@TRANCOUNT

56. What is an extended stored procedure? Can you instantiate a COM object by using T-SQL?

An extended stored procedure is a function within a DLL (written in a programming language like C, C++ using Open Data Services (ODS) API) that can be called from T-SQL, just the way we call normal stored procedures using the EXEC statement. See books online to learn how to create extended stored procedures and how to add them to SQL Server.
Yes, you can instantiate a COM (written in languages like VB, VC++) object from T-SQL by using sp_OACreate stored procedure. Also see books online for sp_OAMethod, sp_OAGetProperty, sp_OASetProperty, sp_OADestroy. For an example of creating a COM object in VB and calling it from T-SQL, see 'My code library' section of this site.

57. What is the system function to get the current user's user id?

USER_ID(). Also check out other system functions like USER_NAME(), SYSTEM_USER, SESSION_USER, CURRENT_USER, USER, SUSER_SID(), HOST_NAME().

58. What are triggers? How many triggers you can have on a table? How to invoke a trigger on demand?

Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table.
In SQL Server 6.5 you could define only 3 triggers per table, one for INSERT, one for UPDATE and one for DELETE. From SQL Server 7.0 onwards, this restriction is gone, and you could create multiple triggers per each action. But in 7.0 there's no way to control the order in which the triggers fire. In SQL Server 2000 you could specify which trigger fires first or fires last using sp_settriggerorder

Triggers can't be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.

Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.

Till SQL Server 7.0, triggers fire only after the data modification operation happens. So in a way, they are called post triggers. But in SQL Server 2000 you could create pre triggers also. Search SQL Server 2000 books online for INSTEAD OF triggers.

Also check out books online for 'inserted table', 'deleted table' and COLUMNS_UPDATED()

There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better?

Instantiating COM objects is a time consuming process and since you are doing it from within a trigger, it slows down the data insertion process. Same is the case with sending emails from triggers. This scenario can be better implemented by logging all the necessary data into a separate table, and have a job which periodically checks this table and does the needful.

59. What is a self join? Explain it with an example.

Self join is just like any other join, except that two instances of the same table will be joined in the query. Here is an example: Employees table which contains rows for normal employees as well as managers. So, to find out the managers of all the employees, you need a self join.
CREATE TABLE emp
(
empid int,
mgrid int,
empname char(10)
)

INSERT emp SELECT 1,2,'Vyas'
INSERT emp SELECT 2,3,'Mohan'
INSERT emp SELECT 3,NULL,'Shobha'
INSERT emp SELECT 4,2,'Shridhar'
INSERT emp SELECT 5,2,'Sourabh'

SELECT t1.empname [Employee], t2.empname [Manager]
FROM emp t1, emp t2
WHERE t1.mgrid = t2.empid

Here's an advanced query using a LEFT OUTER JOIN that even returns the employees without managers (super bosses)

SELECT t1.empname [Employee], COALESCE(t2.empname, 'No manager') [Manager]
FROM emp t1
LEFT OUTER JOIN
emp t2
ON
t1.mgrid = t2.empid

*********************END*********************



No comments:

ORA-08004: sequence IEX_DEL_BUFFERS_S.NEXTVAL exceeds MAXVALUE

 Error:- IEX: Scoring Engine Harness Error - ORA-08004: sequence IEX_DEL_BUFFERS_S.NEXTVAL exceeds MAXVALUE (Doc ID 2056754.1) SYMPTOMS:- Yo...