Oracle DBA Interview Questions.docx

December 20, 2017 | Author: radhashyam naak | Category: Oracle Database, Load Balancing (Computing), Databases, Sql, Backup
Share Embed Donate


Short Description

Download Oracle DBA Interview Questions.docx...

Description

Oracle DBA Interview Questions 1. What is the latest version of oracle database available on the market? Oracle Database 11g Release 2: 11.2.0.1 (released 2009-09-01) 2. What are the features of oracle database 11g? Oracle Real Application Testing This feature makes it easier to test systems before and after database upgrades and hardware and operating system changes so you can catch and fix problems more quickly. Enhanced Partitioning These capabilities include partitioning by parent/child references; partitioning by virtual columns, more composite partitioning choices; and interval partitioning, which automatically generates new partitions based on intervals, such as every day or every month. Advanced Compression Oracle Database 11g supports data compression for update, insert and delete operations commonly used in online transaction processing (OLTP) applications. Oracle Database 11g table compression improves database performance with better use of memory for caching data and reduced I/O for table scans. Flashback Data Archive Part of the Oracle Total Recall option, this feature lets you query data in selected tables “as of” earlier times, which adds a time dimension to your data for change tracking, information lifecycle management, auditing and compliance. Flashback data archive stores change data automatically to enable fast query access to old versions of the data. Oracle Secure Files This feature lets you store large objects such as images, large text objects, or advanced data types including XML, medical imaging, and geospatial raster objects inside the database. The performance is apparently comparable to file systems, and Oracle Secure Files provides advanced functionality including intelligent compression, transparent encryption and transparent deduplication. PL/SQL Function Result Cache This new PL/SQL function allows you cache frequently retrieved data, and get the data from the block buffer cache, instead of checking to see if the query has already been parsed, finding the data in the buffer and then returning it.

3. What are the roles of a dba?

DBA Responsibilities The job of the DBA seems to be everything that everyone else either doesn't want to do, or doesn't have the ability to do. DBAs get the enviable task of figuring out all of the things no one else can figure out. More seriously though, here is a list of typical DBA responsibilities: 

Installation, configuration and upgrading of Oracle server software and related products



Evaluate Oracle features and Oracle related products



Establish and maintain sound backup and recovery policies and procedures



Take care of the Database design and implementation



Implement and maintain database security (create and maintain users and roles, assign privileges)



Perform database tuning and performance monitoring



Perform application tuning and performance monitoring



Setup and maintain documentation and standards



Plan growth and changes (capacity planning)



Work as part of a team and provide 7x24 support when required



Perform general technical trouble shooting and give consultation to development teams



Interface with Oracle Corporation for technical support.



Patch Management and Version Control

4. Explain the steps for the manual creation of Db? In LINUX: 1. Create folders for Administration files $ cd /app/oracle/admin//

- ( Example db_name = xyz)

$ cd /app/oracle/admin/xyz $ mkdir adump cdump bdump dpdump pfile udump script Create/modify init.ora file under pfile

2. Create folders for physical files ( Datafiles, Redofiles, Controlfiles,etc.,) $ cd /app/oracle/oradata/

(Example db_name=xyz)

$ mkdir xyz

1. $ cd /app/oracle/product/10.2.0/dbs/ i. $ export ORACLE_SID= ii. $ orapwd file=oraxyzpw password=xyz entries=3 force=y 2. $ sqlplus /nolog 3. SQL> connect sys as sysdba Password: xyz

SQL> startup pfile=’/app/oracle/admin//pfile/init.ora ‘ nomount

Create database script(Createdb.sql) under script directory (/app/oracle/admin//script)

SQL > @/app/oracle/admin//script/dbcreate.sql Database created. SQL> @/app/oracle/product/10.2.0/rdbms/admin/catalog.sql SQL> @/app/oracle/product/10.2.0/rdbms/admin/catproc.sql

5. What are the Advantages of Using DBCA You can use its wizards to guide you through a selection of options providing an easy means of creating and tailoring your database. It allows you to provide varying levels of detail. You can provide a minimum of input and allow Oracle to make decisions for you, eliminating the need to spend time deciding how best to set parameters or structure the database. Optionally, it allows you to be very specific about parameter settings and file allocations. It builds efficient and effective databases that take advantage of Oracle's new features. It uses Optimal Flexible

Architecture (OFA), whereby database files and administrative files, including initialization files, follow standard naming and placement practices 6. What are the differences you have seen while installing Oracle on NT and UNIX platform? Oracle Server Oracle Instance + Oracle Database Oracle instance comprises of Background Process and memory structures in Unix all background processes are treated as independent processes but in windows all are combined together within oracle.exe. in Unix when a user logins he is dedicated to the server via an in depended process so if require you can kill a process through os level ..this is one of the major advantage of using oracle on Unix based system rather than windows system bcoz in case database stucks or hangs an independent process causing the problem can be killed and database will be made resumable immediately and one more diffrence is in windows you are require to create a service to start the instance by using oradim but in unix its not required .you can start the instance.in windows unique service name is required but in unix diffrent user can have the same service name started by them but its not advisable. 7. What is a database instance and Explain? SGA+Background Process Instance As soon as user process starts and server process takes control from user process instance created with help of background processes and most important background processes are dbwriter logwriter checkpoint SMON PMON and components of SGA are shared pooldatabase buffer cache redo log cache large pool stream pool. Most important library cache + Data Dictionary Shared Pool 8. How do you find whether the instance was started with pfile or spfile There are 3 different ways :1) SELECT name, value FROM v$parameter WHERE name = 'spfile'; //This query will return NULL if you are using PFILE 2) SHOW PARAMETER spfile // This query will returns NULL in the value column if you are using pfile and not spfile 3) SELECT COUNT(*) FROM v$spparameter WHERE value IS NOT NULL; // if the count is nonzero then the instance is using a spfile, and if the count is zero then it is using a pfile: By Default oracle will look into the default location depends on the o/s. Like in unix, oracle will check in $oracle_home/dbs directory and on windows it will check in oracle_home/database directory, and the content of pfile is just text based, but spfile content is in binary format, that is understandable by oracle very well. Also oracle server always check the spfile or pfile with these sequence :SPFILE.ORA SPFILE.ORA PFILE.ORA PFILE.ORA

9. Name the ORACLE Background Process and explain each functions ? Mandatory Processes DBWR - Database Writer. LGWR - Log Writer CKPT - Check Point SMON - System Monitor PMON - Process Monitor Optional Process ARCH - Archiver RECO - Recover Dnnn - Dispatcher and LCKn - Lock Snnn - Server. 10. What is the function of checkpoint (CKPT)? The Checkpoint (CKPT) process is responsible for signaling DBWR at checkpoints and updating all the data files and control files of the database. 11. What is PGA ? Program Global Area (PGA) is a memory buffer that contains data and control information for a server process. Program Global Area. The PGA is a memory region containing data and control information for a single process (server or background). One PGA is allocated for each server process; the PGA is exclusive to that server process and is read and written only by Oracle code acting on behalf of that process. A PGA is allocated by Oracle when a user connects to an Oracle database and a session is created. 12. What is User Process? A user process is created and maintained to execute the software code of an application program. It is a shadow process created automatically to facilitate communication between the user and the server process. 13.What Does DBWR do ? When Does DBWR write to the database? Database writer writes modified blocks from the database buffer cache to the data files. DBWn writes when: 1) checkpoint occurs 2) dirty buffers reach threshold 3) there are no free buffers 4) timeout occurs 5) RAC ping request is made 6) when any tablespace is taken offline, read only, drop or truncated & when begin backup

14. What does LGWR do? When does LGWR write to the database? Log Writer (LGWR) writes redo log entries generated in the redo log buffer of the SGA to on-line Redo Log File.LGWR is oracle background process.. all changes which have been made inthe database gets recorded in the redolog buffer.so when the users fires an commit statement LGWR writes these changes it into thr redolog files. and also writes it into files when the redolog buffer is one thrid full... and also when buffer is nealy 1mb full lgwr writes it into redologfiles. LGWr writes when: 1)at commit 2)when 1/3rd full 3)when there is 1mb of redo 4)every 3 seconds 5)before DBWn writes. 15. What are the functions of SMON? System Monitor (SMON) performs instance recovery at instance start-up. In amultiple instance system (one that uses the Parallel Server), SMON of one instance can also perform instance recovery for other instance that have failed SMON also cleans up temporary segments that are no longer in use and recovers dead transactions skipped during crash and instance recovery because of file-read or off-line errors. These transactions are eventually recovered by SMON when the table space or file is brought back on-line SMON also coalesces free extents within the database to make free space contiguous and easier to allocate. If server unplanned shutdown Power failure SMON Instant recovery. There is two type of Instant recovery 1st is Roll forward 2nd Roll back. Rollback means committed transaction. Roll forward means uncommitted transaction. 16. What are functions of PMON? Process Monitor (PMON) performs process recovery when a user process fails PMON is responsible for cleaning up the cache and Freeing resources that the process was using PMON also checks on dispatcher and server processes and restarts them if they have failed. 17. What is the function of ARCH? Archiver (ARCH) copies the on-line redo log files to archival storage when they are full. ARCH is active only when a database's redo log is used in ARCHIVELOG mode. 18. What is function of RECO? RECOver (RECO) is used to resolve distributed transactions that are pending due to a network or system failure in a distributed database. At timed intervals,the local RECO attempts to connect to remote databases and automatically complete the commit or rollback of the local portion of any pendingdistributed transactions.

19. What is the function of Dispatcher (Dnnn)? Dispatcher (Dnnn) process is responsible for routing requests from connected userprocesses to available shared server processes and returning the responses back to the appropriate user processes. 20. How many Dispatcher Processes are created? Atleast one Dispatcher process is created for every communication protocol in use. 21. What is the function of Lock (LCKn) Process? What is the maximum number of Lock Processes used? Lock (LCKn) are used for inter-instance locking when the ORACLE Parallel Server option is used.Though a single LCK process is sufficient for most Parallel Server systems up to Ten Locks (LCK0,....LCK9) are used for inter-instance locking. 22. Explain what are Oracle Catalog and Oracle Archive log? Oracle System Catalog : System Created Tables Which Contain Statistics and Useful Data Collected Automatically by the Database Engine to Help the Administrator or the regular users. There Are Several Kinds Of Catalogs V$_Catalog dba_Catalog User_Catalog Where as Archive Log Files are offline copies of Online Redo Log Files meaning : Once the Online Redo Log files are filled if database is running in archive log mode archiver saves these files to the archive destination. 23. What is PCT Free and PCT Used? What is PCT increase parameter in segment? What is growth factor? PCT FREE: PCTFREE is a block storage it use to mention how much space should be left in database block for future updates (updating the records eg. previously name kalyan after that we will update the name as kalyan kumar). If mention PCTFREE as 10 oracle will adding the new rows to block upto 90 Its allows 10 for future updates. PCTUSED: This is the parameter which specify in percent that a block can only used for insert or come in the freelist(list of blocks in segment ready for insert operation) when used space in a block is less than PCTUSED. Suppose value of pctused is 40 and pctfree is 20 then data can be inserted till 80 of the block directly. And suppose the used space is 60 and some one has perform a delete operation in a row in the same block which brings the used space to 50 .Now one cannot insert any record in the same block unless the used space comes down below 40 i.e. pctused. 24. What is dump destination? What are bdump, cdump and udump? Explain in detail? The dump destination is: Oracle_home/admin/ The UDUMP specifies user dump directory where all the user related information is stored in the

form of trace file. The BDUMP specifies background dump directory where background processes information and error logs are stored in the form of alert log file. The CDUMP specifies core dump directory where all the information related to core operations performed by oracle is stored. 25. What are four errors found in an alert (error) log that can ruin a DBA's appetite and how can you avoid them? If we are getting any issue regarding database while performing any activity we should check alert log file in dump destination. 1) Snapshot too old error (O1555) 2) Deadlock error 3) any issue regarding backup & recovery 26. Can you perform DML operations when the standby database is in read only in Standby Database? Standby can be of two types, physical standby and logical standby. Physical standby database is exactly the same in structure as primary database. When it is in read-only mode, SQL queries can be run on it. The other mode is redo-apply mode and database is not accessible for queries at that time. Logical standby database may have different structure from primary database. When it is in readonly mode, SQL statements generated from redo are applied and queries may be run concurrently. When in read-write mode, one can modify data in tables created in addition to primary schema. But this setting may be over written by specifying additional security options. So no DMLs are allowed on the standby database and the most important things is that Standby databases can always be opened in READ-ONLY mode which won't allow DMLs. 27. What will you do if in any condition you do not know how to troubleshoot the error at all and there are no seniors or your co-workers around? Check the alert.log in bdump.

28. How to convert local management tablespace to dictionary managed tablespace?

Local to Dictionary managed tablespcaes:

exec dbms_space_admin.Tablespace_Migrate_FROM_Local('tablespace'); Dictionary to locally managed tablespaces:

exec dbms_space_admin.Tablespace_Migrate_to_Local('tablespace');

29. When yesterday developer gives the following command: select count(*) from [table name] it gives the output within minutes, today the same command takes hours? What will you check? we have to take the sql trace. but it cannot be read by us. so we have to take the tkprof of this file which can be read by us. to take the sql trace fire the below command SQL>alter session set sql_trace true; then fire that sql statement SQL>select count(*) from [tablename]; it will generate a trace file in udump then stop the trace by following command SQL>alter session set sql_trace false; then produce a tkprof $tkprof [filename] [kprof filename] Have a look into the following tables : DBA_HIST_SQLSTAT dba_hist_snapshot by doing natural joins on these views for the SQL_ID you will know about any plan changes happened. Do corrective actions as per the findings. 30. How will you rectify if one of the rollback segments gets corrupted? The only option available is to restore and recover the database followed by opening the database with reset logs. 31. When exporting using file size parameter, if three files is generated. How the Oracle name these three files? When Export reaches the value you have specified for the maximum FILESIZE Export stops writing to the current file opens another export file with the next name specified by the FILE parameter and continues until complete or the maximum value of FILESIZE is again reached. If you do not specify sufficient export filenames to complete the export Export will prompt you to provide additional filenames. 32. Three users at a time giving the following command: alter database backup controlfile to trace; How can you differentiate the file using the filename itself? When you issue the command alter database backup controlfile to trace ; a trace file will be created in the user_dump destination. The default name of the trace file would look something similar to dbname_ora_5175.trc. The number 5175 is the unix process id of the user session which initiated this trace. As each user has their own unix pid you can identify the file created by that user.

Still want to double confirm open the trace files generated during that time and you will find the client information there. 33. When you execute: alter tablespace begin backup? How can oracle engine can identify that the corresponding data files are in backup mode? SQL>select * from v$backup; in this view you can check for status if it is ACTIVE that file is still in backup mode. 34. If the large table contains thousands of records and the application is accessing 35% of the table which method to use: index searching or full table scan? To improve the performance we have to go for index searching. 35. How to check to memory gap once the SGA is started in restricted mode? V$SGA - Provided that the user is granted DBA access 36. If the SQL * plus hangs for a long time, what is the reason? Use hanganalyze ALTER SESSION SET EVENTS 'immediate trace name hanganalyze level 5'; You are running a cartisian query typically by mistake. Make sure every table has a join criteria specified for it. You are working on a table with 100+million rows. The database server is busy doing a backup. Check the disk IO for the process that appears hung and if the disk IO is increasing every 5-10 seconds then the job is not hung it is just taking a while to complete. When we try access a table which is locked or manipulated by another user 37. What is mutated trigger? In single user mode we got mutated error, as a DBA how you will resolve it? A trigger is said to be mutated when the table on which the trigger is written, is being used inside trigger for DML operation. 38.Schema A has some objects and created one procedure and granted to Schema B. Schema B has the same objects like Schema A. Schema B executed the procedure like inserting some records. In this case where the data will be stored whether in Schema A or Schema B? Procedure will be executed with the authority of A and therfore data will go to the tables owned by A. If one wants the data to go to B use the clause authid current_user while definingthe procedure. 39. If the entire disk is corrupted how will you recover the database and what are the steps to recover the database?

Successful backup is possible if there is "Archive Mode" is on. that is database is in Archive Mode. and if it's off then there are only 99.9 chances through Group1 or Group2 of Online Redo log files. Things Useful For Complete Recovery : 1- Last Valid Backup 2- Dump Files 3- Archive Logs - If You Have a Valid Backup on Another Disk Rather Than The Damaged One You Can Recover The Database till The Time Of This Backup. - If You Have Archive Logs till The Time Of Disaster You Can Recover The Database to The Point Of The Last Commit . - If You Don`t Have Backup Or Archive Logs You Can Use Dump File To Restore Files Back To Their Place . 40. There are about a 10,000 records in a table. A user 1 runs a query which is doing a full table scan. While doing the full table scan, user 2 changes some value x to y using a DML statement in record. What does the 1st user see ( x or y ) ? If x, then where is the value stored? In full table scan if another user updates the value for a given row does not affect the full table scan if the user finishes the update by the time the oracle reads that particular record will get updated value otherwise it has the old value. It will be stored in UNDO tablespace. 41. A user has connect and resource privileges allocated by the DBA. He is been allocated quota on three tablespaces by the DBA - Default Tablespace Quota 500 M - Tablespace 1 Quota 100 M - Tablespace 2 Quota 200 M Now the user tries to make a table which uses 300 M in tablespace 2. Will he be successful? Yes he will be successful, because resource role grant user unlimited tablespace system privilege, quota ignored. 42. There are 100 data files, numbered from 1 to 100. File number 10 is deleted and it has 500 MB of data. The database is working in No-Archive log mode. How can the database be recovered?  

This can be easily done but you will loose the data if you don't restore from backup. If you have a backup of datafiles and controlfile then restore them. If you don't have the backup then you need to use SQL>alter database create datafile 'new_filename.dbf' as 'original_lost_filename.dbf'; 43. How to estimate the size of SGA? SQL> show sga

