You are on page 1of 14

1.What is an Oracle Instance? 2. What information is stored in Control File? 3.

When you start an Oracle DB which file is accessed first? 4. What is the Job of SMON, PMON processes? 5. What is Instance Recovery? 6. What is written in Redo Log Files? 7. How do you control number of Datafiles one can have in an Oracle database? 8. How many Maximum Datafiles can there be in an Oracle Database? 9. What is a Tablespace? 10. What is the purpose of Redo Log files? 11. Which default Database roles are created when you create a Database? 12. What is a Checkpoint? 13. Which Process reads data from Datafiles? 14. Which Process writes data in Datafiles? 15. Can you make a Datafile auto extendible. If yes, how? 16. What is a Shared Pool? 17. What is kept in the Database Buffer Cache? 18. How many maximum Redo Logfiles one can have in a Database? 19. What is difference between PFile and SPFile? 20. What is PGA_AGGREGRATE_TARGET parameter? 21. Large Pool is used for what? 22. What is PCT Increase setting? 23. What is PCTFREE and PCTUSED Setting? 24. What is Row Migration and Row Chaining? 25. What is 01555 - Snapshot Too Old error and how do you avoid it? 26. What is a Locally Managed Tablespace? 27. Can you audit SELECT statements? 28. What does DBMS_FGA package do? 29. What is Cost Based Optimization? 30. How often you should collect statistics for a table? 31. How do you collect statistics for a table, schema and Database? 32. Can you make collection of Statistics for tables automatic? 33. On which columns you should create Indexes? 34. What type of Indexes are available in Oracle? 35. What is B-Tree Index? 36. A table is having few rows, should you create indexes on this table?

Can you change SHARED_POOL_SIZE online? 45. Can you built indexes online? 40. What is an Index Organized Table? 55. When should you rebuilt indexes? 39. What is a Global Index and Local Index? 56. Can you disable and enable Primary key? 54. 41. What is the difference between Direct Path and Convention Path loading? 53. What is the difference between Range Partitioning and Hash Partitioning? . What is DB Buffer Cache Advisor? 43. How do you delete duplicate rows in a table? 49. What is COMPRESS and CONSISTENT setting in EXPORT utility? 52.37. What is the difference between DELETE and TRUNCATE statements? 51. You want users to change their passwords every 2 months. What is STATSPACK tool? 44. Can you assign Priority to users? 47. Can you Redefine a table Online? 46. if you have to? 38. Can you see Execution Plan of a statement. A table is created with the following setting storage (initial 200k next 200k minextents 2 maxextents 100 pctincrease 40) What will be size of 4th extent? 42. How do you enforce this? 48. A Column is having many repeated values which type of index you should create on this column. What is Automatic Management of Segment Space setting? 50.

Swap partition must be how much the size of RAM? 10. How do you see how much hard disk space is free in Linux? 7. How do you remove Memory segments? 16. How do you kill a process in Unix? 20. What is the difference between Soft Link and Hard Link? 17. How do you automate starting and shutting down of databases in Unix? 3. How do you make it run automatically every week? 4. 7. What is DISM in Solaris? 11. What is stored in oratab file? 18. AIX and Solaris? 15. What is difference between Multithreaded/Shared Server and Dedicated Server? 58. What is SAR? 8. How do you set Kernel Parameters in Red Hat Linux. How do you move tables from one tablespace to another tablespace? 60. How do you see which segment belongs to which database instances? 13.3 to 9i? 59. You have written a script to take backups. What is OERR utility? 5. How do you see how many processes are running in Unix? 19. Can you change priority of a Process in Unix? . How do you see how many memory segments are acquired by Oracle Instances? 12.57. How do you see how many instances are running? 2. What is VMSTAT? 14. How do see how much space is used and free in a tablespace? UNIX INTERVIEW QUESTIONS 1. How do you see Virtual Memory Statistics in Linux? 6. What is SHMMAX? 9. Can you import objects from Oracle ver.

Oracle database FAQ Oracle database FAQ: Contents [hide] • • • • • • • • • • • • • • • • • • 1 How does one create a new database? 2 What database block size should I use? 3 What database aspects should be monitored? 4 How does one rename a database? 5 Can one rename a database user (schema)? 6 Can one rename a tablespace? 7 How does one see the uptime for a database? 8 Can one resize tablespaces and data files? 9 How do I find the overall database size? 10 How do I find the used space within the database size? 11 Where can one find the high water mark for a table? 12 How do I find used/free space in a TEMPORARY tablespace? 13 How can one see who is using a temporary segment? 14 Who is using which UNDO or TEMP segment? 15 How does one get the view definition of fixed views/tables? 16 How full is the current redo log file? 17 Tired of typing sqlplus '/as sysdba' every time you want to do something? 18 What patches are installed within an Oracle Home? .

The Oracle Universal Installer (oui) normally starts it after installing the database server software to create the starter database. [edit]What database aspects should be monitored? One should implement a monitoring system to constantly monitor the following aspects of a database. or buying a third-party monitoring product. however. This is because volume manager products use 8K blocks (and this is not configurable). ALTER SYSTEM SET DB_CREATE_ONLINE_LOG_DEST_2='/u03/oradata/'. implementing Oracle's Enterprise Manager. use a smaller block size. With fewer but larger transactions.     . ALTER SYSTEM SET DB_CREATE_ONLINE_LOG_DEST_1='/u02/oradata/'.) to take appropriate action. or be multiples of your operating system block size. This can be achieved by writing custom scripts. Infrastructure availability:  Is the database up and responding to requests Are the listeners up and responding to requests Are the Oracle Names and LDAP Servers up and responding to requests Are the Application Servers up and responding to requests Etc.• 19 How does one give developers access to trace files (required as input to tkprof)? [edit]How does one create a new database? One can create and modify Oracle databases using the Oracle DBCA (Database Configuration Assistant) utility. Also see Creating a New Database. If an alarm is triggered. but the performance cost is significant. as with a DSS application. One can use smaller block sizes. etc. The dbca utility is located in the $ORACLE_HOME/bin directory. the system should automatically notify the DBA (email. consider your "operating system block size" to be 8K. Your choice should depend on the type of application you are running. is falling out of fashion as it is quite involved and error prone. Look at this example for creating an Oracle 9i or higher database: CONNECT SYS AS SYSDBA ALTER SYSTEM SET DB_CREATE_FILE_DEST='/u01/oradata/'. use a larger block size. [edit]What database block size should I use? Oracle recommends that your database block size match. This option. CREATE DATABASE. If you have many small transactions as with OLTP. text. If you are using a volume manager. One can also create databases manually using scripts.