44. What do you do when tempdb is full? If your tempdb gets full you can do one of following: Restarting the server is not recommended. Increasing the size. Committing the user transactions. 45. How to load data into multiple tables at once? You can use SQL loader to do this. Using the When conditions in SQL Loader control file this is possible. 46.Is it possible to resize tablespaces and data files? If yes, how? We can resize the datafiles which in turn resize the tablespace for which the datafile belongs. The command is SQL>alter database datafile '' resize(size)M; By this command the datafile size will increase and intrun the tablespace size. We can add the datafiles to the tablespace to increase the size of the tablespace. The command is SQL>alter tablespace add datafile ' size(size)M; 47. How to monitor how fast a table is imported? How to modify data as it loads into the database? Use below script to monitor how speed import is happening. SQL>SELECT SUBSTR(sql_text INSTR(sql_text 'INTO ') 30) table_name rows_processed ROUND( (sysdate-TO_DATE(first_load_time 'yyyy-mm-dd hh24:mi:ss'))*24*60 1) minutes TRUNC(rows_processed/((sysdateto_date(first_load_time 'yyyy-mm-dd hh24:mi:ss'))*24*60)) rows_per_minute FROM sys.v_$sqlarea WHERE sql_text like 'INSERT INTO ' AND command_type 2 AND open_versions > 0;

48. How does one use the import/export utilities? Logical Backup using export utility works as an alternative backup method. we can export from one user and import into another within the same database. we can export from one database and import into another database(but both source and destination databases should be are ORACLE databases) when migrating from one platform to another like from windows to sun solaris then export is the only method to transfer the data. selective exports or imports are possible,like 1.from one user to another user 2.from one database to another database

3.from one o/s to another o/s as export files are platform independent 4.from one version to another version. 49. Why and how the deadlock situation arises? Deadlock occurs when two or more users are waiting for data locked by each other. When this happens these users are stuck (deadly embraced) and cannot continue processing. Oracle automatically detects deadlocks and resolves them by rolling back one of the statements involved in the deadlock thus releasing one set of data locked by that statement. The session that is rolled back will observe Oracle error: ORA-00060: deadlock detected while waiting for resource. Oracle will also write out a trace file with detailed information to the database's UDUMP directory. Multi-table deadlocks can be avoided by locking tables in same order (in all applications) thus preventing a deadlock condition. For example session1 lock table: emp then dept; session2: emp then dept. If this is not possible your application should check for ORA-60 errors and restart the rolled back transactions 50. Exp userid=system/manager file=expfile.dmp log=expfile.log full=Y compress=Y buffer=1000000 If i do't mention compress & buffer parameter, then this query will run or not? Yes exactly it will run perfectly because compress and buffer both are optional. 51. What is Ora1555 error? Explain in detail? Oracle Rollback Segments (Undo more recently) hold a copy of data before it was modified and they work in a round-robin fashion. Writing and then eventually overwriting the entries as soon as the changes are committed. They are needed to provide read consistency (a consistent set of data at a point in time) or to allow a process to abandon or rollback the changes or for database recovery. Here’s a typical scenario:User A opens a query to fetch every row from a billion row table. If User B updates and commits the last row of the billion row table a Rollback entry will be created so User A can see the data as it was before the update. Other users are busily updating rows in the database and this in turn generates rollback – which may eventually cause the entry needed for User A to be overwritten (after all User B did commit the change – so it’s OK to overwrite the rollback segment).Maybe 15 minutes later the query is still running and User A finally fetches the last row of the billion row table – but the rollback entry is gone. ORA-01555: Snapshot too old rollback segment too small 52. My database size is 100GB. I am using compress parameter. Will my database size reduce, remain same or increase. What will happen?

When you export will mark the table to be loaded as one extent for the import utility. This option will use only if you want to do import. Export size will not change if we use compress y.

53. How to check whether database whether it is opened by pfile/spfile.?

check this parameter select value from v$parameter where name like 'spfile' if it is empty you are using pfile .

SHOW PARAMETER SPFILE;

54. Explain the differences between 9i OEM & 10G OEM along with new features that changes the way you do your daily job? Here are the major differences between Oracle9i and Oracle10g: 

Major changes to SQL optimizer internals



Oracle Grid computing



AWR and ASH tables incorporated into Oracle Performance Pack and Diagnostic Pack options



Automated Session History (ASH) materializes the Oracle Wait Interface over time



Data Pump replaces imp utility with impdp



Automatic Database Diagnostic Monitor (ADDM)



SQLTuning Advisor



SQLAccess Advisor



Rolling database upgrades (using Oracle10g RAC)



dbms_scheduler package replaces dbms_job for scheduling New Features of Oracle10g release 2:

Web server load balancing - The web cache component includes Apache extension to loadbalance transactions to the least-highly-loaded Oracle HTTP server (OHS). RAC instance load balancing - Staring in Oracle 10g release 2, Oracle JDBC and ODP.NET provide connection pool load balancing facilities through integration with the new “load balancing advisory” tool. This replaces the more-cumbersome listener-based load balancing technique. Automated Storage Load balancing - Oracle’s Automatic Storage Management (SAM) now enables a single storage pool to be shared by multiple databases for optimal load balancing. Shared disk storage resources can alternatively be assigned to individual databases and easily moved from one database to another as processing requirements change. Data Guard Load Balancing – Oracle Dataguard allows for load balancing between standby databases. Listener Load Balancing - If advanced features such as load balancing and automatic failover are desired, there are optional sections of the listener.ora file that must be present. Automatic Storage Management (ASM) includes multiple disk operations and a non-ASM database migration utility Enhancements to data provisioning and Oracle Streams designed to make it easier to archive, move, and copy large data sets New Fast-Start Failover for automatic fail over to standby databases Integrated data encryption and key management in the database Automated statistics collection directly from memory designed to eliminate the need to execute SQL queries New administrative reports include automatic database workload repository comparison Extended use of Standard Chunk sizes - In 10gR2, the server has been enhanced to further leverage standard chunk allocation sizes. This additional improvement reduces the number of problems arising from memory fragmentation. Mutexes - To improve cursor execution and also hard parsing, a new memory serialization mechanism has been created in 10gR2. For certain shared-cursor related operations, mutexes are used as a replacement for library cache latches and librarycache pins. Using mutexes is faster, uses less CPU and also allows significantly improved concurrency over the existing latch mechanism. The use of mutexes for cursor pins can be enabled by setting the init.ora parameter _use_kks_mutex to TRUE. V$SGASTAT - V$SGASTAT has been enhanced to display a finer granularity of memory to component allocation within the shared pool. This allows faster diagnosis of memory usage (in prior releases many smaller allocations were grouped under the ‘miscellaneous’ heading). V$SQLSTAT - A new view, V$SQLSTAT has been introduced which contains SQL related statistics (such as CPU time, elapsed time, sharable memory). This view is very cheap to query even on high-concurrency systems, as it does not require librarycache latch use. It contains the most frequently used SQL statistics in the V$SQL family of views.

V$OPEN_CURSOR - This implementation of this view has also been enhanced to be latchless, making it inexpensive to query. V$SQLAREA - The V$SQLAREA view has been improved in 10gR2; the view optimizes the aggregation of the SQL statements while generating the view data. 55. I have to check used space/unused space in table space. Which view /command will provide me the desired answer?

dba_free_spaces and dba_segments 56. How to create User in Oracle, allocate quota on Oracle table space? SQL> create user test identified by test default tablespace XYZ quota unlimited on XYZ1 quota unlimited on XYZ2 quota unlimited on XYZ3 quota unlimited on XYZ4; User created. 57. Why do you take table spaces in backup mode? In Oracle we can take the backup of our database in two mode cold backup or hot backup. When we want to take the hot backup of database when user is accessing the data we can put the tablespace in backup mode. We need to put the tablespaces in backup mode during hot backup so that writing to datafiles related to this tablespace would stop and be written in the archive logs instead during the period of the backup. If you will not put the tablespaces in backup mode and copy directly while the database is up your backup would be not restorable. 58. Can you take online backup of a Control File If yes, How? Yes you could take a online backup of a control file. SQL> alter database backup controlfile to trace; This will create a text copy of your controlfile. You could use this text file to recreate your controlfile. 59. How do you kill a process in UNIX? Type the following command in the shell prompt to force kill kill -9 for normal kill kill

60. What is stored in Oratab file? This file is used by ORACLE utilities. It is created by root.sh and updated by the Database Configuration Assistant when creating a database. A colon, ':', is used as the field terminator. A new line terminates the entry. Lines beginning with a pound sign, '#', are comments. Entries are of the form: $ORACLE_SID:$ORACLE_HOME:: The first and second fields are the system identifier and home directory of the database respectively. The third filed indicates to the dbstart utility that the database should , "Y", or should not, "N", be brought up at system boot time. Multiple entries with the same $ORACLE_SID are not allowed. 61. How do you remove memory segments? How do you see how many memory segments are acquired by Oracle Instance.? To see the Oracle memory segments from UNIX write ipcs Then look at the status column the one with status is empty and owner is oracle write down the shmid ex: 2 find 2 shmid 123 and 456 in order to startup the database without having to reboot the database server simply remove the newly allocated shared memory. In this case ipcrm shm 123 456 To see the memory segments use $ ipcs -m 62. How many max data files can there be in an Oracle Database? How do you control No. of Data files one can have in an Oracle Database? The maximum number of data files in an Oracle Database is usually 64K files Look A single Oracle database can have max of 1022 of data file in case of small file tablespace and only one data file in case of Bfile tablespace. To restrict the data files At creation time you can set up the maximun numer of datafiles. CREATE DATABASE ..... MAXDATAFILES 500 If you want to check it: SQL>select * from V$CONTROLFILE_RECORD_SECTION where type 'DATAFILE'; If you want to increase it you have to recreate control file. 63. You have a database. You have a data file and some blocks are corrupted in the data file. What statement will you issue to know how many blocks are corrupted?

You can check the "V_$DATABASE_BLOCK_CORRUPTION" view to determine the corrupted blocks. you can use the DBVERIFY utility to check the corruption in datafiles so that you can now number of blocks corrupted.Here is the procedure :On o/s prompt login as oracle user : $ dbv file 'datafile name' now in the output check for the line ' number of pages corrupted' . It tells you about the number of datablocks corrupted in that datafile. 64. What are standby databases? Difference between physical and logical standby databases? A standby database is a transactionally consistent copy of the primary database. Using a backup copy of the primary database, you can create up to nine standby databases. A standby database can be either a physical standby database or a logical standby database. A Physical standby database provides a physically identical copy of the primary database, with on disk database structures that are identical to the primary database. This standby database is kept synchronized with the primary database by recovering/applying the redo data received from the primarydatabase. A Logical standby database has same logical information as the production database, although the physical organization and structure of the data can be different. The logical standby database is keptsynchronized with the primary database by transforming the data in the redo received from the primary database into SQL statements and then executing the SQL statements on the standby database. 65. Show one instance when you encountered an error in alert log and you overcome that error. What actions you took to overcome that error.? Oracle write error in alert log file. Depending upon the error corrective action needs to be taken.1) DeadLock Error : Take the trace file in user dump destination and analysis it for the error.2) ORA01555 Snapshot error. Check the query try to fine tune and check the undo size.3) Unable to extent segment : Check the tablespace size and if require add space in the tablespace by 'alter database datafile .... resize' or alter tablespace add datafile command. 66. What kind of backup you take Physical / Logical? Which one is better and why? Logical backup means backing up the individual database objects such as tables, views , indexes.. using the utility called EXPORT, provided by Oracle. The objects exported in this way can be imported into either samedatabase or into any other database . The backed-up copy of information is stored in a dumpfile, and this file can be read using another utility called IMPORT. There is no other way you can use this file.Physical backups rely on the Operating System to make a copy of the physical files like data files, logfiles,controlfiles that comprise the database. We don't prefered logical backup. it is very slow and recoverys not possible 67. What is your datafile size? How long it can go? What is the max limit to which you can extend? v$datafile data dictionary view will tell us the size of a datafile. to check the number of datafile you can check db_files init parameter. you can also alter this parameter but it will reflect after restart the database. you can also resize the datafile size.