[edit]Can one rename a database user (schema)? No.. Also change "CREATE CONTROLFILE REUSE .sql. Workaround:  Do a user-level export of user A create new user B import system/manager fromuser=A touser=B drop user A    [edit]Can one rename a tablespace? From Oracle 10g Release 1. Edit dbrename.  Locate the latest dump file in your USER_DUMP_DEST directory (show parameter USER_DUMP_DEST) . . Example: ALTER TABLESPACE ts1 RENAME TO ts2.".. Shutdown the database (use SHUTDOWN NORMAL or IMMEDIATE. and change the database's name." to "CREATE CONTROLFILE SET . Rename the database's global name:    ALTER DATABASE RENAME GLOBAL_NAME TO new_db_name. Execute this command from sqlplus while connected to 'SYS AS SYSDBA':  ALTER DATABASE BACKUP CONTROLFILE TO TRACE RESETLOGS. remove all headers and comments.     [edit]How does one rename a database? Follow these steps to rename a database:  Start by making a full database backup of your database (in case you need to restore if this procedure is not working).rename it to something like dbrename..sql. this is listed as Enhancement Request 158508.Things that can cause service outages:  Is the archive log destination filling up? Objects getting close to their max extents Tablespaces running low on free space/ Objects what would not be able to extend User and process limits reached Etc.. don't ABORT!) and run dbrename. users can rename tablespaces.sql.

use the following workaround:  Export all of the objects from the tablespace Drop the tablespace including contents Recreate the tablespace Import the objects    [edit]How does one see the uptime for a database? Look at the following SQL query: SELECT to_char(startup_time.However.dbf' SIZE 100M. you must adhere to the following restrictions:  COMPATIBILITY must be set to at least 10. Extend datafiles . you can add more space to your database without adding more datafiles. [edit]Can one resize tablespaces and data files? Add more files to tablespaces To add more space to a tablespace.1 Cannot rename SYSTEM or SYSAUX Cannot rename an offline tablespace Cannot rename a tablespace that contains offline datafiles    For older releases. This is useful for correcting errors in estimations of space requirements.0. Manually reducing the sizes of datafiles allows you to reclaim unused space in the database. Resize datafiles One can manually increase or decrease the size of a datafile from Oracle 7. one can simply add another file to it. This is beneficial if you are concerned about reaching the maximum number of datafiles allowed in your database.'DD-MON-YYYY HH24:MI:SS') "DB Startup Time" FROM sys.2 using the following command: ALTER DATABASE DATAFILE 'filename2' RESIZE 100M. Example: ALTER TABLESPACE USERS ADD DATAFILE '/oradata/orcl/users1. Because you can change the sizes of datafiles.v_$instance.

datafiles can be allowed to automatically extend if more space is required.data_size+b. ( select sum(bytes) redo_size from sys.temp_size+c. To find out how many megabytes are allocated to ALL datafiles: select sum(bytes)/1024/1024 "Meg" from dba_data_files. To get the size of the on-line redo-logs: select sum(bytes)/1024/1024 "Meg" from sys. ( select nvl(sum(bytes).Also.v_$log. To get the size of all TEMP files: select nvl(sum(bytes).dbf' SIZE 3M AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED DEFAULT STORAGE ( INITIAL 10240 NEXT 10240 MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0) ONLINE PERMANENT. Putting it all together into a single query: select a. ALTER DATABASE DATAFILE 1 AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED.v_$log ) c.0) temp_size from dba_temp_files ) b. [edit]How do I find the overall database size? The biggest portion of a database's size comes from the datafiles. Look at the following commands: CREATE TABLESPACE pcs_data_ts DATAFILE 'c:ora_appspcspcsdata1.redo_size "total_size" from ( select sum(bytes) data_size from dba_data_files ) a.0)/1024/1024 "Meg" from dba_temp_files. Another query ("Free space" reports data files free space): col "Database Size" format a20 col "Free space" format a20 .

(query result 2) . SELECT EMPTY_BLOCKS FROM DBA_TABLES WHERE OWNER=UPPER(owner) AND TABLE_NAME = UPPER(table). .bytes) / 1024 / 1024 ) || ' MB' "Database Size" . the tables' HWM = (query result 1) . SUM(bytes_free) FROM V$temp_space_header GROUP BY tablespace_name.table ESTIMATE STATISTICS. SUM(bytes_used).select round(sum(used.p / 1024 / 1024) || ' MB' "Free space" from (select bytes from v$datafile union all select bytes from v$tempfile union all select bytes from v$log) used . true temporary tablespace information is not listed in DBA_FREE_SPACE. [edit]Where can one find the high water mark for a table? There is no single system table which contains the high water mark (HWM) for a table. Example: SELECT SUM(bytes)/1024/1024 "Meg" FROM dba_segments. ANALYZE TABLE owner. Thus.1 NOTE: You can also use the DBMS_SPACE package and calculate the HWM = TOTAL_BLOCKS . round(free.p / [edit]How do I find the used space within the database size? Select from the DBA_SEGMENTS or DBA_EXTENTS views to find the used space of a database. [edit]How do I find used/free space in a TEMPORARY tablespace? Unlike normal tablespaces. (select sum(bytes) as p from dba_free_space) free group by free. Instead use the V$TEMP_SPACE_HEADER view: SELECT tablespace_name. A table's HWM can be calculated using the results from the following SQL statements: SELECT BLOCKS FROM DBA_SEGMENTS WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table).UNUSED_BLOCKS .1.

all sorts are done in one large temporary segment.name.serial#. Look at these examples: select s.process.block_size) / 1024 / 1024 v$sort_segment A.session_addr and vp. D. D. s.v_$session s. D. s."USER".ts# GROUP BY B. For usage stats.V$_LOCK with type 'TS'. u.tablespace_name.SUM (A.mb_total.contents. s. v$tempfile C WHERE B. C.username. s.osuser.blocks)*vp.used_blocks * D.bbbb' where 'ffff' is the file it is in and 'bbbb' is first block of the segment.v_$parameter vp where s.v$sort_usage. u. [edit]How can one see who is using a temporary segment? For every user using temporary space.username. sys. sum(u. ( SELECT B.used_blocks * D. sys. there is an entry in SYS.To report true free space within the used portion of the TEMPFILE: SELECT A. u.V_$SORT_SEGMENT From Oracle 8. SUM (C. SUM (A. u.saddr = u.ts#= C.block_size.value/1024 sort_size from sys. u.serial#.mb_total .extents.process.block_size ) D WHERE A.tablespace.name GROUP by A. vp.username.block_size) / 1024 / 1024 mb_used.name.blocks from sys.name = 'db_block_size' and s.osuser like '&1' group by s. s.session_addr / select s.v_$session s.v_$sort_usage u. If your temporary tablespace is set to TEMPORARY.tablespace_name = D. All temporary segments are named 'ffff.v_$sort_usage u where s.tablespace_name tablespace.mb_total.osuser. C. sys.bytes) / 1024 / 1024 mb_free FROM mb_total FROM v$tablespace B.saddr = u. s. see SYS. one can just query SYS.value / [edit]Who is using which UNDO or TEMP segment? Execute the following query to determine who is using a particular UNDO or Rollback Segment: .

TABLESPACE SIZE SID_SERIAL USERNAME PROGRAM ---------.v_$session s. 4 r.program 6 FROM sys. 4 a. 7 sys.sid)||'.xidusn(+) 12 AND x.---------.serial#) sid_serial.v_$transaction t. 2 NVL(s.7 SCOTT sqlplus@localhost.username. Example: SELECT * FROM v$fixed_view_definition WHERE view_name='V$SESSION'.name = 'db_block_size' SID_SERIAL ORAUSER PROGRAM UNDOSEG Undo ---------.v_$sort_usage b.taddr = t. 3 a.v_$parameter p 9 WHERE p.name undoseg.localdomain _SYSSMU4$ 8K (TNS V1-V3) Execute the following query to determine who is using a TEMP Segment: SQL> SELECT b.localdomain (TNS V1-V3) [edit]How does one get the view definition of fixed views/tables? Query v$fixed_view_definition.username.sid||'.'||a.used_ublk * TO_NUMBER(x. b.-------.7 SCOTT sqlplus@localhost.blocks.-----------------------------TEMP 24M 260.name = 'db_block_size' 10 AND a.v_$parameter x 10 WHERE s.saddr = b.blocks*p.-----------------------------.serial# SID_SERIAL.tablespace.program.session_addr 11 ORDER BY b.--------------------260.tablespace.value)/1024/1024). 7 sys.v_$rollname r.usn = t. 8 sys. 'None') orauser.addr 11 AND r. 5 t. 9 sys.2)||'M' "SIZE".'||TO_CHAR(s. 8 sys.---------.SQL> SELECT TO_CHAR(s. [edit]How full is the current redo log file? .v_$session a.------. 3 s. 5 a.value)/1024||'K' "Undo" 6 FROM sys. 2 ROUND(((b.

lesiz "Size of Log in Blocks" 5 FROM x$kcccp cp.cpodr_bno "Current Block No". This FAQ will show how you can list and compare the patches installed within your Oracle Homes. Whenever you now want to start sqlplus as sysdba.cpodr_bno/le. implement the following shortcut: On Unix/Linux systems: Add the following alias to your . Note: From Oracle 10g you don't need to put the "/AS SYSDBA" in quotes anymore. and place it somewhere in your PATH. This may lead to situations where a feature works on machine X. 3 cp. 2 100*cp.bat.24) = 8 8 / Current log sequence No Percent Full Current Block No Size of Log in Blocks ----------------------.bash_profile file: alias sss='sqlplus "/as sysdba"' On Windows systems: Create a batch file.leseq "Current log sequence No".lesiz "Percent Full". just type "sss".Here is a query that can tell you how full the current redo log file is. 4 le. sss. All patches that are installed with Oracle's OPatch Utility (Oracle's Interim Patch Installer) can be listed by invoking the opatch command with the lsinventory option. [edit]What patches are installed within an Oracle Home? DBA's often do not document the patches they install. add the command to it. Here is an example: $ cd $ORACLE_HOME/OPatch $ opatch lsinventory . x$kccle le 6 WHERE le. Much less typing for ya lazy DBA's.leflg.-----------. but not on machine Y.leseq =CP.cpodr_seq 7 AND bitand(le. SQL> SELECT le.-----------------------------------416 48. Handy for when you need to predict when the next log file will be archived out.6669922 49835 102400 [edit]Tired of typing sqlplus '/as sysdba' every time you want to do something? If you are tired of typing sqlplus "/as sysdba" every time you want to perform some DBA task.profile or .

0.1. There are no Interim patches installed in this Oracle Home.0 Copyright (c) 2005.r--) these trace files: _trace_files_public = true Include this in your INIT. There is an undocumented INIT. FAQ contributed by Erlie Flynn Category: Frequently Asked Questions • • • •    page discussion edit history site navigation Wiki Home Forum Home Blogger Home • Log in site highlights .0.ORA file and bounce your database for it to take effect.1.. Installed Top-level Products (1): Oracle Database 10g There are 1 products installed in this Oracle Home.2.0 Oracle interim Patch Installer version 10. 10.2. Oracle Corporation.Invoking OPatch 10... On Unix the default file mask for these files are "rwx r-. [edit]How does one give developers access to trace files (required as input to tkprof)? The alter session set sql_trace=true command generates trace files in USER_DUMP_DEST that can be used by developers as input to tkprof.---".2. OPatch succeeded. you may need to download it from Metalink and install it yourself.ORA parameter that will allow everyone to read (rwx r-.1.0.0 NOTE: If OPatch is not installed into your Oracle Home ($ORACLE_HOME/OPatch). . All rights reserved.

:: Wiki Home :: Blogger Home :: Forum Home :: Contact :: Privacy ::. vv . .         search Blog Aggregator FAQ's Mailing Lists Usenet News RSS Feeds wiki navigation Categories Recent changes Random page Help Top of Form Go Bottom of Form toolbox Search       What links here Related changes Upload file Special pages Printable version Permanent link  This page was last modified on 14 June 2010. at 15:07.