68. Can we create as many tablespace as we require. What is the limit? What is the default size of tablespace? (System and User tablespace). Mention name of some tablespace.? Default size for tablespace: 51276 kb 69. Difference between failover and switch over servers? Failover: Primary fails and standby is made primary. Switchover: Primary and secondary interchanges the role. Effectively in both cases standby becomes primary main difference is when failover happens it means there is something wrong at primary site in some way primary is not accessible either DB has failed or network at primary site. On other hand switchover is part of routine activity to make sure that DR is functional. Many system (where DR is setup) do switchover every 6 months. Failover is never planned it happens when major fault occurs at primary site. 70. While Installing Oracle10g at unix (RedHat) environment , which parameter needs to be set at OS level, to login as a sysdba in Oracle for the first time? .bash_profile has to set at OS level before connecting to oracle database. 71. What is the difference between Cloning and Standby databases? Cloning is nothing but the copy of your database which can be open in read write mode. The standby database is also a copy of your database which is in standby mode and which is made in sink with production database by applying the redo log generated at source database (prodcution database). This database can not be open inread write mode. This standby database can be mode in read write mode by activating the database which reset's it's redo log sequence. 72. What is the most important action a DBA must perform after changing the database from NOARCHIVELOG TO ARCHIVELOG? First of all take a offline backup of whole database(including the (datafile controlfile and redolog files) It is obvious that archive log process should be started by :alter system archive log start otherwise the database halts if unable to rotate redo logs backup the entire database. 73. How to change the database from NOARCHIVELOG TO ARCHIVELOG? Let’s start by checking the current archive mode. SQL> SELECT LOG_MODE FROM SYS.V$DATABASE; LOG_MODE -----------NOARCHIVELOG So we're in NOARCHIVELOG mode and we need to change. We can use a database alter statement, but that won't be perminant, so lets just update the pfile directly.

The pfile should be in $ORACLE_HOME/admin/SID/pfile.

either

$ORACLE_BASE/admin/SID/pfile

or

############################ # Archive Log Destinations ############################ log_archive_dest_1='location=/u02/oradata/cuddle/archive' Note that we're not actually required to specify the location of the log destination, but if you don't it'll end up in strange places (in my test it went to $ORACLE_HOME/dbs making a mess). You can specify as many as 10 diffrent archive log destinations by using the paramters log_archive_dest_1 through log_archive_dest_10. Remember, if you run out of space in your archive log destination the database will shut down! Now we can startup the database in mount mode and put it in archivelog mode. sqlplus sys/passwd as sysdba; Connected to an idle instance. SQL> startup mount ORACLE instance started. Database mounted. SQL> alter database archivelog; Database altered. SQL> alter database open; Database altered. There are several system views that can provide us with information reguarding archives, such as: V$DATABASE Identifies whether the database is in ARCHIVELOG or NOARCHIVELOG mode and whether MANUAL (archiving mode) has been specified. V$ARCHIVED_LOG Displays historical archived log information from the control file. If you use a recovery catalog, the RC_ARCHIVED_LOG view contains similar information. V$ARCHIVE_DEST Describes the current instance, all archive destinations, and the current value, mode, and status of these dstinations. V$ARCHIVE_PROCESSES Displays information about the state of the various archive processes for an instance. V$BACKUP_REDOLOG

Contains information about any backups of archived logs. If you use a recovery catalog, the RC_BACKUP_REDOLOG contains similar information. V$LOG Displays all redo log groups for the database and indicates which need to be archived. V$LOG_HISTORY Contains log history information such as which logs have been archived and the SCN range for each archived log. Using these tables we can verify that we are infact in ARCHIVELOG mode: SQL> select log_mode from v$database; SQL> select DEST_NAME,STATUS,DESTINATION from V$ARCHIVE_DEST; 74. What are the differences between Archive mode and No Archive Mode? No archive log

Archive log

Must backup entire database.

Can backup parts of database (datafiles tablespaces)

DB must be shut down.

hot backups possible

Only entire DB can be restored

Tablespaces can be restored

In case of a failure, all changes sinces the last backup will be lost

All commited transactions will be restorable

75. How do you check whether db is running in archive mode or non archive mode? SQL> archive log list SQL> select log_mode from v$database; 76. How to manager Memory in Oracle Database? How to maximize nos. of user in Oracle Database? It depends on your requirement if you want no of users around 300 then you can still achieve that by keeping PGA parameters low. If you are looking for number of users 1000 or even more you need to go forshared server mode. 77. How to find which tablespace belongs to which datafile ? SQL>select d.name t.name from v$datafile d v$tablespace t where d.ts# t.ts#; run this query in the sql prompt sql> select tablespace_name file_name from dba_data_files;

select file_name tablespace_name from dba_data_files; 78. What is difference between base table and data dictionary views? Base tables are made when the database is created and these tables are stored in data dictionary. These base tables contains the information related to the database. These tables are owned by sys. The information in these tables is encrypted and cannot be modified. So we use the views to access the information in these base tables. These views are called data dictionary views. these views are created when we run the script @ ORACLE_HOME/RDBMS/ADMIN/CATALOG.SQL

79. What are the advantages of the Locally Managed Tablespaces Over Dictionary Managed Tablespaces? 

Because locally managed tablespaces do not record free space in data dictionary, it reduces contention on these tables.



Local management of extents automatically tracks adjacent free space, eliminating the need to coalesce free extents.



Avoids recursive space management operations, which can occur in dictionary-managed tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a rollback segment or data dictionary table.



Sizes of extents that are managed locally can be determined automatically by the system. Alternatively, all extents can have the same size in a locally managed tablespace.



Changes to the extent bitmaps do not generate rollback information because they do not update tables in the data dictionary (except for special cases such as tablespace quota information).



Reduced fragmentation.

80. How can the problem be resolved if a SYSDBA, forgets his password for logging into enterprise manager? Always you should have one more user activated as SYSDBA and this is achieved by using orapw utility If there is just one SYS user then on unix platform login as ORACLE user (DBA group) sqlplus '/ as sysdba' alter user sys identified by 'xyz' ; This would change SYS pwd 81. What is the difference between materialized view and snapshots?

Snapshots can't update. While MV can be updated constantly. 82. How many maximum number of columns can be part of Primary Key in a table in Oracle 9i and 10g? You can set primary key on table up to 16 columns of table in oracle 9i and 10g 83. What is RAC? What is Data Migration? What is Data Pumping? RAC stands for Real Application Cluster. In previous versions, it is known as PARALLEL SERVER. RAC is a mechanism that allows multiple instances (on different hosts/nodes) to access the same database. The benefits: It provides more memory resources, since more hosts are being used; If one host gets down, then second host assumes it's work load. Data Pumping is a data movement utility. This is an replacement to imp/exp utilities. imp/exp utilities are also data movement utilities, but they work within the local servers only. Whereas, impdp/expdp (Data pumping) are very fast and perform data movements from one database to another database. In other words, it provides secure transports. When A large rows gets A updates and A no place in extents found to store, then Oracle server searches for the suitable block/extent, if available, it moves entire row from previous one to new block/extent. The process is called Data migration. If not available, row chained method comes to picture. 84. What is difference between spfile and init.ora? spfile are dynamic file.spfile can be created from pfile.you can open your database without spfile. init.ora is must to open the database.you can edit the init.ora file because it is a text file.whereas spfile cannot it reside on serverside. init.ora spfile both are contains Database parameters info. Both are supported by oracle. Every database instance required either any one. If both are present first choice is given to spfile only. (becareful if both are present any changes made in pfile those are not recongnized in next instance because it always first preference is givent to spfile only). init.ora saved in the format of ASCII SPFILE saved in the format of binary. init.ora info is read by oracle engine at the time of database instance starting time only any modification made in this those are applicatble when in the next startup only. But in spfile modifications (through alter system..... command) can applicable without restarting oracledatabase(restarting instance). spfile we can create with the help of create spfile from pfile. as well as we can create pfile (init.ora) from spfile create pfile from spfile.

in general 24x7 environment spfile is only preferable because parameters can change dynamically. 85. How to Estimate the size of Tablespace? select owner sum(bytes/1024/1024/1024) from dba_segments group by owner 86. Where the SCN does resides (system change number)? SCN - System Change Number - is always getting incremented by Oracle server and will be used to make sure the consistency across the database. SCN number will be updated in almost all places of the database. 1. CONTROLFILE 2. DATAFILE HEADERS 3. REDOLOG FILES (and hence ARCHIVE LOG FILES) 4. DATA BLOCK HEADERS But not in ALERT LOG file as it is not part of database. 87. How do sql statement processing oracle database? Processing Of Sql select statement: When any user executes any sql statement a user process generated and it the request sents to server process. First Server process checks for any privious execution of statement(execution plan) is available inLibrary cache if the execution plan is availble it uses tht path and it fetches the required data from the datafiles and put into database buffer cache and then sends to userprocess. If execution plan is not there in the library cache then the statement enters into parsing state in which validations are performed like object is existing or not. after parsing it goes to datadictionary cache to find the definations of the object and takes the data from the datafiles and fetches the required data from datafiles to database buffer cache and sends to user process. Its a question should hav to explaing with a memory diagram through tht every one can easily understood . 88. What is ORA-1555? This shanshot too old. -> problem occurs generally in 9i only. Whether in 10g at the time of tablespace creation retuntion guarentee is applied it automatically we can supress( by default in oracle 10g retuntion gurantee is flase -- be careful). This problem generally occur in the followin situation. for eg. One user continuously updating on one table where as the another user trying to retrieve conituously on that same table with in the time of retention guarentee period. 89. What is the database holding Capacity of Oracle ?

database holding capacity of oracle 9i is 500 pb(peta bytes) database holding capacity of oracle 10 g is 8 trillion tera bytes. 90. You have taken import of a table in a database. you have got the Integrity constraint violation error. How you are going to resolve it.? if u want to import the table just say constraints=n the movement table got imported then u create constriant on that tables. Find the Master Table(s) of the given table and export / import them all. 91. what are the diffrent file types that are supported by SQL*Loader? 1. .txt 2. .dat 3. .csv 4. .mdb 92. How to find how many database reside in Oracle server in query? select count(*) from v$database; 1. Check the oratab file to get the list of databases on a server. Caveat: If the database is created manually then the oratab won't updated automatically which should be done manually as oratab is updated only when thedatabase is created using DBCA. 2. Check "smon" or "pmon" process at os level using the following command. ps -ef|grep smon|grep -v grep 3. Check the IPCS parameters at OS level which would also provide some information about the existing database instances on that server. 93. Assuming today is Monday, how would you use the DBMS_JOB package to schedule the execution of a given procedure owned by SCOTT to start Wednesday at 9AM and to run subsequently every other day at 2AM? See for this what you have to do is create a view which will result the time to you like create view job_interval as select TRUNC(sysdate+1)+decode(to_char(sysdate+1 'DAY') 'WED' 9/24 2/24) TIME From dual; WHAT THIS VIEW WILL DO IS IT WILL RETURN YOU 2 AM FOR DAYS OTHER THAN WEDNESDAY AND 9 AM FOR WEDNESDAY.

NOW USE THIS VIEW IN DBMS_JOB.SUBMIT AND PASS (SELECT TIME FROM JOB_INTERVAL) IN YOUR INTERVAL ARGUMENT IN DBMS_JOB.SUBMIT AS EXEC DBMS_JOB.SUBMIT(:JOBNO 'YOUR_WORK' 'TRUNC(SYSDATE+2)+9/24' (SELECT TIME FROM JOB_INTERVAL)); 94. HOW 2 ENABLE PARTITIONING FEAUTURE IN ORACLE 10g PARTITION is one of the options which you can enable when you install Oracle Enterprice Edition. You may enable it later if you didn't choose to install at first time. You will have to install again by using OUI and choose the PARTITION option to install it for you. Once it is installed it is enabled for use defaultly. 95. How many memory layers are in the shared pool? shared pool consist of 2 memory layers-library cache and datadictionary cache...library cache -contains parsed sql statements cursor information execution plansdata dictionary cache -user account information priveleges information datafile segment and extent information stored into the data dictionary cache. Sharedpool contains 3 memory layers. 1.Library cache: 2.Data dictionary cache 3.UGA 96. Virtual Indexes in Oracle? Virtual Indexes are another undocumented feature used by Oracle. Virtual indexes, as the name suggests are pseudo-indexes that will not behave the same way that normal indexes behave, and are meant for a very specific purpose.A virtual index is created in a slightly different manner than the normal indexes. A virtual index has no segment pegged to it, i.e., the DBA_SEGMENTS view will not show an entry for this. Oracle handles such indexes internally and few required dictionary tables are updated so that the optimizer can be made aware of its presence and generate an execution plan considering such indexes.As per Oracle, this functionality is not intended for standalone usage. It is part of the Oracle Enterprise Manger Tuning Pack (Virtual Index Wizard). The virtual index wizard functionality allows the user to test a potential new index prior to actually building the new index in the database.It allows the CBO to evaluate the potential new index for a selected SQL statement by building an explain plan that is aware of the potential new index. This allows the user to determine if the optimizer would use the index, once implemented. 97. What are materialized views? when are they used?

Materialized view is like a view but stores both definition of a view plus the rows resulting from execution of the view. It uses a query as the bases and the query is executated at the time the view is created and the results are stored in a table. You can define the Materialized view with the same storage parametes as any other table and place it in any tablespace of your choice. You can also index and partition the Materialized view table like other tables to improve performance of queries executed aginst them. Use of Meterialized view:Expensive operations such as joins and aggregations do not need to be reexecuted. If the query is astisfied with data in a Meterialized view, the server transforms the query to reference the view rather than the base tables. 98. What is an extent? An Extent is a set of contignous data blocks obtain in a single allocation and used to store specific type of information. 99. How to you move from Dedicated server Process to a Shared Server Process? set SHARED_SERVERS (more than 1) in init.ora make changes in tnsnames.ora file to get the connection with DISPATHERS rather than dedicated servers 100. What are the components of physical database structure of Oracle database? totally there are 6 files(components) of physical database structure.3 mandatory & 3 optional.Three mandatory files are :1> datafile : store actual data 2> control file : strores stuctural & status information of database.3> redolog file : stores changed/committed dataThree optional files are :4> parameter file : strores all size related parameters note : this file ismandatory for a1st time u create a database, then it is optional. 5> archivelog file : its offline copy of redolog files6> password file : used to make normal user to behave as a super user. 101. What are the components of logical database structure of Oracle database? Tablespace segments extens data Blocks. A logical unit of storage of databse is called Tablespace. Segments is a space alloocated for a specific logical storage structure within a tablespce. Extents: Space allocated to a segments. Datablocks: Oracle server manage the storage space in the datafiles in units is called data blocks or oracle blocks. 102. What are the different types of segments? data segmentundo segmenttemperory segmentIndex segments table segment index segment IOT cluster etc temp segment data segment

table segment index segment 103. How can be determine the size of the log files.? SQL>select sum(bytes)/1024/1024 size_in_mb from v$log; 104. How can you check which user has which Role.? select * from dba_role_privs order by grantee; SQL>SELECT A.ROLE A.PRIVILEGE FROM ROLE_SYS_PRIVS A DBA_ROLE_PRIVS B WHERE A.ROLE B.GRANTED_ROLE AND B.GRANTEE 'SCOTT' UNION SELECT null role A.PRIVILEGE FROM dba_sys_privs a WHERE a.grantee 'SCOTT' 105. Can you start a database without SPfile in oracle 10g? Yes it is possible to start the database using init.ora file only. The main advantage of using the SPFILE.ora is only to make changes to the dynamic initialization parameters without restarting the database using the SCOPE option. The changes will be stored in the spfile only and if you start the database using pfile option those changes won’t be applicable to the database. 106. Do a view contain data? The answer depends on the type of view. in case of normal view, the ans is NO it only contains query based on a base table but in case of materialized view, YES it does contain data and for the updated data in the base table , it needs to be refreshed. A view does not contain any data of its own but is like a window through which data from other tables can be viewed and changed. 107. Can objects of the same schema reside in different tablespaces? Yes : Schema objects can stored in different tablespace and a tablespace can contained one or more schema objects data. 108. What is an Oracle index? An Index is a tree structure that allows direct access to a row in a table. Indexes can be classified based on their logical design or on their physical implementation. The Logical classification groups indexes from an application perspective while the physical classification is derived from the way the indexes are stored An Index is based on tree structre that allow direct access to a row in a table oracle uses different type of index 1) B-Tree Index 2) Bitmap Index

109. What are the characteristics of data files?

Characterstics of Data File : - A Data file can be associated with only one database. - Once created, a data file cannot change is size. - One or more data files form a logical unit of database storage called a Tablespace. Characteristics of a Data File : - A Data file can be associated with only one tablespace. - Once created a datafile can be increased or decreased in size with RESIZE command. Example: ALTER database datafile '/u03/oradata/dev01/users_02.dbf' RESIZE 150 MB ; - Once created a datafile cannot be dropped. It can only be shrunk to an insignificant size. - One or more data files form a logical unit of database storage called a Tablespace. 110. What is a temporary segment? Temporary Segments are created by ORACLE when a SQL statement needs a temporary work area to complete execution. When the statement finishes execution the temporary segments extents are released to the system for future use. 111. What are the uses of rollback segment? The uses of Roll Back Segment are : 1. Transaction Rollback 2. Transaction Recovery 3. Read Consistency 112. What process writes from data files to buffer cache? It's Server Process 113. Name init.ora parameters which effects system performance? These are the Parameters for init.ora DB_BLOCK_BUFFERS

SHARED_POOL_SIZE SORT_AREA_SIZE DBWR_IO_SLAVES ROLLBACK_SEGMENTS SORT_AREA_RETAINED_SIZE DB_BLOCK_LRU_EXTENDED_STATISTICS SHARED_POOL_RESERVE_SIZE Additionally PGA_Aggregate_target set when Work_area_policy is set to auto and FAST_START_MTTR_Target set may also affect d/b performance 114. What will you find the rollback segment? ROLLBACK INFORMATION NOTES: Segment Name - Name of the rollback segment. Owner - Owner of the rollback segment. Tablespace - Name of the tablespace containing the rollback segment. Segment ID - ID number of the rollback segment. File ID - ID number of the block containing the segment header. Block ID - Starting block number of the extent. Initial Extent - Initial extent size in bytes. Next Extent - Secondary extent size in bytes. Min Extents - Minimum number of extents. Max Extents - Maximum number of extents. PCT Increase - Percent increase for extent size. Status - ONLINE if the segment is online or PENDING OFFLINE if the segment is going offline but some active (distributed) transactions are using the rollback segment. When the transaction(s) complete the segment goes OFFLINE. Instance - Instance this rollback segment belongs to (Parallel Server) or NULL for a singleinstance system . SQL>select SEGMENT_NAME OWNER, TABLESPACE_NAME, SEGMENT_ID, FILE_ID, BLOCK_ID , INITIAL_EXTENT, NEXT_EXTENT , MIN_EXTENTS ,MAX_EXTENTS , PCT_INCREASE , STATUS , INSTANCE_NUM from dba_rollback_segs order by SEGMENT_NAME 115. What is a data segment? A segment is a set of extents that contains all the data for a specific logical storage structure within a tablespace. For example for each table Oracle allocates one or more extents to form that table's data segment and for each index Oracle allocates one or more extents to form its index segment. Oracle databases use four types of segments which are described in the following sections: A single data segment in an Oracle database holds all of the data for one of the following:

A table that is not partitioned or clustered A partition of a partitioned table A cluster of tables

116. What is SYSTEM tablespace and when is it created? A system tablespace is a memory allocated by oracle to creation of objects and is automatically created at the time of database creation 117. What is a tablespace? What are their types? An Oracle database consists of one or more logical storage units called tablespaces which collectivley store all of the database's data. Oracle Stores logically data in tablespaces every database atleast one tablespace accumulated with it tablespace is two types System Tablespaces:- created automatically when database is created by oracle server to hold system objects data dictionary and not user data. Non-System Tablespace:- created by DBA to store UNDO TEMP and APPLICATION objects. 118. Can a table space hold objects from different schemes? It can be, the only required option is that your tablespace have quota assigned to any user that want to store objects in it. 119. What is the use of control file? Control file is binary file which is having all the information realted to database. db_name maxlogfiles maxdatafiles tablespaces information. Without this u cannot open your database. Init.ora parameter file showing the location of the controlfile. 120. What is a segment? segment is the collection of extents allocated to paricular object like table and index. Table segment and index segment 121. What is row chaining? If any of he empty row is not sufficient to hold the row. then row is placed in multiple blocks. it happenes when the block size is small and rows are of large size. then it cause chaining. Due to chaining performance degrades and will cause more IOs 122. What does a control file contains? information about the database redologfile and datafile archivelog file location and current scn no and redo log file 123. How to define data block size? The primary block size is defined by the Initiaization parameter DB_BLOCK_SIZE. 124. Explain the relationship among database, tablespace and data file. What is schema? Database : Collection of data is called database.

Tablespace : An Oracle Database consists of one or more logical storage units called tablespace which collectively use to store all the database's data. DataFile : Each tablespace in an Oracle Database consists of one or more datafiles which are used to store data physically. Schema : A schema is a named collection of objects that include Tables Triggers constraints Indexes Views etc. A user can only be associated with one schema and that is the same name as the user's. Username and schema are often used interchangeably. 125. What are memory structures in Oracle? The basic memory structures associated with Oracle include: System Global Area (SGA) which is shared by all server and background processes and holds the following: o Database buffer cache o Redo log buffer o Shared pool o Large pool (if configured) Program Global Areas (PGA) which is private to each server and background process; there is one PGA for each process. The PGA holds the following: o Stack areas o Data areas 126. What does database do during mounting process? while mounting the database oracle reads the data from controlfile which is used for varifying physical database files during sanity check.backgroung processes are started before mounting the database only. 127. What is the view name where i can get the space in MB for tables or views? SQL>select segment_name,sum(bytes) from dba_segments where segment_name='TABLE_NAME' AND OWNER='OWNER of the table'group by segment_name 128. How to DROP an Oracle Database? You can do it at the OS level by deleting all the files of the database. The files to be deleted can be found using: 1) select * from dba_data_files; 2) select * from v$logfile; 3) select * from v$controlfile; 4) archive log list 5) initSID.ora 6) In addition you can clean the UDUMP, BDUMP, scripts etc Clean up the listener.ora and the tnsnames.ora. make sure that the oratab entry is also removed. Real time Oracle Interview Questions

129. Create temporary table space with 100 MB tempfile size and test whether we can create any objects under temp table space.? Syntax to create a temp tablespace SQL> CREATE TEMPORARY TABLESPACE GTEMP01 TEMPFILE 'Path of the Temp file\TEMP01.DBF' SIZE 100M Note: The Default Temporary Tablespace size is the size given at the time of creation of the DB through script. If the size is not given then it will throw the error. Adding a object into a temporary Tablespace: SQL> create table emp(emp_id number) tablespace GTEMP01; ERROR at line 1: ORA-02195: Attempt to create PERMANENT object in a TEMPORARY tablespace. Note: it's because the tablespace in which you try to create a table is in TEMPORARY mode (contents column in dba_tablespaces), which means that you cannot create an object in that tablespace. Tables used to Find the Temporary Tablespace name, Path of the tempfile and size of the tempfile is “DBA_TEMP_FILES”. Query to find the name of temporary tablespace, path and size of the file: SQL> SELECT tablespace_name, file_name, bytes FROM dba_temp_files WHERE tablespace_name = 'TEMP01';

Tables used to Find the other Tablespace name, Path of the tempfile and size of the tempfile is “DBA_DATA_FILES” Query to find the name of tablespace, path and size of the file: SQL> SELECT tablespace_name, file_name, bytes FROM dba_data_files; To determine the current default temporary tablespace for the database, run the following query: SQL> SELECT PROPERTY_NAME, PROPERTY_VALUE FROM DATABASE_PROPERTIES;

130. Clear the transactions in temp table space and reduce the size of temp file to 50M? Resize a Temporary Table Space: SQL> alter database tempfile 'Path of the Temp File.dbf' resize 50M; Database altered. To Clear the Transactions in temp file : Commit the transactions in the temporary tablespace. 131. Create / alter temporary table space with dictionary managed and auto segment management. ? Advantages in using Locally Managed Tablespaces Over Dictionary Managed Tablespaces 

Because locally managed tablespaces do not record free space in data dictionary, it reduces contention on these tables.



Local management of extents automatically tracks adjacent free space, eliminating the need to coalesce free extents.



Avoids recursive space management operations, which can occur in dictionary-managed tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a rollback segment or data dictionary table.



Sizes of extents that are managed locally can be determined automatically by the system. Alternatively, all extents can have the same size in a locally managed tablespace.



Changes to the extent bitmaps do not generate rollback information because they do not update tables in the data dictionary (except for special cases such as tablespace quota information).



Reduced fragmentation.

SQL > CREATE TEMPORARY TABLESPACE GTEMP01 tempfile 'D:\oradata\orcl\GTEMP01.dbf'SIZE 100M REUSE EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M; The extent management clause is optional for temporary tablespaces because all temporary tablespaces are created with locally managed extents of a uniform size. The default for SIZE is 1M. But if you want to specify another value for SIZE, you can do so as shown in the preceding statement. Note: 

On some operating systems, the database does not allocate space for the tempfile until the tempfile blocks are actually accessed. This delay in space allocation results in faster creation and resizing of tempfiles, but it requires that sufficient disk space is available when the tempfiles are later used. Please refer to your operating system documentation to determine whether the database allocates tempfile space in this way on your system.

Note: 

The Dictionary managed extent management is not possible on temporary tablespace because it is well known behaviour that in a Temp Tablespace (the behaviour is to do with the fact that it is a Tablespace with contents='TEMPORARY' and doesn't really related to LMT, whereas a TEMPORARY Tablespace can only be LMT -- which is a different issue), all sessions share a single Temp Segment and the segment is NOT released or dropped or resized when sessions log out or when they persist. However, extents within the segment are reused for other queries (even of other sessions) when the query using those extents for temp space has completed.

You can verify that by monitoring V$TEMPSEG_USAGE while and after a large query is running. Auto segment management: It is not possible for a temporary tablespace because these type of tablespaces won’t extend. 132. Create 2 undo tablespace with 500m size and tablespace must be locally managed and auto extent. Creating an Undo Tablespace There are two methods of creating an undo tablespace. The first method creates the undo tablespace when the CREATE DATABASE statement is issued. This occurs when you are creating a new database, and the instance is started in automatic undo management mode (UNDO_MANAGEMENT = AUTO). The second method is used with an existing database. It uses the CREATE UNDO TABLESPACE statement. You cannot create database objects in an undo tablespace. It is reserved for system-managed undo data. Using CREATE DATABASE to Create an Undo Tablespace You can create a specific undo tablespace using the UNDO TABLESPACE clause of the CREATE DATABASE statement. The following statement illustrates using the UNDO TABLESPACE clause in a CREATE DATABASE statement. The undo tablespace is named undotbs_01 and one datafile, /u01/oracle/rbdb1/undo0101.dbf, is allocated for it. CREATE DATABASE rbdb1 CONTROLFILE REUSE . . . UNDO TABLESPACE undotbs_01 DATAFILE '/u01/oracle/rbdb1/undo0101.dbf';

If the undo tablespace cannot be created successfully during CREATE DATABASE, the entire CREATE DATABASE operation fails. You must clean up the database files, correct the error and retry the CREATE DATABASE operation. Using the CREATE UNDO TABLESPACE Statement The CREATE UNDO TABLESPACE statement is the same as the CREATE TABLESPACE statement, but the UNDO keyword is specified. The database determines most of the attributes of the undo tablespace, but you can specify the DATAFILE clause. This example creates the UNDOTBS2 undo tablespace: SQL> create undo tablespace UNDOTBS2 datafile 'D:\ORADATA\ORCL\UNDOTBS02.DBF' size 500M reuse autoextend on; Tablespace created. You can create more than one undo tablespace, but only one of them can be active at any one time. The CREATE DATABASE statement also lets you create a single-file undo tablespace at database creation. 133. How to Change the location of undo data files? The following are the steps to change the locations of the datafiles  Make the tablespace status to offline SQL> Alter tablespace OFFLINE;  Copy the data files for the corresponding tablespace to your needed locations. In Linux using CP command

SYNTAX in LINUX: CP old path new path In MS ctrl+c and ctrl+v 

Alter the path

SQL> Alter tablespace rename datafile ‘’ to ‘’;  Make the tablespace status to online SQL> Alter tablespace ONLINE; 134. How do you find objects default table space? SQL> select username,default_tablespace from dba_users;

SQL> select owner,tablespace_name from dba_tables; 135. How to change the temporary table space into permanent table space? This type of conversion is not possible in 10g Version .But it is possible in lower version like 9g .This is because the extent management is local in oracle 10g but in 9i it is dictionary managed. SYNTAX for creating in 9i SQL> create tablespace testDic 2 datafile 'C:\oracle\oradata\Venkat\t1.dbf' size 2m 3 default storage 4 ( 5 initial 200k 6 next 200k 7 pctincrease 0 8 ) 9 temporary; Tablespace created. SQL> alter tablespace testDic permanent; Tablespace altered.

136.What are all the parameters can set in init.ora for undo management?

For UNDO we have The following is a summary of the initialization parameters for automatic undo management mode: Initialization Parameter

Description

UNDO_MANAGEMENT

If AUTO, use automatic undo management mode. If MANUAL, use manual undo management mode. The default is MANUAL.

UNDO_TABLESPACE

An optional dynamic parameter specifying the name of an undo tablespace to use. This parameter should be used only when the

database has multiple undo tablespaces and you want to direct the database instance to use a particular undo tablespace. UNDO_RETENTION

A dynamic parameter specifying the minimum length of time to retain undo. The default is 900 seconds. The setting of this parameter should take into account any flashback requirements of the system.

137. Can you explain how undo management works?

Working of an UNDO Management: Now if a new transaction comes, oracle will check if any of the extent is free (In-active). Even a single extent can hold more then one transaction. Extents are made of oracle block. But a single oracle block can hold data from only one transaction. Now imaging that Extent 5 is having some space and all other extents are full. In this case new transaction will be allocated to extent 5. As transaction proceeds, the space in the extent will start getting occupied. A stage will come when extent 5 will get full. Not ideally one of the other extent should get freed (In-active) because of completion of some other transaction. But if all the transactions are long running then none of the extent will be freed. In this case oracle will pull a new extent into this “cycle” After some time some of the transactions commits and there extents gets freed and can be allocated to other active transactions if required. Again if extents are insufficient a new extent will be pulled. This continuous until the tablespace is full. 138.Create table space with data file size 1G extend to 2G with locally managed and auto segment management.? Syntax for creating the tablespace: SQL> create tablespace ‘’ datafile ‘’ size 1G auto extend on next 1M maxsize 2G extent management local segment space management auto;

Syntax for altering the tablespace: SQL> Alter database datafile ‘’ resize autoextend on next maxsize Syntax for adding a data file into the tablespace: SQL>Alter tablespace’’ add datafile’’ size 139. Create objects in a different table space?

The System and the User tablespaces are the two permanent tablespace available in oracle. The rest of the tablespaces are temporary. Syntax for creating the table in system tablespace: SQL> CREATE TABLE "table_name"("column 1" "data_type_for_column_1", "column 2" "data_type_for_column_2",... ); This will be allocated to the system tablespace because the default tablespace is SYSTEM. Syntax for creating the table in USER tablespace: SQL> CREATE TABLE "table_name"("column 1" "data_type_for_column_1", "column 2" "data_type_for_column_2",... ) tablespace ‘’; 140. Can we create multiple system undo, temp table space? If so, how? System Tablespace: Every Oracle database contains a tablespace named SYSTEM, which Oracle creates automatically when the database is created. The SYSTEM tablespace always contains the data dictionary tables for the entire database. All data stored on behalf of stored PL/SQL program units (procedures, functions, packages, and triggers) resides in the SYSTEM tablespace. The SYSTEM tablespace is always online when the database is open. Creation of Undo Tablespaces A database administrator creates undo tablespaces individually, using the CREATE UNDO TABLESPACE statement. It can also be created when the database is created, using the CREATE DATABASE statement. A set of files is assigned to each newly created undo tablespace. Like regular tablespaces, attributes of undo tablespaces can be modified with the ALTER TABLESPACE statement and dropped with the DROP TABLESPACE statement. Note:You can create more than one undo any one time.

tablespace, but only one of them can be active at

Creation of Temporary Tablespaces Create temporary tablespaces by using the CREATE TEMPORARY TABLESPACE statement. Note: An undo tablespace cannot be dropped if it is being used by any instance or contains any undo information needed to recover transactions You may have multiple temporary tablespaces in an Oracle Database 1Og database, in order to support heavy database sorting operations 141. How do you increase/ decrease tablespace data file size? By Using the alter Command

SQL>Alter Tablespace ‘’ datafile ‘’ resize 142.How do you change the name of undo, temporary table space? Renaming Tablespaces Using the RENAME TO clause of the ALTER TABLESPACE, you can rename a permanent or temporary tablespace. SQL> alter tablespace ‘’ RENAME TO ‘’; Tablespace altered. When you rename a tablespace the database updates all references to the tablespace name in the data dictionary, control file, and (online) datafile headers. The database does not change the tablespace ID so if this tablespace were, for example, the default tablespace for a user, then the renamed tablespace would show as the default tablespace for the user in the DBA_USERS view. The following affect the operation of this statement: The COMPATIBLE parameter must be set to 10.0 or higher.

Note:  If the tablespace being renamed is the SYSTEM tablespace or the SYSAUX tablespace, then it will not be renamed and an error is raised. SQL> alter tablespace system RENAME TO system1; alter tablespace system RENAME TO system1 * ERROR at line 1: ORA-00712: cannot rename system tablespace

SQL> alter tablespace sysaux RENAME TO system1; alter tablespace sysaux RENAME TO system1 * ERROR at line 1: ORA-13502: Cannot rename SYSAUX tablespace 

If any datafile in the tablespace is offline, or if the tablespace is offline, then the tablespace is not renamed and an error is raised. SQL> alter tablespace userts RENAME TO users; alter tablespace userts RENAME TO users *

ERROR at line 1: ORA-01135: file 4 accessed for DML/query is offline ORA-01110: data file 4: 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\USERS01.DBF' 

If the tablespace is read only, then datafile headers are not updated. This should not be regarded as corruption; instead, it causes a message to be written to the alert log indicating that datafile headers have not been renamed. The data dictionary and control file are updated. SQL> alter tablespace userts read only; Tablespace altered. SQL> alter tablespace userts RENAME TO users; Tablespace altered.

alter tablespace userts RENAME TO users Tablespace 'USERTS' is renamed to 'USERS'.

Tablespace name change is not propagated to file headers because the tablespace is read only. 

If the tablespace is the default temporary tablespace, then the corresponding entry in the database properties table is updated and the DATABASE_PROPERTIES view shows the new name. SQL> select property_value 2 from database_properties 3 where property_name like '%TEMP%';

SQL> alter tablespace temp2 rename to temp; Tablespace altered. SQL> select property_value 2 from database_properties 3 where property_name like '%TEMP%'; 143. How do you check whether db is running in archive mode or non archive mode? SQL> archive log list SQL> select log_mode from v$database; 144. How do you drop original temp and undo table space?

We can’t drop the original tablespace because the tablespace will be in use. So we want to recreate another tablespace and drop the original. DROP AND RECREATE UNDO AND TEMP TABLESPACE create a new temporary undo tablespace SQL>CREATE UNDO TABLESPACE UNDOXX DATAFILE '/u01/oradata/xxxx/undoXX.dbf' SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE 32767M; alter system command to point to the temporary tablespace SQL>ALTER SYSTEM SET UNDO_TABLESPACE=UNDOXX; drop the original undo tablespace including datafile; SQL>DROP TABLESPACE "UNDOTBS" INCLUDING CONTENTS AND DATAFILES ; recreate the UNDO tablespace using the original name. SQL>CREATE UNDO TABLESPACE "UNDOTBS" DATAFILE '/u01/oradata/xxxx/undotbs01.dbf' SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE 32767M; Repeat step 2 to switch back to the original named tablespace. drop the UNDOTBS2 tablespace.

to query what transaction is actively using the UNDO tablespace, run this query; SQL>SELECT TO_CHAR (s.SID) || ',' || TO_CHAR (s.serial#) sid_serial, NVL (s.username, 'None') orauser, s.program, r.NAME undoseg, t.used_ublk * TO_NUMBER (x.VALUE) / 1024 || 'K' "Undo", t1.tablespace_name FROM SYS.v_$rollname r,SYS.v_$session s,SYS.v_$transaction t,SYS.v_$parameter x,dba_rollback_segs t1 WHERE s.taddr = t.addr AND r.usn = t.xidusn(+)AND x.NAME = 'db_block_size'AND t1.segment_id = r.usn AND t1.tablespace_name = 'UNDO'; TEMP tablespace create a new temporary temp tablespace. SQL>CREATET TEMPORARY TABLESPACE TEMPXX TEMPFILE '/ora2/oradata/ENROLPDB/tempxx.dbf' AUTOEXTEND ON NEXT 10M MAXSIZE 5000M; alter database to point it to the new tempxx tablespace.

SQL>ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPXX; drop the original temporary tablespace. SQL>DROP TABLESPACE TEMP INCLUDING CONTENTS AND DATAFILES; recreate the new temp tablespace with the original name using step 1. repeat the step to switch backup the temporary tablespace back using step 2. drop the tempxx tablespace. 145. Can we offline temporary and undo table space? If so, how? We can’t make the current tablespcae to offline . But we can make the tablespace to offline which is not currently used. For other tablespaces SQL> alter tablespace ‘’ offline; Tablespace altered. 146. How do you check the table space status? Tablespace Information SQL>select TABLESPACE_NAME,INITIAL_EXTENT,NEXT_EXTENT,MIN_EXTENTS, MAX_EXTENTS,PCT_INCREASE,STATUS,CONTENTS from dba_tablespaces Order by TABLESPACE_NAME ; Coalesced Exts SQL>select TABLESPACE_NAME,TOTAL_EXTENTS,EXTENTS_COALESCED,PERCENT_EXTENTS_COALESCE D,TOTAL_BYTES, BYTES_COALESCED, TOTAL_BLOCKS,BLOCKS_COALESCED, PERCENT_BLOCKS_COALESCED from dba_free_space_coalesced order by TABLESPACE_NAME; Usage select a.TABLESPACE_NAME, a.BYTES bytes_used, b.BYTES bytes_free, b.largest, round(((a.BYTES-b.BYTES)/a.BYTES)*100,2) percent_used from ( select TABLESPACE_NAME, sum(BYTES) BYTES from dba_data_files group by TABLESPACE_NAME

) a, (

) b where order

select TABLESPACE_NAME, sum(BYTES) BYTES , max(BYTES) largest from dba_free_space group by TABLESPACE_NAME a.TABLESPACE_NAME=b.TABLESPACE_NAME by ((a.BYTES-b.BYTES)/a.BYTES) desc

147. How do you resize the SGA size? Set the SGA_TARGET in the pfile 148. How do you change the db block size? The Default size will be multiple of the OS blocks.it is impossible to alter the DB_BLOCK_SIZE once a database is created. You must decide the DB_BLOCK_SIZE when you first create the Database. Best way to get it changed on your system would be create a new database with the blocksize you require (alongside the existing DB), full export from old db - import into new database. 149. Which background process can create in multiple? If so, what and in which situation? Although there is only one SMON and one PMON process running per database instance, one can have multiple DBWR processes running at the same time. Note the number of DBWR processes running is set via the DB_WRITER_PROCESSES. The DBWR (Database Writer) background process is responsible for managing the contents of the data block buffer cache and dictionary cache. DBWR performs batch writes of changed block. SinceOracle uses write-ahead logging, DBWR does not need to write blocks when a transaction commits. In the most common case, DBWR writes only when more data needs to be read into the system global area and too fewdatabase buffers are free. The least recently used data is written to the datafiles first.

150. Can we create multiple ARCH processes? Archive process writes filled redo logs to the archive log location(s). In RAC, the various ARCH processes can be utilized to ensure that copies of the archived redo logs for each instance are available to the other instances in the RAC setup should they be needed for recovery. 151. How do you check data file locations and attached to which table space? SQL>SELECT file_name, tablespace_name,bytes/1024/1024 MB, blocks FROM dba_data_files

UNION ALL SELECT file_name, tablespace_name,bytes/1024/1024 MB, blocks FROM dba_temp_files ORDER BY tablespace_name, file_name; 152. How do you move the objects from once table space to another table space without exp/imp ? SQL>SELECT 'ALTER TABLE '|| table_name ||' MOVE TABLESPACE USERS;' FROM user_tables WHERE tablespace_name='MY_TableSpace'; SQL>SELECT 'ALTER INDEX '|| index_name ||' REBUILD TABLESPACE USERS;' FROM user_indexes WHERE tablespace_name='MY_TableSpace';

SQL>SELECT 'ALTER TABLE '|| table_name ||' MOVE LOB (' || column_name ||') STORE AS (TABLESPACE USERS);' FROM user_lobs WHERE tablespace_name='MY_TableSpace'; 153. Can we define the max data files in a database? If so how? Where to find the max data files? Max Data File in a database: That can be defined in the control file at the time of database creation. Default is 255 . The number of data files in oracle database is controlled by the initialization parameter DB_FILES setting this value too high can cause DBWR issues. before 9i maximum no of datafiles in a oracle database is 1022 after 9i and this limit is applicable to the no of data files in a tablespace. The maximum data file size is calculated by: Maximum datafile size = db_block_size * maximum number of blocks The maximum amount of data in an Oracle database is calculated by: Maximum database size = maximum datafile size * maximum number of datafile The maximum number of datafiles in Oracle9i and Oracle 10g Database is 65,536. However, the maximum number of blocks in a data file increase from 4,194,304 (4 million) blocks to 4,294,967,296 (4 billion) blocks. The maximum amount of data for a 32K block size database is eight exabytes (8,388,608 Terabytes) in Oracle 10g. BLOCK SIZE

MAXIMUM DATA FILE SIZE

MAXIMUM DATABASE SIZE

32 K

131,072 GB

8,589,934,592 GB

16 K

65,536 GB

4,294,967,296 GB

8K

32,768 GB

2,147,483,648 GB

4K

16,384 GB

1,073,741,824 GB

2K

8,192 GB

536,870,912 GB

To add the datafile SQL> alter tablespace ‘’ add datafile ‘' size 4M autoextend on; 154. How do you find redo log sequence no? SQL> SELECT SEQUENCE# FROM V$LOG; 155. List out the redo log data dictionary table / view? V$LOG, V$LOGFILE, V$LOG_HISTORY 156. How do you mirror the control file / redo log files.? Instructions: 1. Ensure that your database is recoverable back to original location and state by backing it up before executing this procedure: Database in NON-ARCHIVE LOG MODE - take an off-line database backup. Database in ARCHIVELOG MODE - take an on-line or off-line database backup. 2. Connect to sql*plus as the user ‘SYS AS SYSDBA’ and ensure that all users have logged off the system by executing the following command. SQL> connect / as sysdba Connected. SQL> select username from v$session; SQL> select username from v$session;

3. Place the system in restricted mode: SQL> alter system enable restricted session; System altered. 4. Connect as SYS with SYSDBA privileges and execute the following SQL command: The [alter database backup controlfile to trace;] command will generate a SQL script that can be used to regenerate the database. 5. Execute the sql*plus command show parameter to find your user dump directory. SQL> show parameter user_dump_dest 6. Exit to the OS layer and move to the user_dump_dest directory. Trace file names are generated by oracle in the following format [instance_name]+[oracle generated number].trc, so use the timestamp to locate the last trace file generated. Open the file in a text editor and remove everything above the ‘STARTUP NOMOUNT ..' statement. Alter the ‘CREATE CONTROLFILE’ statement for the following uses: Rename DB in Archivelog mode: CREATE CONTROLFILE SET DATABASE "new_db_name" RESETLOGS ARCHIVELOG Rename DB in Non-Archivelog mode: CREATE CONTROLFILE SET DATABASE "new_db_name" NORESETLOGS NOARCHIVELOG Reuse DB name in Archivelog mode: CREATE CONTROLFILE REUSE DATABASE "db_name"

RESETLOGS

ARCHIVELOG

Reuse DB name in Non-Archivelog mode: CREATE CONTROLFILE REUSE DATABASE "db_name"

NORESETLOGS NOARCHIVELOG

7. Edit the rest of this file to reference the correct locations of you log files, datafiles and temp files. 8. Move the trace file to an appropriate location and name to recreate_db.sql. 9. Connect as SYS with SYSDBA privileges and shutdown the database in immediate mode: SQL> shutdown immediate. 10. Move the following files to their corresponding locations in updated recreate_db.sql file. DATAFILES,Log files NOTE: Do not move your old control files or temp files to the new location. 11. Restore or copy the backup and the archived logs (if any) to the new machine.

12. Move your INIT$ORACLE_SID.ORA file to its new location. Ensure your controlfile and archive destinations in INIT are set properly to the new locations. 13. Connect to SQLPLUS on your new machine as SYS AS SYSDBA and run create_db.sql script as follows: SQL> @[directory_location]/create_db.sql 14. Change the global database name if you renamed your database as follows: SQL> ALTER DATABASE RENAME GLOBAL_NAME = new_db_name; 15. Perform full system backup and store in a safe location.

NOTE: This new backup will be you starting point for recovery in the new database location. You have completed database cloning procedure. Renaming and Relocating Datafiles You can rename datafiles to either change their names or relocate them. Some possible procedures for doing this are described in the following sections: •

Procedures for Renaming and Relocating Datafiles in a Single Tablespace



Procedure for Renaming and Relocating Datafiles in Multiple Tablespaces

When you rename and relocate datafiles with these procedures, only the pointers to the datafiles, as recorded in the database control file, are changed. The procedures do not physically rename any operating system files, nor do they copy files at the operating system level. Renaming and relocating datafiles involves several steps. Read the steps and examples carefully before performing these procedures. Procedures for Renaming and Relocating Datafiles in a Single Tablespace The section suggests some procedures for renaming and relocating datafiles that can be used for a single tablespace. You must have ALTER TABLESPACE system privileges. Procedure for Renaming Datafiles in a Single Tablespace To rename datafiles in a single tablespace, complete the following steps: 1.

Take the tablespace that contains the datafiles offline. The database must be open.

For example: ALTER TABLESPACE users OFFLINE NORMAL; 2.

Rename the datafiles using the operating system.

3. Use the ALTER TABLESPACE statement with the RENAME DATAFILE clause to change the filenames within the database.

For example, the following statement renames the datafiles /u02/oracle/rbdb1/user1.dbf and /u02/oracle/rbdb1/user2.dbf to/u02/oracle/rbdb1/users01.dbf and /u02/oracle/rbdb1/users02.dbf, respectively: ALTER TABLESPACE users RENAME DATAFILE '/u02/oracle/rbdb1/user1.dbf', '/u02/oracle/rbdb1/user2.dbf' TO '/u02/oracle/rbdb1/users01.dbf', '/u02/oracle/rbdb1/users02.dbf'; Always provide complete filenames (including their paths) to properly identify the old and new datafiles. In particular, specify the old datafile name exactly as it appears in the DBA_DATA_FILES view of the data dictionary. 4. Back up the database. After making any structural changes to a database, always perform an immediate and complete backup. Procedure for Relocating Datafiles in a Single Tablespace Here is a sample procedure for relocating a datafile. Assume the following conditions: • An open database has a tablespace named users that is made up of datafiles all located on the same disk. • The datafiles of the users tablespace are to be relocated to different and separate disk drives. •

You are currently connected with administrator privileges to the open database.



You have a current backup of the database.

Complete the following steps: If you do not know the specific file names or sizes, you can obtain this information by issuing the following query of the data dictionary view DBA_DATA_FILES: SQL> SELECT FILE_NAME, BYTES FROM DBA_DATA_FILES WHERE TABLESPACE_NAME = 'USERS'; Note: You can temporarily exit SQL*Plus to execute an operating system command to copy a file by using the SQL*Plus HOST command.

1.

Rename the datafiles within the database.

The datafile pointers for the files that make up the users tablespace, recorded in the control file of the associated database, must now be changed from the old names to the new names. Use the ALTER TABLESPACE...RENAME DATAFILE statement. ALTER TABLESPACE users RENAME DATAFILE '/u02/oracle/rbdb1/users01.dbf', '/u02/oracle/rbdb1/users02.dbf' TO '/u03/oracle/rbdb1/users01.dbf', '/u04/oracle/rbdb1/users02.dbf'; 2. Back up the database. After making any structural changes to a database, always perform an immediate and complete backup. Procedure for Renaming and Relocating Datafiles in Multiple Tablespaces You can rename and relocate datafiles in one or more tablespaces using the ALTER DATABASE RENAME FILE statement. This method is the only choice if you want to rename or relocate datafiles of several tablespaces in one operation. You must have the ALTER DATABASE system privilege. Note: To rename or relocate datafiles of the SYSTEM tablespace, the default temporary tablespace, or the active undo tablespace you must use this ALTER DATABASE method because you cannot take these tablespaces offline. To rename datafiles in multiple tablespaces, follow these steps. 1.

Ensure that the database is mounted but closed.

Note: Optionally, the database does not have to be closed, but the datafiles (or tempfiles) must be offline. 2. Copy the datafiles to be renamed to their new locations and new names, using the operating system. You can copy the files using the DBMS_FILE_TRANSFER package discussed in "Copying Files Using the Database Server". 3.

Use ALTER DATABASE to rename the file pointers in the database control file.

For example, the following statement renames the datafiles/u02/oracle/rbdb1/sort01.dbf and /u02/oracle/rbdb1/user3.dbf to /u02/oracle/rbdb1/temp01.dbf and /u02/oracle/rbdb1/users03.dbf, respectively: ALTER DATABASE

RENAME FILE '/u02/oracle/rbdb1/sort01.dbf', '/u02/oracle/rbdb1/user3.dbf' TO '/u02/oracle/rbdb1/temp01.dbf', '/u02/oracle/rbdb1/users03.dbf; Always provide complete filenames (including their paths) to properly identify the old and new datafiles. In particular, specify the old datafile names exactly as they appear in the DBA_DATA_FILES view. 4. Back up the database. After making any structural changes to a database, always perform an immediate and complete backup. Control Files: Every Oracle Database has a control file, which is a small binary file that records the physical structure of the database. The control file includes: •

The database name



Names and locations of associated datafiles and redo log files



The timestamp of the database creation



The current log sequence number



Checkpoint information

It is strongly recommended that you multiplex control files i.e. Have at least two control files one in one hard disk and another one located in another disk, in a database. In this way if control file becomes corrupt in one disk the another copy will be available and you don’t have to do recovery of control file. You can multiplex control file at the time of creating a database and later on also. If you have not multiplexed control file at the time of creating a database you can do it now by following given procedure. Multiplexing Control File Steps: 1.

Shutdown the Database.

SQL>SHUTDOWN IMMEDIATE;

2. Copy the control file from old location to new location using operating system command. For example. $cp /u01/oracle/ica/control.ora

/u02/oracle/ica/control.ora

3.

Now open the parameter file and specify the new location like this

CONTROL_FILES=/u01/oracle/ica/control.ora Change it to CONTROL_FILES=/u01/oracle/ica/control.ora,/u02/oracle/ica/control.ora 4.

Start the Database

Now Oracle will start updating both the control files and, if one control file is lost you can copy it from another location. Changing the Name of a Database If you ever want to change the name of database or want to change the setting of MAXDATAFILES, MAXLOGFILES, MAXLOGMEMBERS then you have to create a new control file. Creating A New Control File Follow the given steps to create a new controlfile Steps 1.

First generate the create controlfile statement

SQL>alter database backup controlfile to trace; After giving this statement oracle will write the CREATE CONTROLFILE statement in a trace file. The trace file will be randomly named something like ORA23212.TRC and it is created in USER_DUMP_DEST directory. 2. Go to the USER_DUMP_DEST directory and open the latest trace file in text editor. This file will contain the CREATE CONTROLFILE statement. It will have two sets of statement one with RESETLOGS and another without RESETLOGS. Since we are changing the name of the Database we have to use RESETLOGS option of CREATE CONTROLFILE statement. Now copy and paste the statement in a file. Let it be c.sql 3. Now open the c.sql file in text editor and set the database name from ica to prod shown in an example below CREATE CONTROLFILE SET DATABASE prod LOGFILE GROUP 1 ('/u01/oracle/ica/redo01_01.log', '/u01/oracle/ica/redo01_02.log'), GROUP 2 ('/u01/oracle/ica/redo02_01.log',

'/u01/oracle/ica/redo02_02.log'), GROUP 3 ('/u01/oracle/ica/redo03_01.log', '/u01/oracle/ica/redo03_02.log') RESETLOGS DATAFILE '/u01/oracle/ica/system01.dbf' SIZE 3M, '/u01/oracle/ica/rbs01.dbs' SIZE 5M, '/u01/oracle/ica/users01.dbs' SIZE 5M, '/u01/oracle/ica/temp01.dbs' SIZE 5M MAXLOGFILES 50 MAXLOGMEMBERS 3 MAXLOGHISTORY 400 MAXDATAFILES 200 MAXINSTANCES 6 ARCHIVELOG; 4. Start and do not mount the database. SQL>STARTUP NOMOUNT; 5.

Now execute c.sql script

SQL> @/u01/oracle/c.sql 6.

Now open the database with RESETLOGS

SQL>ALTER DATABASE OPEN RESETLOGS; 157. How do you create table space with big file? Creating a Bigfile Tablespace To create a bigfile tablespace, specify the BIGFILE keyword of the CREATE TABLESPACE statement (CREATE BIGFILE TABLESPACE ...). Oracle Database automatically creates a locally managed tablespace with automatic segment-spec management. You can, but need not, specify EXTENT MANAGEMENT LOCAL and SEGMENT SPACE MANAGEMENT AUTO in this statement. However, the database returns an error if you specify EXTENT MANAGEMENT DICTIONARY or SEGMENT SPACE MANAGEMENT MANUAL. The remaining syntax of the statement is the same as for the CREATE TABLESPACE statement, but you can only specify one datafile. For example: CREATE BIGFILE TABLESPACE bigtbs DATAFILE '/u02/oracle/data/bigtbs01.dbf' SIZE 50G ...

You can specify SIZE in kilobytes (K), megabytes (M), gigabytes (G), or terabytes (T). If the default tablespace type was set to BIGFILE at database creation, you need not specify the keyword BIGFILE in the CREATE TABLESPACE statement. A bigfile tablespace is created by default. If the default tablespace type was set to BIGFILE at database creation, but you want to create a traditional (smallfile) tablespace, then specify a CREATE SMALLFILE TABLESPACE statement to override the default tablespace type for the tablespace that you are creating. Altering a Bigfile Tablespace Two clauses of the ALTER TABLESPACE statement support datafile transparency when you are using bigfile tablespaces: • RESIZE: The RESIZE clause lets you resize the single datafile in a bigfile tablespace to an absolute size, without referring to the datafile. For example: • ALTER TABLESPACE bigtbs RESIZE 80G; • • AUTOEXTEND (used outside of the ADD DATAFILE clause): With a bigfile tablespace, you can use the AUTOEXTEND clause outside of the ADD DATAFILE clause. For example: ALTER TABLESPACE bigtbs AUTOEXTEND ON NEXT 20G; An error is raised if you specify an ADD DATAFILE clause for a bigfile tablespace. Identifying a Bigfile Tablespace The following views contain a BIGFILE column that identifies a tablespace as a bigfile tablespace: • DBA_TABLESPACES • USER_TABLESPACES • V$TABLESPACE You can also identify a bigfile tablespace by the relative file number of its single datafile. That number is 1024 on most platforms, but 4096 on OS/390. 158. Very next day on the prodction box It looks some procedres/packages got invlidated. What command I should give to know how many packges are invalidated. If suppose thousands are the packages invalidated then what command I should Issut to get then validated. Use dbms_utility.compile_schema procedure to compile all the functions,procedure and packages for a schema.exec dbms_utility.compile_schema('schema_name'); SQL>select object_name object_type status from dba_objects where status 'INVALID'; you can run utlrp.sql residing in $ORACLE_HOME/rdbms/admin and it will try to validate all the objects we can use the @?/rdbms/admin/utlrp.sql The below listed are the scripts that were executed to valid the DBMS_STAT on particular databses. @?/rdbms/admin/dbmsstat.sql @?/rdbms/admin/prvtstas.plb @?/rdbms/admin/prvtstat.plb

159. If the export dump is in one characterset and the target database which has to be imported is in another characterset how could we import that particular dumpfile into target database? In 10g exp/imp can be used to convert to character set but it can result in some data loss or data corruption.consier also when we are migrating form character set A to set B make sure to avod data loss that B is a superset of A. First look into your character set by using this command:select * from v$nls_parameters; There will be a character set column in it. Copy it and EXPORT NLS_LANG (Paste it here before you start your import.) 160. Shall we create procedures to fetch more than one record? You can create a procedure to return REF cursor or VARRAY or PL/SQL Table type out parameters which can return more than one value. 161. How to do the scheduled task/jobs in Unix platform? The two available options are 1. CRONTAB 2. AT (One time scheduling)

Oracle security Interview Questions 162. How will you enable database auditing? In How many ways can you implement database auditing? Auditing is a functionality which keep track of all the activity happening to DB There are two type of auditing in Oracle 1 Standard Auditing 2. Fine grained Auditing The standard Auditing is again divided by Statement Privilege and Object. Statement - Tracks all action on any type of objects Privilege - Tracks action on system level Object - Track action on all the objects (table update delete etc) Enabling Audit Audit_Trail True in int.ora file Audit can be of os db db & extended etc. Dba_audit_trail table is data dictionary table gives information on audit. 163. How to store the passwords in database

For applications dealing with this highly sensitive data like passwords Oracle provides the DBMS_OBFUSCATION_TOOLKIT PL/SQL package to encrypt and decrypt data. It includes string inputs and raw inputs. The function is limited to selected algorithms such as the Data Encryption Standard (DES). The function prohibits making multiple passes of encryption; that is you cannot nest encryption calls thereby encrypting an encrypted value. Well sometimes passwords are not stored encrypted but rather they are stord HASHED. It can be done by using some hash value. (dbms_utility.get_hash_value) 1644. What is Oracle Wallet? Wallet is a Oracle object which keeps the record of Master key for the entire database and all other digital certificates used by the database for encryption purpose. The Walled kept outside the database software and has a different password then DBA system password. 165. What's the Advantage if Listener logging is enabled? Force attempts are not stopped by the Listener but it can log them if logging is enabled. set LOGGING_LISTENER ON 166. How do you Set Password for Listener.ora? oracle@localhost> lsnrctl LSNRCTL> set current_listener LISTENER Current Listener is LISTENER LSNRCTL> set save_config_on_stop on Connecting to (DESCRIPTION (ADDRESS (PROTOCOL IPC)(KEY EXTPROC))) LISTENER parameter save_config_on_stop set to ON The command completed successfully LSNRCTL> change_password Old password: New password: Reenter new password: Connecting to (DESCRIPTION (ADDRESS (PROTOCOL IPC)(KEY EXTPROC))) Password changed for LISTENER The command completed successfully

LSNRCTL> set password Password: The command completed successfully LSNRCTL> stop Connecting to (DESCRIPTION (ADDRESS (PROTOCOL IPC)(KEY EXTPROC))) The command completed successfully LSNRCTL> exit To set the password for the listener.ora are as follows; lsnrctl>lsnrctl password 167. If we have database,then how can we tell the data in the "database is secured" ?what is ment by "data validation"? If we want to say that our Database is secured then we must confirm first that our Data is validate.There are various methods of validating the Data:1. Accept only known valid Data.2. Reject known Bad Data.3. Sanitize Bad data. We cannot emphasize strongly enough that Accept Only Known Valid Data is the best strategy. We do however recognize that this isn't always feasible for political financial or technical reasons and so we describe the other strategies as well.All three methods must check: * Data Type * Syntax * Length Data type checking is extremely important. The application should check to ensure a string is being submitted and not an object for instance.Accept Only Known Valid DataAs we mentioned this is the preferred way to validate data. Applications should accept only input that is known to be safe and expected. As an example let's assume a password reset system takes in usernames as input. Valid usernames would be defined as ASCII A-Z and 0-9. The application should check that the input is of type string is comprised of A-Z and 0-9 (performing canonicalization checks as appropriate) and is of a valid length.Reject Known Bad DataThe rejecting bad data strategy relies on the application knowing about specific malicious payloads. While it is true that this strategy can limit exposure it is very difficult for any application to maintain an up-to-date database of web application attack signatures.Sanitize All DataAttempting to make bad data harmless is certainly an effective second line of defense especially when dealing with rejecting bad input. However as described in the canonicalization section of this document the task is extremely hard and should not be relied upon as a primary defense technique. 168. What are Roles ? Roles are named groups of related privileges that are granted to users or other roles. 169. What is user Account in Oracle database? An user account is not a physical structure in Database but it is having important relationship to the objects in the database and will be having certain privileges. 170. How will you enforce security using stored procedures? Don't grant user access directly to tables within the application.

Instead grant the ability to access the procedures that access the tables. When procedure executed it will execute the privilege of procedures owner. Users cannot access tables except via the procedure. 171. What are the dictionary tables used to monitor a database spaces ? DBA_FREE_SPACE DBA_SEGMENTS DBA_DATA_FILES. 172. What are the roles and user accounts created automatically with the database? DBA - role Contains all database system privileges. SYS user account - The DBA role will be assigned to this account. All of the base tables and views for the database's dictionary are store in this schema and are manipulated only by ORACLE. SYSTEM user account - It has all the system privileges for the database and additional tables and views that display administrative information and internal tables and views used by oracle tools are created using this username. 173. What are the database administrators utilities avaliable ? SQL * DBA - This allows DBA to monitor and control an ORACLE database. SQL * Loader - It loads data from standard operating system files (Flat files) into ORACLE database tables. Export (EXP) and Import (imp) utilities allow you to move existing data in ORACLE format to and from ORACLE database. 174. What are the minimum parameters should exist in the parameter file (init.ora) ? DB NAME - Must set to a text string of no more than 8 characters and it will be stored inside the datafiles, redo log files and control files and control file while database creation. DB_DOMAIN - It is string that specifies the network domain where the database is created. The global database name is identified by setting these parameters (DB_NAME & DB_DOMAIN) CONTORL FILES - List of control filenames of the database. If name is not mentioned then default name will be used. DB_BLOCK_BUFFERS - To determine the no of buffers in the buffer cache in SGA. PROCESSES - To determine number of operating system processes that can be connected to ORACLE concurrently. The value should be 5 (background process) and additional 1 for each user. ROLLBACK_SEGMENTS database startup.

- List of rollback segments an ORACLE instance acquires at

Also optionally LICENSE_MAX_SESSIONS,LICENSE_SESSION_WARNING LICENSE_MAX_USERS.

and

175. What is a trace file and how is it created ? Each server and background process can write an associated trace file. When an internal error is detected by a process or user process, it dumps information about the error to its trace. This can be used for tuning the database. 176. What are roles? How can we implement roles ? Roles are the easiest way to grant and manage common privileges needed by different groups of database users. Creating roles and assigning provides to roles. Assign each role to group of users. This will simplify the job of assigning privileges to individual users. 177. How can you enable automatic archiving ? Shut the database Backup the database Modify/Include LOG_ARCHIVE_START_TRUE in init.ora file. Start up the database. 178. How can we specify the Archived log file name format and destination? By setting the following values in init.ora file. LOG_ARCHIVE_FORMAT = arch %S/s/T/tarc (%S - Log sequence number and is zero left paded, %s - Log sequence number not padded. %T - Thread number lef-zero-paded and %t - Thread number not padded). The file name created is arch 0001 are if %S is used. LOG_ARCHIVE_DEST = path. 179.What are the use of Roles ? REDUCED GRANTING OF PRIVILEGES - Rather than explicitly granting the same set of privileges to many users a database administrator can grant the privileges for a group of related users granted to a role and then grant only the role to each member of the group. DYNAMIC PRIVILEGE MANAGEMENT - When the privileges of a group must change, only the privileges of the role need to be modified. The security domains of all users granted the group's role automatically reflect the changes made to the role. SELECTIVE AVAILABILITY OF PRIVILEGES - The roles granted to a user can be selectively enable (available for use) or disabled (not available for use). This allows specific control of a user's privileges in any given situation. APPLICATION AWARENESS - A database application can be designed to automatically enable and disable selective roles when a user attempts to use the application. 180. What is a profile ? Each database user is assigned a Profile that specifies limitations on various system resources available to the user.

A profile is used to restrict the reource uses password reuses idle time of a session etc. We can also attach a password verify function for the database user. A database user can be assigned a profile. It is an optional clause. By default it takes DEFAULT profile. 181. What are the system resources that can be controlled through Profile ? The number of concurrent sessions the user can establish the CPU processing time available to the user's session the CPU processing time available to a single call to ORACLE made by a SQL statement the amount of logical I/O available to the user's session the amout of logical I/O available to a single call to ORACLE made by a SQL statement the allowed amount of idle time for the user's session the allowed amount of connect time for the user's session. 182. What is Auditing ? Monitoring of user access to aid in the investigation of database use. Auditing in Oracle can be done by writing logs to either the SYS.AUD$ table or to the OS itself. Auditing to the OS makes deleting the audit trail by a DB user more difficult. But auditing all accounts and all actions would severely affect performance. Auditing involves in recording all the activities based on the auditing rules Some types of auditing are Database level Auditing Schema Level auditing Object level Auditing and Statement level auditing. 183. What are the different Levels of Auditing ? Statement Auditing, Privilege Auditing and Object Auditing. Statement Auditing Statement auditing is the auditing of the powerful system privileges without regard to specifically named objects. The Statement auditing is tracking the SQL statements issued by database users. In order to enable or disable auditing on SQL statements you must have the AUDIT SYSTEM privilege. Privilege Auditing Privilege auditing is the auditing of the use of powerful system privileges without regard to specifically named objects. Privilege auditing involves the tracking of the SQL statements issued by users who have been granted the right to execute that statement through a system privilege. In order to enable or disable auditing onSQL statements you must have the AUDIT SYSTEM privilege. Privilege audit options match the corresponding system privileges. For example in order to audit the DELETE ANY TABLE system privilege you would issue the following command: AUDIT DELETE ANY TABLE BY ACCESS WHENEVER SUCCESSFUL. Object Auditing Object auditing is the auditing of accesses to specific schema objects without regard to user. Object auditing involves the tracking of the specific SQL DML statements issued against objects by database users. 184. What is the use of ANALYZE command ?

To perform one of these function on an index,table, or cluster:    

To collect statistics about object used by the optimizer and store them in the data dictionary. To delete statistics about the object used by object from the data dictionary. To validate the structure of the object. To identify migrated and chained rows of the table or cluster.

Oracle Backup and Recovery Interview Questions 185. Why more redos are generated when the database is in begin backup mode? During begin backup mode datafile headers get freezed and as a result row information cannot be retrieved as a result the entire block is copied to redo logs as a result more redo generated and more log switch and in turn more archive logs. SQL> Alter database begin backup; This command freezes the datafile headers as well as controlfile headers but the headers of redolog files are free. Hence if any of the transaction is performed after the online backup command. The SCN's are recorded in the header of redolog files but in the header of datafile and controlfiles header hence extra redo's are generated. 186. Why is the header of datafile and information of control file different at the time of inconsistant backup? When we start datafile backup with begin backup command which will freeze the datafile headers and SCN cannot be updated only in controlfile SCN will update. This process is till end backup. 187. Suppose you have two servers, one at 2nd floor and another on 3rd floor, If you have to configure the server on 3rd floor while sitting on 2nd floor how Will you do it? If both are same domain connect to ftp and ssh or scp / remote desktop connection/netmeetigs/vncserver. 188.How we you identify if a table was exported in its life time? Refer cumulative or an incremental backup (export ) we have a parameter (RECORD) & the default parameter is yes & is to track the incremental backup of a table so those backup (export) information will get update in the following sys tables SYS.INCEXP SYS.INCFIL SYS.INCVID desc SYS.INCVID EXPID desc SYS.INCEXP OWNER# NAME TYPE# CTIME ITIME EXPID

desc SYS.INCFIL EXPID EXPTYPE EXPFILE EXPDATE EXPUSER 189. Is it possible to take backup of catalog database using RMAN? If Yes, How? For my understanding can we take backup the catalog database through RMAN 1. yes possible to take backup like rman target / catalog catalogdbusername/password@catalogdbname How ever it wont be good to have backup like this better to go with offline usermanged backup (or) 2. just say rman and then target as your catalog database and take backup but still it wont be advisable as there is no use of it too Yes Schedule a Schema level Export backup of the RMAN Catalog Database in Task Scheduler or CRON Exporting the Recovery Catalog This example uses the Original Export utility described in Oracle Database Utilities to create a logical export of the recovery catalog. Refer to Oracle Database Utilities for concepts and procedures relating to the Data Pump Export utility. The following procedure creates a logical export of the recovery catalog. 1. Execute the Oracle export utility at the operating system command line making sure to do the following: 

Connect as the owner of the recovery catalog



Specify the OWNER option



Specify an output file

For example if the owner of the catalog in database catdb is rman you can issue the following at the UNIX command line to export the catalog to file cat.dmp: exp rman/cat@catdb FILE cat.dmp OWNER rman 2. Examine the output to make sure you were successful: 3. Export terminated successfully without warnings.

Importing the Recovery Catalog This example uses the Original Import utility described in Oracle Database Utilities to create a logical export of the recovery catalog. Refer to Oracle Database Utilities for concepts and procedures relating to the Data Pump Import utility. To make a logical import of the recovery catalog from the command line: 1. Create a new user in another database. 2. Import the catalog data from the export file. Execute the import at the command line making sure to do the following: 

Connect as the new owner of the recovery catalog.



Specify the old owner with the FROMUSER parameter.



Specify the new owner with the TOUSER parameter.



Specify the import file.

For example assume the following: 

The old owner of the catalog in database prod1 is rman.



The user in the new recovery catalog database catdb2 is rman2.



The file containing the export of the catalog is cat.dmp. The command is then as follows: imp USERID rman2/cat2@catdb2 FILE cat.dmp FROMUSER rman TOUSER rman2 Method 2: When backing up the recovery catalog database you can use RMAN to make the backups. you should start RMAN with the NOCATALOG option so that the repository for the recovery catalog is the control file in the catalog database. Follow these guidelines when developing an RMAN backup strategy for the recovery catalog database:



Run the recovery catalog database in ARCHIVELOG mode so that you can do point-in-time recovery if needed.



Set the retention policy to a REDUNDANCY value greater than 1.



Back up the database onto two separate media (for example disk and tape).



Run BACKUP DATABASE PLUS ARCHIVELOG at regular intervals to a media manager if available or just to disk.



Do not use another recovery catalog as the repository for the backups.



Configure the control file autobackup feature to ON. 190. What are the steps to creating a password authentication file? There are two types of authentications OS level DB level For OS level authentication: 1. Shutdown the database 2. Set OS_AUTHENT_PREFIX=' ' in init.ora file 3.$ connect '/ as sysdba' 4. > startup 5.> create user username(OS level userid created by admin) identified externally; 6.>grant connect, resource to username; 7.dbs$ sqlplus / 8. $username connect / as sysdba 9. startup force For DB level authentication: 1. set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE in init.ora file 2. dbs$orapwd file=orapw$ORACLE_SID password=sys force=y 3. startup force; 4. grant sysdba to user(any user in the database); 5. conn user/user 6. conn user/user as sysdba 7. Show user 191. What is configure command? When do you use this? Configure command is used in RMAN. This is used to configure the parameters for the RMAN database to work while taking backups and doing recoveries.Like: 1. configure controlfile autobackup on; 2. configure retention policy to redundancy 2; show all; command at RMAN will show all configure command in default or update configuration mode 192. What is recovery catalog? Why do you need this? Using a recovery catalog preserves RMAN repository information if the control file is lost making it much easier to restore and recover following the loss of the control file. It stores much more extensive history of your backups than the control file due to limits on the number of control file records. Recovery catalog is a repository of metadata that is available in the control file of the target database. Whenver we take backups using RMAN the copy of the backup is placed in the control file in the form of reusable records and as well as in the recovery catalog in the form of tables. So that while taking recovery also these table info is useful to apply the backup data.

193. What are different types of backup? (Hot, Cold, logical, Physical) Explain in detail.? Hot backups are when database is up and running you take backup(DB has to be in archivelog mode in order to do that.) Cold backups are shutdown the database and copy datafiles control files and save them some place safer(on a different server) Good dba should do that atleast once a month. When you rman backups benefit is that it only backsup blocks that have been used empty data does not get backed up. This is very efficient as far as space issues go. 194. What is the difference between ntbackup and third party backup? One difference between NT Backup and full-blown third-party backup utilities is the lack of an internal backup job scheduler. While most backup utilities can be set to run automatically at a certain time of the day NT Backup doesn t have this option. However scheduling NT Backups is possible with the Windows NT AT command. The AT command which requires that the Windows NT Schedule service be running (by default this service does not run; if you wish to enable it go to Services change its startup type to Automatic and click the start button to have it start immediately) 195. What’s the Concept of Flashback Query in Oracle (10g in particular) and how is it beneficial? It lets you to view and repair historical data.They query the database by TIME or user specified SCN. It do not UNDO anything .It is only a query mechanism.You can take o/p from flashback query and perform an undo yourself. It do not work through DDL operation. for example the data before 5 minutes which has lost is repaired asexecute dbms_flashback.enable_at_time(sysdate-5/1440); ............................................ execute dbms_flashback.disable 196.My database is in archive mode. when log switch occur that log file is archiving . what happens when log switch occurs? After logswitch checkpoint accour.It update the hedder of datafile and controlfile with new SCN no. and checkpoint position.it also give the signal to dbwr to writ dirty buffer to datafile. 197. You have taken a manual backup of a datafile using o/s. How RMAN will know about it? You have to catalog those backups with RMAN using catalog. Whenever we take any backup through RMAN in the repository information of the backup is recorded. The RMAN respository can be either controlfile or recovery catalog. However if I take a backup through OS command then RMAN does not aware of that and hence recorded are not reflected in the repository. This is also true whenever we create a new controlfile or a backup taken by RMAN is transferred to another place using OS command then controlfile/recovery catalog does not know about the prior backups of the database. So in order to restore database with a new created controlfile we need to inform RMAN about the backups taken before so that it can pick one to restore. This task can be done by catalog command in RMAN. With catalog command it can -Add information of backup pieces and image copies in the repository that are on disk.

-Record a datafile copy as a level 0 incremental backup in the RMAN repository. -Record of a datafile copy that was taken by OS. But CATALOG command has some restrictions. It can't do the following. -Can't catalog a file that belong to different database. -Can't catalog a backup piece that exists on an sbt device. Examples of Catalog command 1)Catalog an archive log: To catalog two archived logs named /oracle/oradata/arju/arc001_223.arc and /oracle/oradata/arju/arc001_224.arc the command is RMAN>CATALOG ARCHIVELOG '/oracle/oradata/arju/arc001_223.arc' '/oracle/oradata/arju/arc001_224.arc'; 2)Catalog a file copy as an incremental backup: To catalog datafile copy '/oradata/backup/users01.dbf' as an incremental level 0 backup your command will be RMAN>CATALOG DATAFILECOPY '/oradata/backup/users01.dbf' LEVEL 0; Note that this datafile copy was taken backup either using the RMAN BACKUP AS COPY command or by using operating system utilities in conjunction with ALTER TABLESPACE BEGIN/END BACKUP. 3)Catalog multiple copies in a directory: To catalog all valid backups from directory /tmp/backups issue RMAN>CATALOG START WITH '/tmp/backups' NOPROMPT; 4)Catalog files in the flash recovery area: To catalog all files in the currently enabled flash recovery area without prompting the user for each one issue RMAN>CATALOG RECOVERY AREA NOPROMPT; 5)Catalog backup pieces: To catalog backup piece /oradata2/o4jccf4 issue RMAN>CATALOG BACKUPPIECE '/oradata2/o4jccf4'; Uncatalog Backup In many cases you need to uncatalog command. Suppose you do not want a specific backup or copy to be eligible to be restored but also do not want to delete it. To uncatalog all archived logs issue RMAN>CHANGE ARCHIVELOG ALL UNCATALOG; To uncataog tablespace USERS issue RMAN>CHANGE BACKUP OF TABLESPACE USERS UNCATALOG; To uncatalog a backuppiece name /oradata2/oft7qq issue RMAN>CHANGE BACKUPPIECE '/oradata2/oft7qq' UNCATALOG; 198.If an oracle database has crashed. How would you recover the transactions that are not in the backups? If an Oracle Database has been crashed we can recover the database with SCN. For every commit transaction the SCN will generate. Sql>Alter database recover automatic using backup controlfile until SCN; 199. How to take cold and hot backup using UNIX? We can perform cold backup in unix by shutting down the database in proper mode so the control file will in consistent state and after that u can perform backing up all database files. I hot back we can perform by the stmt >alter tablespace begin backup;

Then enter into unix promt and backup the datafile of that tablespace then >alter tablespace ? end backup;

200. How to recover control file without backup and without 'create control file' command? if we don;t have any backup of Controlfile...then we have to use create controlfile command.. If this is the situation simple process is : 1. Take a trace of control file from clone do the changes in that like database name and datafile name and location. 2. Save it as < name >.ora 3. Run the file in nomount stage. This will create your control file . Note : Always make a habit of taking control file trace with the cold back. 201. How do you verify and validate the Datafile which is backed up? The DBVERIFY Utility An OS executable (dbv in $ORACLE_HOME/bin) used to verify datafiles Works against datafiles live or backup But doesnot work on Backup sets... Works for datafiles on raw devices but you must give it a range of blocks to look at. In the output it refers to blocks as pages . Block 5 would be page 5. 202. RMAN performs its own validation when backing up so dbv is not necessary. It can be used on user backups (aka non-RMAN backups). If a block is influx then DBV was forced to check it multiple times because it was in use. To verify that the datafile is particularly backed up or not. Sql>select * from v$backup-->This will shows the status of a particular file. sql>select * from v$recover_file-->This is show whether any file has to be recovered. 203. How much time will it take a hotbackup if the batabase size is 60Gb? its all upto the Kind of Server and No of server Parameters configured and the type of backup device Depends! On the I/O at that time... Hot backup involves many Steps including - taking the particular Tablespace in begin backup mode and then copying the file to Backup directory.

It all depends on the Server Configuration & I/O at that time. Generally the DB will be stored on EMC - where EMC connects to large number of Servers. 204. What is mean live dead lock? How to prevent it.? A deadlock occurs when two or more users are waiting for data locked by each other(Not commited by user01). To fix this recreate the segment with higher INITTRANS and/or PCTFREE values. This will allow more space in the data blocks for Oracle to allocate more transaction entries (24 bytes at a time) when required 205. what is the difference between recovery and restoring of the database.? Restoring a database is copying the physical files from a backup medium (disk or tape) to the appropriate file locations for database operationRecovery is process of updating database files restored from backup w/changes made to the database since backup, typically using redo log files.(Restored backup files + changes = Recovery) Here is a scenario to understand Restore & Recovery Sunday 10pm : Database is backed up. and is running fine. Monday 11am : Went down / crashed due to some reason. To bring up the database we have 2 options: 1. Simple Restore : copying files from backup taken sunday night and open the database. Here we loose all the changes that are done since sunday night. 2. Restore and Recovery: Copying files from backup taken sunday night and applying all the archivelog and redo log files to bring up the database to the point of failure. Here you dont loose the changes done until monday 11 am. Restore : copying files from the backup overwriting the existing database files Recovery: applying the changes to the database till point of failure. these changes are recorded in online redolog and archivelog ( which are the backups of redolog) files. 206. What are the different tools available for hot backups. Is it preferable to take it manually all the time or it depends on the size of the database. See A hot backup can be done by either RMAN,User Managed Backups by puting tablespace in backup mode my OEM which does the same as the user managed backup.But the Backup depends uponthe size of the database you are using . if the database size in TB the RMAN backup will take more than 10 hours to complete and if the database is critical you can' wait for long to go for so long in this case their are special backup techniques which are given by vendors like TIVOLI and Netbackup they provide BC Vol backup called Business content Volumn Sync

which copies a snapshot of the primary data to another place and backsup the database from one SAN to another with in 15 min for 2 TB of database and is the preferable method for big companies. 1. Using OS level filesystem backup tools 2. RMAN utility 3. Using traditional hot backup methos like keeping the tablespace in backup mode and the using OS level copy command to copy the datafiles to the backup location

207. what is the difference between media recovery & crash recovery..? Datafile media recovery or media recovery is used when we need to recover datafile, controlfile or spfiles( server parameter file).Crash recovery is the recovery of a database in a single-instance configuration or an Oracle Real Application Clusters configuration in which all instances have crashed.Likecrash recovery Oracle will not initiate media recovery on its own, it must be demanded by a DBA only. media failture involves a physical when reading from or writing to a file that is necessary fo the database to operate. media failure is the most serious type of failure and dba intervention requires. To recover database depends on the following: .backup method you choose and which files are affected. .the arechivelog mode of operation of the database. if archiving is used you can apply archived redo log files to recover committed data since the last backup. if you are using rman you can also apply incremental backups. instance failure: .power outage .hardware problems .background processes startup instance---- the oracel server will automatically recover performing both the roll forward and roll back phases. investigates the cause of failure by reading the alert log and any other trace files that were generated during the instance fuilure. oracle never accepts the inconsistency of the database. so when oracle goes down due to power outage or aborted manually next time once the database base is opened it goes mainly to the three states nomount mount and open when oracle try to open the database it makes check of SCN in the controlfile and each database datafile header if the check is not correct it will try to perform crash recovery and apply the online redo logs to bring the database in consistent state. By any means if it could not apply then it will try to locate the archive logs to apply and asks for media recovery. 208. What is the disk migration?what isthe steps involved in diskmigration?

Disk migration is noting but migration of data from one OS dependent database to another Dependent database. The steps involved in this are - first go to your target database and export all your data into flat files -next in the destination database during the installation of the database it asks for data source instead of giving the data of the oracle provided give the path of the flat file you exported previously 209. What are the steps involved in Database Startup ? Start an instance, Mount the Database and Open the Database. Steps are NOMOUNT STAGE 

SGA is allocated



background processes are started



Alert log file is opened Mount Stage



controlfiles is read



name & location of the daatfiles, logfiles are detected Open Stage



files are opened 210. What are the steps involved in Database Shutdown ? Close the Database, Dismount the Database and Shutdown the Instance. There are four types of shutdown Shutdown Normal - Normal is the default mode, here new user can't logon to the database, but the current user can start the new transaction and work till he wants, the database shutdown only after the last user logs off. Shutdown Transactional - here new user can't logon to the database, and the current user can't start the new transaction, once the current transaction complets, database shutdown. Shutdown Immediate - here new user can't logon to the database, user can't start the new transaction, the current transactions rolls back, and database shutdown.

Shutdown Abort - here new user can't logon to the database, user can't start new transaction, the current transaction is not rolled back, database shutdown's. While shutting down oracle updates data file header and control file with the current checkpoint informanation, Except Shutdown Abort the checkpoint is same in datafile header and control file it meansdatabase is consistance and it is clean shutdown. If the checkpoint is not same at both locations then instance recovery required at next startup. 211. What is Restricted Mode of Instance Startup ? An instance can be started in (or later altered to be in) restricted mode so that when the database is open connections are limited only to those whose user accounts have been granted the RESTRICTED SESSION system privilege. To Enable Restricted Session Alter system enable restricted session; To Disable Restricted Session Alter system disable restricted session; To Start the Database in Restricted Mode STARTUP RESTRICT RESTRICT is one of an important option used with an open database. It performs a database startup with the database in the restricted user mode. User must having the privileges of RESTRICT usually it is used by DBA's only. It is used for database maintenence allowing only DBA's to connect and disallowing general user population activity. We can change this mode by using the ALTER DATABASE [RESTRICT] OPEN command. 212. What are the different modes of mounting a Database with the Parallel Server ? Exclusive Mode If the first instance that mounts a database does so in exclusive mode, only that Instance can mount the database. Parallel Mode If the first instance that mounts a database is started in parallel mode, other instances that are started in parallel mode can also mount the database. 213. What is Full Backup ? A full backup is an operating system backup of all data files, on-line redo log files and control file that constitute ORACLE database and the parameter. If you are using the Rman for backup then in Rman full backup means Incremental backup on 0 level.

A full backup can be consistent and inconsistent backupsConsistent Bakup: When the database is down and the backup of the database taken using the operating system copy command. Most of the times the consistent backup would be taken when the database is not in archivelog mode and also the downtime won't affect the system. In this case one should backup datafiles redolog files and controlfile.Inconsistent Backup: This type of backup is taken when the database is up and running and the individual tablespaces are kept in backup mode and the the datafiles are copied using the operating system copy command. The database should be in archivelog mode to take this sort of backup. In this case one should backup datafiles archived redolog files and controlfile. The first choice to be made is whether a backup should be of the entire database or just a part of it. A full backup is the is a backup of all Datafiles control files and the spfile. Remember that as all multiplexed copies of the control files are identical So it is necessary to backup only one of them. We do not backup the on line Redo logs! Online redo logs are protected by multeplexing and optionally by archiving. Also note that only datafiles for permanent tablespace can be backed up. The tempfiles used for your tablespace cannot be backed up by RMAN nor they can be put into backup mode foran operating system backup. A whole backup can be made with RMAN or with operating system commands while the database is open or closed. As a general rule if your database is not running in archive log mode you must always do whole backups.

Backup tools:

Backup can be made using straight forward operating system utilities such as copy or winzip or windows or cp tar or cpi on Unix. However oracle strongly recommends the use of the Recovery manager(RMAN). RMAN is now its fourth generation originally introduced with release 8.0 and perfectly functional then and it has been substantilally enhanced through 8i 9i and 10G. When using logical backup if we give full y - that is a full backup. When using RMAN by default it takes full backup and image copy is also full backup since it contains all blocks used and not used ones. But in RMAN terms full backup is part of incremental backup strategy level 0 is full backup and rest is incremental. We can make image copy as part of incremental backup by using level 0 keyword. The difference between full and whole backup is that full contains all the used locks whereas whole means all datafiles and control file backup. 214. Can Full Backup be performed when the database is open ? No. full backup can be taken with the interaction of oracle where we keep the tablespaces in begin backup mode and the respective datafiles are taken at os.finallt controlfile is taken backup .After that logfile switch should be force for recovery purpose.

Yes by using the Rman you have to take full backup when database is opened. But it is not a synchronized backup because its a hot backup. I have recomended to you go for cold backup. 215. What is Partial Backup ? A Partial Backup is any operating system backup short of a full backup, taken while the database is open or shut down. A partial backup is an operating system backup of part of a database. The backup of an individual tablespace's datafiles or the backup of a control file are examples of partial backups. Partial backups are useful only when the database is in ARCHIVELOG mode. 216. What is On-line Redo Log? The On-line Redo Log is a set of tow or more on-line redo files that record all committed changes made to the database. Whenever a transaction is committed, the corresponding redo entries temporarily stores in redo log buffers of the SGA are written to an on-line redo log file by the background process LGWR. The on-line redo log files are used in cyclical fashion. Redo logs records all the changes to the database whether commited or uncommited. How does it know whether you are committing or rolling back till you commit it. Oracle always thinks positively that everything is going to be commited and writes to the log and when it is rolled back, it rolls back from the rollback segment otherwise those segments will be used for another transactions. Please correct me if iam wrong. Online redologs name is used since archivelogs are called offline redologs. Online redologs can be in three states current to which lWr is currently writing transaction changes then this current becomes active after it gets filled and logswitch/ckpt happens then active becomes inactive only after its contents are syncronized with corresponding datafiles and undofiles after this step it becomes inactive and it can go to current state only from inactive mode since this is a cycle its called cyclic buffer. 217. What is Mirrored on-line Redo Log ? A mirrored on-line redo log consists of copies of on-line redo log files physically located on separate disks, changes made to one member of the group are made to all members. When your database is in archive log mode and you have to set the parameter of pfile that archive files are going on the two seperate disk. It is called on- line Redo Log mirrored. 218. What is Archived Redo Log ? Archived Redo Log consists of Redo Log files that have archived before being reused. Archived redo log means store the history of the redolog files.To recover the database till the point of failer archive files play the important role.for it our database must be in archive mode 219. What are the advantages of operating a database in ARCHIVELOG mode over operating it in NO ARCHIVELOG mode ? Complete database recovery from disk failure is possible only in ARCHIVELOG mode.

Online database backup is possible only in ARCHIVELOG

mode.

220. What is Log Switch ? The point at which ORACLE ends writing to one online redo log file and begins writing to another is called a log switch. When you give this command 'alter system switch logfile' then he generate a checkpoint number which shows that your courrent redo log is full and he write the second redo log. If you want to information about checkpoint the you have to use this view 'V$datafile'. log switch occurs when current redo logfile gets full and lgwr writes redo to next redo logfile. Even we can perform log switch with the command also before we execute the sql execute following statement SQL> select status from v$log; STATUS ---------------UNUSED UNUSED CURRENT------>active redo logfile 3 After execute the statement SQL> alter system switch logfile; System altered. SQL> select status from v$log; STATUS ---------------CURRENT---->now it have changed the position from logfile3 to logfile1 UNUSED ACTIVE 221. What are the steps involved in Instance Recovery ? Rolling forward to recover data that has not been recorded in data files, yet has been recorded in the on-line redo log, including the contents of rollback segments. Rolling back transactions that have been explicitly rolled back or have not been committed as indicated by the rollback segments regenerated in step a. Releasing any resources (locks) held by transactions in process at the time of the failure. Resolving any pending distributed transactions undergoing a two-phase commit at the time of the instance failure. Just startup your database. Oracle will take care remaining process.While Startup of database in Mount stage controlfile information is getting verified and is going to synchronize with Datafile header and online redolog file by CKPT. While SMON willtake care of RollBack and releases the lock held by user process. Steps for Instance Recovery. 1.While performing Instance recovery the oracle server identifies the last check point.The current redo log file is the only file needed a log switch always initiates check point. 2.From the last check point using the current the current redo log file all changes made to the database that are not recorded in the datafile are applied.During the roll forward phase the rbs

and userdata are updated. 3.Then the db is open and users can connect to the database.However some data may be locked by the transaction that did not commit during the rollforward phase. 4.Then Smon comes into the picture and start doing all bncommitted transaction.If Server process initiates recovery before smon rollback.Then Server process initiates recovery transaction. 5.In the Final stage the background process SMON initiates recover when needed. Crash recovery is performed by SMON when database started after an instance crash or after a shutdown abort. Since during crash current transactions are present in redolog files and not yet been written to corresponding files so the SCN number of transactions are not synchronized with datafile headers. So while starting up SMON compares SCN in redologs and datafile headers since its not same it writes committed as well as uncommitted data present in redolog files to datafiles now this step is called rollforward now datafiles contain both committed and uncommitted data. During rollforward undo is generated in undo files. Now this undo is applied to datafiles and uncommitted data is rolled back this is called rollback mechanism instance recovery is one where in RAC setup SMON of one instance performs recovery of other failed instances.

Oracle Architecture Interview Questions 222. What is the command to find the database that already present before connecting ? In UNIX ps -ef || grep Oracle command can be used to know if all the bgprocesses are up and running & in WINDOWS services needs to be checked. select name as "DB Name" from v$database; select global_name from global_name; select ora_database_name from dual; 223. What is remote login user and local user in database?And sid is used when user want to login as local user and Glodal database name is used when user wants to login as remote user.. What does it mean? When you have distributed environment,you may access one database from other.This is normally done via db link.So lets say you have flight database and customer dabatabase.Now from customer database you intend to access flight database then you have to create a database link in customer database providing the login credentials for flight database which would mean that you are mentioning the user name(say flight_admin) of flight database in customer database.Hence the remote user(in this case flight_admin).You may require to mention the domain name in the definition if the domain of both the databases are different else its ok.

224. How to encrypt and decrypt oracle procedure? The WRAP utility 'wraps' or hashes the PL/SQL source code but will not 'unwrap' it to restore the plain text starting point. Oracle can decipher this 'translation' internally however to edit the code one must retain the plaintext source. WRAP is intended to obfuscate source code distributed to client sites in an effort to prevent prying eyes from seeing the underlying logic and to prevent any unauthorized code modification by the client. Again there is no UNWRAP utility so once code is WRAPed it remains such to the naked eye. DBMS_OBFUSCATION_TOOLKIT package is a simple API for data encryption 225. What are the Large object types supported by Oracle? blob clob blob nlob these ususaly support data up to 4GB Oracle provides six data types for storing LOBs: CLOB and LONG for large fixed-width character data NCLOB for large fixed-width national character set data BLOB and LONG RAW for storing unstructured data BFILE for storing unstructured data in operating system files LONG and LONG RAW data types were previously used for unstructured data such as binary images documents or geographical information and are primarily provided for backward compatibility. These data types are superseded by the LOB data types. LOB at types are distinct from LONG and LONG RAW and they are not interchangeable. LOBs will not support the LONG application programming interface (API) and vice versa. 226. What are the Characteristics of Data Files ? A data file can be associated with only one database. Once created a data file can't change size. One or more data files form a logical unit of database storage called a tablespace. 1>datafiles comes under the physical structure of the database. 2>It is used to store the actual data.. each datafile can be associated with one tablespace only.. two datafiles cannot belong to different tablespace.. but two datafiles can belong to same tablespace. 3>we cannot change the system datafiles assocaited with system tablespace.. but we can change the user datafiles associated with users tablespaces,

4>we can resize the datafile,, we can add new datafile to the same tablespace, so whenever database runs lack of space,, either we can change the datafile size or we can add new datafile to the same tablespace.. Oracle architecture: Database->Tablespace->Datafiles Data base is a set of data where data are stored in form of Relational model. Tablespace: tablespace is the logical division of Databse. Each database has atleast one tablespace.i.e SYSETEM tablespace. A tablespace belong to only one database. Datafiles: Datafile is the physical storage of data which associated with tablespace. One datafile must belong to one tablespace. one tablespace can have multiple datafile. Every datafile belongs to one and only tablespace. Note: From Oracle 7.2 datafile can be resized after creation. We can create datafile and alter the existing datafile so that it automatically increase its size when more space is neede in database. the datfile size increases in specified increments up to specified maximum. We can check whether the datfile is autoextensiable. Check in view DBA_DATA_FILES and check AUTOEXTEND ON clause. sql> select * from DBA_DATA_FILES: Increae the size of datafile by adding new datafile with tablespace: sql> alter tablespace SYSTEM add datafile size 10m autoextend on next 512 k maxsize 250m We can crease or decrease the size of existing datafile: sql> alter database datafile resize 100m; datafile_name: '/u02/oracle/rbdb1/stuff01.dbf' 227. what is the difference between SID and Global Database Name ? SID (System Identifier) : A SID (almost) uniquely identifies an instance. Actually, $ORACLE_HOME, $ORACLE_SID and $HOSTNAME identify an instance uniquely. The SID is 64 characters, or less; at least on Oracle 9i. The system identifier is included in the CONNECT_DATA parts of the connect descriptors in a tnsnames.ora file. The SID defaults to the database name. Global Database Name : A database is uniquely identified by a global database name. Usually, a global database name has the form somename.domain. The global database name is the composit of db_domain and db_name.

system identifier (SID) of a database instance. Oracle recommends that you choose a database SID that will not be managed using Enterprise Manager repository.

Global Database Name The full name of the database which uniquely identifies it from any other database. The global database name is of the form database_name.database_domain for example oemrep.us.ovenbird.com. The database name portion oemrep is a simple name you wish to call your database. The database domain portion us.ovenbird.com specifies the database domain in which the database is located makingthe global database name unique. When possible Oracle recommends that your database domain mirror the network domain. The global database name is the default service name of the database as specified by the SERVICE_NAMES parameter in the initialization parameter file. SID The Oracle System Identifier (SID). A name that identifies a specific instance of a running Oracle database. For any database there is at least one instance referencing the database. 228. What is an Integrity Constrains ? An integrity constraint is a declarative way to define a business rule for a column of a table. Special requirements for table data: 1) allow NULL value 2) uniqueness of value 3) primary key 4) foreign key 5) special value size/text/length etc requirements All information is stored in Data Dictionary. 229. Describe the different type of Integrity Constraints supported by ORACLE ? NOT NULL Constraint - Disallows Nulls in a table's column. UNIQUE Constraint - Disallows duplicate values in a column or set of columns. PRIMARY KEY Constraint - Disallows duplicate values and Nulls in a column or set of columns. FOREIGN KEY Constrain - Require each value in a column or set of columns match a value in a related table's UNIQUE or PRIMARY KEY. CHECK Constraint - Disallows values that do not satisfy the logical expression of the constraint. 230. What is difference between UNIQUE constraint and PRIMARY KEY constraint ? A column defined as UNIQUE can contain Nulls while a column defined as PRIMARY KEY can't contain Nulls. Unique key cannot be used to create referential integrity whereas primary key can do. 231. Describe Referential Integrity? A rule defined on a column (or set of columns) in one table that allows the insert or update of a row only if the value for the column or set of columns (the dependent value) matches a value in a column of a related table (the referenced value). It also specifies the type of data manipulation

allowed on referenced data and the action to be performed on dependent data as a result of any action on referenced data. Referential integrity is regarding two columns of two tables in a database. One of these columns serves as the parent column while another is a sort of child column. The child column values form a subset of the parent column values. For example deptno column in employees table must be the subset of values of deptno column in the departments table. Here departments table is theparent table and employess is the child table. 232. What are the Referential actions supported by FOREIGN KEY integrity constraint ? UPDATE and DELETE Restrict - A referential integrity rule that disallows the update or deletion of referenced data. DELETE Cascade - When a referenced row is deleted all associated dependent rows are deleted. 233. What is self-referential integrity constraint ? If a foreign key reference a parent key of the same table is called self-referential integrity constraint. Self referential integrity constraint refers to two columns related by referential integrity which belong to the same table. For example ManagerId column in employees table is a foreign key which refers to EmployeeId in the same table.

234. What are the Limitations of a CHECK Constraint ? The condition must be a Boolean expression evaluated using the values in the row being inserted or updated and can't contain sub queries, sequence, the SYSDATE,UID,USER or USERENV SQL functions, or the pseudo columns LEVEL or ROWNUM. A check constraint allows you to specify a condition on each row in a table. Note: A check constraint can NOT be defined on a VIEW. The check constraint defined on a table must refer to only columns in that table. It can not refer to columns in other tables. A check constraint can NOT include a SUBQUERY. A check constraint can be defined in either a CREATE TABLE statement or an ALTER TABLE statement.

235. What is the maximum number of CHECK constraints that can be defined on a column ? No Limit. You can create any number of check constraints separated by AND OR or NOT to create more complex conditions. 236. What are Schema Objects ? Schema objects are the logical structures that directly refer to the database's data. Schema objects include tables, views, sequences, synonyms, indexes, clusters, database triggers, procedures, functions packages and database links. 237. Can objects of the same Schema reside in different tablespaces.? Yes. 238. Can a Tablespace hold objects from different Schemes ? Yes.

Oracle Memory Management Interview Questions 239. My platform is Enterprise Linux (RHEL AS4) How to find BLOCK SIZE. What is the difference between Row Changing and Row Migration ? Migration and Changing are two distinctly different types of problems that can exist when a row is too large to fit into a single data block. Row Changing:: Row changing occurs when a row is too large to fit into a single empty data block. When this occurs, Oracle will spread the row across as many blocks as are needed. Changing the row from from one block to the next. Row Migration:: Row migration occurs when a row is updated and it will not fit back into the original block. When this happens, the Oracle server attempts to find another block that the entire row can be moved to. If it does find a block, the entire row is moved to the new block. The row piece(head ROWID) remains in the original block, with original ROWID and points to the migrated rowin the new block. 240. Why we do use very small size of RAM compairing then HARD DISK? RAM means Random access memory which is used as a temporary memory space to load Operating system kernel driver modules and services needed on the system. Whenever you switch off the system all the RAM memory contents are lost. Hard disks are for permanent data storage. So hard disks generally have a huge capacity compared to RAM which is temporary memory space. 241. what is application server and web server give the difference between these two servers? Web servers serves the HTTP request and reutrns the HTTP response whereas application server exposes the business methods. These business methods are invoked thru different protocols e.g. Http TCP/IP etc.

Application servers are typically J2EE-based running EJBs or other Java components. Application servers are designed to create true applications with complex business logic and have scalability features such as load balancing fail-over and process distribution. In other words it's primarily a development environment. Webserver hosts the images html or any content related to the presentation. Nowdays most of the servers e.g. weblogic websphere etc. serves both the purposes. 242. How can we start the database if both the pfile and spfile is lost? if ur pfile and spfile both lost then u can do one thing that check alert log file and check necessary parameter for pfile and take that necessary parameter from there and create pfile from that and u can start your database 243. What are the factors causing the reparsing of SQL statements in SGA? When a SQL query is executed it follows the following steps: 1) Search the shared pool. This is to ensure that the copy of the parsed statement is available in the library cache. 2) Validate the statement 3) Validate the data source 4) Acquire locks 5) Check privileges 6) Parse the statement 7) Execute the statement 8) Fetch values from cursor. In case the parse tree is not available in the library cache it needs to reparse the statement. The Library Cache was introduced because parsing (and validating and checking privileges) is expensive in terms of CPU cycles. Oracle uses a LRU/MRU mechanism to keep sql statements in cache. When more room is needed in the cache Oracle drops off the LRU block. When a sql statement is executed Oracle checks the library cache first. If it finds it then there is no need to reparse and it is a hit. If the statement does not exist in cache then it's a miss and oracle needs to read the data from the data blocks. The statement will be parsed. 244. How to implement the multiple control files for an existing database? 1. Edit init.ora file set control_files parameter with multiple location 2. shutdown immediate 3. copy control file to multiple locations & confirm from init.ora contol_files parameter 4. start the database. 5. run this query for changes confirmation - select name from v$controlfile; 245. What is the significance of having storage clause? Better performance proper use of space . 246.Which parameter in Storage clause will reduce number of rows per block?

PCTFREE : This clause is used for future updation If you increase PCTFREE value There will be less rows inserted in block 247. How will you swap objects into a different table space for an existing database? Alter table < Table_Name> move tablespace ; Alter index rebuild tablespace ; 248. How will you force database to use particular rollback segment ? For perticular transaction Alter system set rollback segment 'name'; For database, we can set in pfile. Rollback_segment='name' 249. What is the use of FILE option in EXP command? To give the export file name. 250. What is the use of COMPRESS option in EXP command ? Flag to indicate whether export should compress fragmented segments into single extents. 251. What is the use of GRANT option in EXP command? A flag to indicate whether grants on databse objects will be exported or not. Value is 'Y' or 'N'. 252. What is the use of INDEXES option in EXP command ? A flag to indicate whether indexes on tables will be exported. 253.What is the use of ROWS option in EXP command ? Flag to indicate whether table rows should be exported. If 'N' only DDL statements for the database objects will be created. 254. What is the use of CONSTRAINTS option in EXP command ? A flag to indicate whether constraints on table need to be exported. 255. What is the use of FULL option in EXP command ? A flag to indicate whether full databse export should be performed. 256. What is the use of OWNER option in EXP command ? List of table accounts should be exported. 257. What is the use of TABLES option in EXP command ? List of tables should be exported. 258.What is the use of RECORD LENGTH option in EXP command ? Record length in bytes. 259. What is the use of INCTYPE option in EXP command ?

Type export should be performed COMPLETE,CUMULATIVE,INCREMENTAL. 260. What is the use of RECORD option in EXP command? For Incremental exports, the flag indirects whether a record will be stores data dictionary tables recording the export. 261. What is the use of PARFILE option in EXP command ? Name of the parameter file to be passed for export. 262. What is the use of PARFILE option in EXP command ? Name of the parameter file to be passed for export. 263. What is the use of ANALYSE ( Ver 7) option in EXP command ? A flag to indicate whether statistical information about the exported objects should be written to export dump file. 264. What is the use of CONSISTENT (Ver 7) option in EXP command ? A flag to indicate whether a read consistent version of all the exported objects should be maintained. 265. What is use of LOG (Ver 7) option in EXP command ? The name of the file which log of the export will be written. 266. What is the use of FILE option in IMP command ? The name of the file from which import should be performed. 267.What is the use of SHOW option in IMP command ? A flag to indicate whether file content should be displayed or not. 268. What is the use of IGNORE option in IMP command ? A flag to indicate whether the import should ignore errors encounter when issuing CREATE commands. 269. What is the use of GRANT option in IMP command ? A flag to indicate whether grants on database objects will be imported. 270. What is the use of INDEXES option in IMP command ? A flag to indicate whether import should import index on tables or not. 271. What is the use of ROWS option in IMP command ? A flag to indicate whether rows should be imported. If this is set to 'N' then only DDL for database objects will be executed. 272. What is SGA? How it is different from Ver 6.0 and Ver 7.0? The System Global Area in a Oracle database is the area in memory to facilitates the transfer of information between users. It holds the 273.List the Optional Flexible Architecture (OFA) of Oracle database? or How can we organize the tablespaces in Oracle database to have maximum performance ? SYSTEM - Data dictionary tables. DATA - Standard operational tables. DATA2- Static tables used for standard operations INDEXES - Indexes for Standard operational tables.

INDEXES1 - Indexes of static tables used for standard operations. TOOLS - Tools table. TOOLS1 - Indexes for tools table. RBS - Standard Operations Rollback Segments, RBS1,RBS2 - Additional/Special Rollback segments. TEMP - Temporary purpose tablespace TEMP_USER - Temporary tablespace for users. USERS - User tablespace. 274. How does Space allocation table place within a block ? Each block contains entries as follows Fixed block header Variable block header Row Header,row date (multiple rows may exists) PCTEREE (% of free space for row updation in future) A block is divided into 1. Header 2.free space 3.data space The free space is in the middle shrinks as header and data space grow. Space usage in the data space : The data space is managed with 2 parameters a.pctused b.pctfree suppose pctused 40 and pctfree 20 We know data is stored in the data block in database.The data or rows are filled in the pctused area and they get filled until 80 of the dataspace is full ie100-pctfree.ie Row inserts occur until 80 of dataspace is full. The use of pctfree is to accomadate any growth in dataspace that might occur due to row updation or any previous null values replaced with values. A pctused can also shrink due to any deletion.Suppose a deletion causes pctused to a value 60 from 80 .Now this block is not available for new inserts until pctused is 40 .So when pctused 40 then the block is included into freelist and made available for new inserts. 100-pctfree. 275. How will you create multiple rollback segments in a database ?

Create a database which implicitly creates a SYSTEM Rollback Segment in a SYSTEM tablespace. Create a Second Rollback Segment name R0 in the SYSTEM tablespace. Make new rollback segment available (After shutdown, modify init.ora file and Start database) Create other tablespaces (RBS) for rollback segments. Deactivate Rollback Segment R0 and activate the newly created rollback segments

1. Create rollback segment by using command like create rollback segment rbs01 tablespace tbs1 storage (initial 1M next 1M optimal 5M minextents 20 maxextents 100) 2. Edit the database initialization file to include the name of the new rollback segment ROLLBACK_SEGMENTS (rbs00 rbs01) 3. Stop and restart the database 4. A rollback segment can be brought online by command alter rollback segment rbs01 online

276. How will you monitor rollback segment status ? Querying the DBA_ROLLBACK_SEGS view IN USE - Rollback Segment is on-line. AVAILABLE - Rollback Segment available but not on-line. OFF-LINE - Rollback Segment off-line INVALID - Rollback Segment Dropped. NEEDS RECOVERY - Contains data but need recovery or corupted. PARTLY AVAILABLE - Contains data from an unresolved transaction involving a distributed database. The following views help in monitoring rollback segment usage: 1.

DBA_SEGMENTS

2.

DBA_ROLLBACK_SEGS

3.

V$ROLLNAME

4.

V$ROLLSTAT

5.

V$TRANSACTION 277. List the sequence of events when a large transaction that exceeds beyond its optimal value when an entry wraps and causes the rollback segment to expand into another extend. Transaction Begins.

An entry is made in the RES header for new transactions entry Transaction acquires blocks in an extent of RBS The entry attempts to wrap into second extent. None is available, so that the RBS must extent. The RBS checks to see if it is part of its OPTIMAL size. RBS chooses its oldest inactive segment. Oldest inactive segment is eliminated. RBS extents The Data dictionary table for space management are updated. Transaction Completes. 278. What is Database Buffers ? Database buffers are cache in the SGA used to hold the data blocks that are read from the data segments in the database such as tables, indexes and clusters DB_BLOCK_BUFFERS parameter in INIT.ORA decides the size. 279. What is dictionary cache ? Dictionary cache is information about the databse objects stored in a data dictionary table. 280. What is meant by recursive hints ? Number of times processes repeatedly query the dictionary table is called recursive hints. It is due to the data dictionary cache is too small. By increasing the SHARED_POOL_SIZE 281. What is meant by redo log buffer ? Changes made to entries are written to the on-line redo log files. So that they can be used in roll forward operations during database recoveries. Before writing them into 282. How will you swap objects into a different table space for an existing database ? Export the user Perform import using the command imp system/manager file=export.dmp indexfile=newrite.sql. This will create all definitions into newfile.sql. Drop necessary objects. Run the script newfile.sql after altering the tablespaces. Import from the backup for the necessary objects. 283. How will you force database to use particular rollback segment ? SET TRANSACTION USE ROLLBACK SEGMENT rbs_name.

284. What is meant by free extent? A free extent is a collection of continuous free blocks in tablespace. When a segment is dropped its extents are reallocated and are marked as free.

285. What is the significance of having storage clause? We can plan the storage for a table as how much initial extents are required, how much can be extended next, how much % should leave free for managing row updations etc., 286. How can we plan storage for very large tables? Limit the number of extents in the tableSeparate Table from its indexes.Allocate Sufficient temporary storage. 287. How will you estimate the space required by a non-clustered tables? Calculate the total header sizeCalculate the available dataspace per data blockCalculate the combined column lengths of the average rowCalculate the total average row size.Calculate the average number 288. It is possible to use raw devices as data files and what is the advantages over file. system files ? Yes. The advantages over file system files. I/O will be improved because Oracle is bye-passing the kernnel which writing into disk. Disk Corruption will be very less. Raw devices are controlled by the database engine so the OS kernel can be bypassed when using raw devices. System files reside on filesystem filesystem is addressed by the kernel. So everytime a database request comes the kernel handles the request to fetch data from the system file. The kernel activities are done directly by the database engine in raw devices. 289. What is a Rollback segment entry ? It is the set of before image data blocks that contain rows that are modified by a transaction. Each Rollback Segment entry must be completed within one rollback segment. A single rollback segment can have multiple rollback segment entries. 290. What is hit ratio ? It is a measure of well the data cache buffer is handling requests for data. Hit Ratio = (Logical Reads - Physical Reads - Hits Misses)/ Logical Reads. 291. When will be a segment released ? When Segment is dropped.When Shrink (RBS only)When truncated (TRUNCATE used with drop storage option) 292. What are disadvantages of having raw devices ? We should depend on export/import utility for backup/recovery (fully reliable) The tar command cannot be used for physical file backup, instead we can 293. List the factors that can affect the accuracy of the estimations? The space used transaction entries and a deleted record does not become free immediately after completion due to delayed cleanout. Trailing nulls and length bytes are not stored. Inserts 294. What is meant by recursive hints?

Number of times processes repeatedly query the dictionary table is called recursive hints. It is due to the data dictionary 295. How can we organize the tablespaces in Oracle database to have maximum performance? store data in tablespaces to avoid disk contension.system tablespace-recursive callsuserdatausers objectsindex tablespace-for indexesrollback segmnets-undo tablespace or manual rollback segmentsplace application specific data in respective tablespaces.place all these tablespaces in saperate disks.try to implement raid-0 (striping) for better performance.

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF