senior oracle dba interview questions

Upload: nagendrakumarym

Post on 14-Jan-2016

83 views

Category:

Documents


4 download

DESCRIPTION

Senior Oracle DBA Interview Questions

TRANSCRIPT

1) How to set pga size, can you change it while the database is running?show parameter pga_aggregate_target;alter system set pga_aggregate_target=100m;Yes the pga can be changed while the database is up and running.2) How to know which parameter is dynamic/static?ISSES_MODIFIABLEVARCHAR2(5)Indicates whether the parameter can be changed withALTER SESSION(TRUE) or not (FALSE)

ISSYS_MODIFIABLEVARCHAR2(9)Indicates whether the parameter can be changed withALTER SYSTEMand when the change takes effect: IMMEDIATE Parameter can be changed withALTER SYSTEMregardless of the type of parameter file used to start the instance. The change takes effect immediately. DEFERRED Parameter can be changed withALTER SYSTEMregardless of the type of parameter file used to start the instance. The change takes effect in subsequent sessions. FALSE Parameter cannot be changed withALTER SYSTEMunless a server parameter file was used to start the instance. The change takes effect in subsequent instances.

SQL> desc v$parameterSQL> select distinct ISSYS_MODIFIABLE from v$parameter;3) How to know how much free memory available in sga?select * from v$sgastat where name =free memory';4) What are oracle storage structures?Oracle storage structures are tablespace,segment,extent,oracle block5) List types of Oracle objectstable, index, cluster table,IOT (Index Organisation Table),function, package, synonym, trigger, sequence, procedure 6) What is an index, how many types of indexes you know? Why you need an indexIndex is an oracle object which is used to retrieve the data much faster rather than scanning entire table.Typically this is like an index page in a book which contains the links to the pages,where we can go through easily through out the book.If index page is not there,we have to search each and every page for our need,so we use indexes in oracle also to retrive the data quickly.Types of indexes:Btree index:Used for searches mostly when used select statements(Ex:pincode)bit map index:when having low cardinolity (low priority) columns used in thestatements.forexample: gender columnfunction based index:sum(salary), upper(ename), lower(ename)reverse index:used mostly to increase the speed of inserts (its like btree only but the key is reverse).7) What is synonym ?Synonym is used to hide the complexity of the original object.for example user a has table t which user a wants to hide the name but user b has to access it.In this case user a can create a synonym on table t and give a select priviledge to user b.SQL> create synonym aishu on t;SQL> grant select on aishu to b;View: DBA_SYNONYMSQuery: Select synonym_name from dba_synonyms;8) What is sequence?Sequence is a oracle object which used to create the unique and sequential numbering for a columnexample: employee num,account idcreate table employee(id number ,name varchar2(10),salary number);create sequence aishu_seq start with 1 increment by 1;insert into employee values (aishu_seq.nextval,paddu,120000);9) Define different types of tablespaces you know?Permanent: system table space,sys aux,userundo: to store undo segmentstemp: to store the sort segments10) What is the difference between Locally managed tablespace and dictionary managed tablespace?LMT: Locally Managed Table space stores all the extent mapping or allocation details in the header of the data fileDMT:Dictionary Managed Table space stores all the extent mapping or allocation details in the dictionary table called UET$ and FET$Since everytime an allocation of extents generate some recursive sql on UET$ and FET$ this is contention in dictionary cache, hence this is not good for performance of database, but LMT can store this outside of dictionary , coz it stores in header of the data file.By Default from 10g the management is LMT only11) What is Automatic segment space management? and how to find the tablespace in ASSM?Oracle will allocates the extents automatically to the table or segment depending upon the size of thetable.Weneed not to give the storage parameters.SQL>desc dba_tablespaces;SQL> select tablespace_name, allocation_type,segment_space_management,extent_management from dba_tablespaces;12) What is uniform segment? How to find it?In uniform segment every extent will have same size.SQL>desc dba_tablespaces;SQL> select tablespace_name, allocation_type,segment_space_management,extent_management from dba_tablespaces;13) Where do you see the tablespace information?SQL>select * from dba_tablespaces;14) How to find the datafiles that associated with particular tablespace? Ex: SystemSQL> desc dba_data_filesSQL> select * from dba_data_files where tablespace_name=SYSTEM';15) How to see which undo tablespace is used for database?SQL> show parameter undo_tablespaceNAME TYPE VALUE undo_tablespace string UNDOTBS3SQL>16) How to see the default temporary tablespace for a database?SQL> select PROPERTY_NAME,PROPERTY_VALUE from database_properties where PROPERTY_NAME like %TEMP%';PROPERTY_NAMEPROPERTY_VALUEDEFAULT_TEMP_TABLESPACETEMP217) How to see what is the default block size for a database ?SQL> show parameter block_size;NAME TYPE VALUE db_block_size integer 819218) Is it possible to have multiple blocksizes in a database if so how? ExplainYes it is possible but we have to create multiple DB buffer pools while setting the required block sizeparameter.Todo that it require database bounce.For example if you want to have 2k size along with default 8kSQL> show parameter db_2k_cache_sizeSQL>alter system set db_2k_cache_size=100M scope=spfile;SQL>shut immediateNow we can create the table space using new 2k block sizeexample:SQL>create tablespace test_2k datafile /u01/oradata/paddu/test2k.dbf size 100M block size 2k;19) What is the oracle block, can you explain?Oracle block is the lowest level of storage structure where it contains the data(business/oracle data) .The block has divided into many sections starting from block header,row header,row directory,ITL list(Intrested Transaction List),free space.20) Can you change the blocksize once the database is created?Obsolutely no becoz once the datafiles is formatted into 8k we cannot change the database block sizes , if you need, you have to create fresh database with new block size and restore from backup or import.21) Can you change the database name once the database is created?Yes we can but the database has to be shutdown and also this will change all of the headers of the filesOption 11) Using NID utilitya)SQL>alter database close;b) nid target=sys as sysdba dbname=ketan(this will change the control files and headers of the datafiles with the correction of new name)c)cd $ORACLE_HOME/dbsd) cpinitaishu.orainitketan.orae)viinitketan.orafind db_name parameter and change it to ketanf)vi /etc/oratabchange the name aishu to ketang) . oraenvset the variable ORACLE_SID=ketanf) startup the databaseSQL> startup (but the database open will error out since the datbase should open with resetlogs)h) alter database open resetlogs;Option 2By changing the control filea)alter database backup control file to trace;b)go to trace directory and edit the control file tracec)In control file trace update database name aishu to ketand)shut down the databasee)remove the control filef)vi init file and change the dbname aishu to ketang)startup nomounth)execute the control file trace which we modified earlier(this will create a new control file in the location with the new dbname )i) alter database open resetlogs;22) Can you change the instance name once the database is created?SQL>alter system set instance_name=test scope=spfile;shut immediate;cpspfilepaddu.oraspfilekarthika.oraexport ORACLE_SID=karthikastartup23) Can you rename the tablespace once it is created?SQL>alter tablespace testtbs1 rename to testtbs3;24) Can you rename the user once it is created?No there is no direct command to change the user name but there is a work around.1) export userexp / as sysdba owner=paddu file=/home/oracle/paddu.dmpsqlplus / as sysdbaSQL> drop user paddu cascade;QL>create user aishu identified by aishu;SQL>grant connect,resource to aishu;SQL> exitimp file=/home/oracle/paddu.dmpfromuser=paddu touser=aishusqlplus / as sysdbaSQL>select username from dba_users;25) Can you rename the table once it is created?Yesconnect to user aishuSQL>connect aishu/aishuSQl>select * from tabSQL> create table t as select * from user_tables;(or)SQL> create table dummy (id number,name varchar2(50),salary number);SQL>rename t to t126) Can you rename the column in a table?yesSQL>desc t;alter table t rename column result_cache to aishu;27) Where you can see the datafile information?desc dba_data_files;SQL> select tablespace_name,file_name,autoextensible, bytes/1024/1024 SIZE_MB from dba_data_files;28) Where you can see the tempfile or tablespace information?(for a particular database)desc dba_temp_files;desc dba_tablespaces;29) What is the difference between v$ views and dba views?dba views are static viewsv$ views are dynamic viewsdba views are available once the db is in open mode onlyV$ can be viewed even the database is in mount state30) What is the difference between a role and privilege , can you provide an example?Set of priviliges is nothing but a role.providing authorisation to an user such as create,alter,delete,drop,truncate,insert,update.How many types of privileges are there ?system privileges : create session/userobject privileges : insert,update,delete or create table31) Where to view the roles and privileges assigned to a user?For roles:-descdba_roles can be used to know what are all the roles in a database.select * from dba_roles;role_sys_privs can used to know what are all the system privileges assigned to that role.role_tab_privs can be used to know what are all the object privileges assigned to that roledba_role_privs can be used to know the grantees assigned to that roleFor privileges:-dba_tab_privs: can be used to know what all privileges assigned to a userSQL> select grantee,owner,table_name,grantor,privilege from dba_tab_privs where grantee=AISHU';dba_sys_privs: to know what all system privileges assigned to a userSQL> select grantee,privilege from dba_sys_privs where grantee=AISHU';32) What is the difference between with grant option and with admin option while assigning privileges?Grant option : We can grant that grant to other useradmin option : can be used for sysdba privileges to grant othergrant select on T to aishu with grant option;Aishu can grant select on table T to any one;grant dba to aishu with admin option;aishu can grant or manage dba role and assign to anyone.34) How to reovoke privilege or role?revoke select on T from aishu;revoke suresh from aishu;(suresh is a role here )33) How to change the default tablespace for a user?alter user aishu default tablespace t;34) How to give a tablespace quota to a user?alter user aishu grant unlimited quota on tablespace t;36) What are constraints? Can you list them and when will you use them?Constrains in oracle are use to protect the integrity of the data.for example a not null constraint will not allow any null value in the columna unique constraint will not allow any duplicate value in the columna primary key constraint will not allow any duplicate value and null in the column.a foreign key constraint will be from the one of the primary key of the table which means data must resides in the primary key table(Master list table)Master Table (a table that contains primary key)SQL> create table pincode (area varchar2(30), pincodenum number primary key);SQL> insert into pincode values (Miyapur,500049);SQL> insert into pincode values(Ameerpet,500084);Child Table ( aa table that is referred to primary key column)SQL> Create table employee (empname varchar2(30),empid number unique,address1 varchar2(10) check=Hyderabad, address2 varchar2(20),pincode numberconstraint pin_fk foreign key(pincode) references pincode (pincodenum));SQL> Insert into employee values(Aishu,1,Ameerpet,Line,500084);37) What is Row chaining? When does it occur? where can you find it? What is the solution?When the row is not adequate to fit in the block while inserting oracle will insert half row in one block and half in another block leaving a pointer between these two blocks.select table_name,chain_cnt from dba_tables where table_name=tablename';Solutions:create a table with bigger the block size1) Create tablespace ts data file /u01/oradata/aishu/paddu.dbf size 100m blocksize 16k;2) alter table employee move to ts;Here TS is the tablespace name with bigger size, before creating tablespace it is assumed that you have created a db buffer cache for it.38) What is row migration? When does it occur? Where can you find this information?Row migration happens when update occurs at one column and the row is not adequate to fit in the block then the entire row will be moved to the new block.select table_name,chain_cnt from dba_tables where table_name=tablename';Solution:set pct_free storage parameter for table to adequate.;39) How to find whether the instance is using spfile or pfile?show parameter spfile;40) How to create password file?orapwd file=$ORACLE_HOME/dbs/pwaishu.oraentry=5 ignore case=Y;41) How to create a database manually , can you provide steps briefly?1) create a parameter file in /dbs directory with necessary parameters like db_name,instance_name,control file locations,sga_max_size etc..2)create necessary directories for datafiles,trace files,redo log files, control files according OFA3)prepare the create db command4)create catalog views (compile,invalid)SQL> @?/rdbms/admin/catalog.sqlSQL> @?/rdbms/admin/catproc.sql

5) add entries inlistner.ora,tnsnames.ora6) add entry in /etc/oratab42) What is OFA? What is the benefit of it?Oracle Flexible ArchitectureDifferent directory structures with diff files and we keeping the files (redolog,control etc) in the corresponding described locations which keeps the files in track and we can easily manage them,Inaddition to tha I/O will be redistributed.43) What does system tablespace and sysaux tablespace contains?system table space stores the system tables such as dbtables,oracle base tables,dictionary objects that related to oracle.a kind of metada(data about data)Sysaux table space: from 10g onwards oracle has segregated some of the dictionary objects to be created in sysaux table space seperating from system table space to reduce the burden on the one table spacefor example oracle session statistics,system statistics,awr data( automatic work load repository),oracle execution statistics44) Do you know about statistics , what is the use of it? What kind of statistics exists in database?Statistics is a collection information about data or databaseThere are different types of statistics that oracle maintains-1)System-Statistics: statistics about the hardware like cpu speed,I/O speed,read time write time etc : select * from aux_stats$2)Object statistics : For a table oracle collects the information aboutno.ofrows,no.ofblocks,avg row lengthetc.Wecan viewSQL>select table_name,num_rows,blocks,avg_row_len from dba_tablesfor index oracle collect statistics on index column aboutno.ofrows,no.ofroot blocks,no.ofbranch blocks,no.ofleaf blocks,no.ofdistinct values etc.46. Why you need statistics to be collected?These statistics wil help the query execution engine called optimizer to determine how best the data can the accessed45) Where to find the table size?table=create segment in a tablespace, that segment contains extents and that extents contains blocksT=100 * 8192 = 819200000dba_segmentsSQL>select segment_name,bytes/1024/1024 from dba_segments where segment_name=T';46> How to find the size of a database?select sum (bytes) from dba_segments;46) Where to find different types of segments in oracle database?select distinct segment_type from dba_segments;47) How to resize the datafile?To resize a datafile the first most thing is the data file should be in auto extendable modeALTER DATABASE DATAFILE /u02/oracle/rbdb1/stuff01.dbf RESIZE 100M;.Can i resize the datafile to lesser than it has?I have 1gbI want to 100MB,But the data in that datafile is upto 500MBcan i resize to 100mb?Yes we can unless the data is not above 100MB in the datafile.48) How to add datafile to a tablepsace?alter tablespace t add datafile /u01/oradata/paddu/tbs1 size 100M;49) How to delete the datafile?alter tablespace t drop datafile /u01/oradata/paddu/tbs1Note:The drop datafile will only works if the datafile is empty50) How to move datafiles from one location to another location? Can you provide the steps?1.Connect as SYS DBA with CONNECT / AS SYSDBA command.2.Make offline the affected tablespace with ALTER TABLESPACE OFFLINE; command.3.Copy the datafiles from old location to new location using OS cp4.Modify the name or location of datafiles in Oracle data dictionary using following command syntax:ALTER database RENAME DATAFILE TO ';5.Bring the tablespace online again with ALTER TABLESPACE alter tablespace ONLINE; command51) What is profile? what is the benefit of profile? Where do you see the information of profiles? Provide an example of profile?Profile is a set of properties assign to an userFor an example password complexity,password reuse,password expiry,idle time etcSQL>desc dba_profiles;SQL> select username,profile from dba_users;52) How to change the profile of a user?alter user username profile profile name53) How to create user?create user username identified by password default tablespace testtbs1 profile test;ex: create user paddu identified by paddu default tablespace testtbs1 profile test;SQL> select username,profile from dba_users;SQL> grant connect,resource to paddu;54) How to create schema?schema is nothing but an user.55) How to grant privileges to user?using grant commandgrant create table to user;grant create table to user with grant option;Note: with grant option provides user to grant the privilege to other users as well, kind of admin56) Can you delete alert log while database is up and running?show parameter background;Yes database can create a new alert log file,but whenever any activity happens in the database it creates a new alert log fileYes one can delete or move the alert log file while the database is up and running there will be no impact,oracle will automatically creates a new alert log if it not found any in the directory57) What is fragmentation of table?Fragmentation of a table is something when ever there is a purge or deletion of a table.Oracle will not use those unused blocks and always try to allocate the extents above highwatermark.thisleads the table to grow larger than its size.58) What is cursor?Cursor is some thing which resides in the PGA and dictionary cache in SGA.

A cursor is a handle, or pointer, to the context area. Through the cursor, Cursors allow you to fetch and process rows returned by a SELECT statement, Through the cursor, a PL/SQL program can control the context area and what happens to it as the statement is processed.

Two important features about the cursor are implicit and explicit cursors.

An implicit cursor is one created "automatically" for you by Oracle when you execute a query. It is simpler to code, but suffers fromInefficiency (the ANSI standard specifies that it must fetch twice to check if there is more than one record).Vulnerability to data errors (if you ever get two rows, it raises a TOO_MANY_ROWS exception).

Example :-SELECT col INTO var FROM table WHERE something;

An explicit cursor is one you create yourself. It takes more code, but gives more control - for example, you can just open-fetch-close if you only want the first record and don't care if there are others.

Example:-DECLARE CURSOR cur IS SELECT col FROM table WHERE something; BEGIN OPEN cur; FETCH cur INTO var; CLOSE cur;END;

59) Can you tell various dynamic views you know about and their purpose?v$session-shows about sessions information that logged into databaseEx:select sid,status,username,logon_time,blocking_session,module,event,sql_id from v$sessionv$process : To view the process information to attached to the sessionEx: select pid,spid,addr from v$processv$database: To view the database informationEx: select dbid,name,open_mode,created from v$database;v$instance : To view the instance informationEx: SQL>select INSTANCE_NAME, HOST_NAME,STATUS,STARTUP_TIME from v$instance;v$lock : To view the locked sessionsEx:SQL> select SID,type,id1,lmode,request from v$lock;SID is the session ID column that is requesting or holding the lockTYPE: Type is the column that shows about what kind of end queue or lock it hasID1 :This column says about the object id that involved inlock.Matchthis object id dba_objects to get the object namesLMODE : lock mode it can be 1-66 is the least level of lock and an exclusive lock,when we update a row that row will be locked as exclusive so that no one will be modifiedFrom 1-5 the locks are different types of levels which are some shared or table level locksRow exclusive Any DML that happens on any row locks as exclusive so that no one can modifyRow shared Select statement ran, during that period the rows will be in shared mode so that no modification to be done until that select retrieve all rows.Table Lock When an update statement ran on column , no other can moidfy the structure of table, and allow row exclusivev$parameter Displays information about parametters in databaseSQL>select name,value,ISSYS_MODIFIABLE from v$parameter where name=sga_target';v$sgastat : Displays information about sga individual pool sizes and also displays free memory in the sgaSQL> select * from v$sgastat;v$sgainfo : Displays information about sga pool sizesSQL> select * from v$sgainfo;v$transaction: Displays information about the transactions that running in the databaseSQL>select * from v$transaction;v$pgaStat:displays about pga allocated in the databaseSQL>select * from v$pgastat;v$sga_resize_ops : Displays information about sga resize operation when sga target is setSQL> select * from v$sga_resize_ops;v$sysstat : Displays the systems statistics informationSQL> select * from v$sysstat;v$sesstat : Displays the information about session statisticsSQL> select * from v$sesstat;Display each statistics information from sysstat but for each session, so 604 statistics X each sessionv$logfile : Displays information about the redo log filesSQL> select group#,member,status from v$logfile;v$log : Displays information about redolog groupsSQL>select group#,members,status from v$log;v$undostat : Displays the information about undo usage in the databasev$sysaux_occupants : Displays the information about objects that resides in sysaux table space60) Difference between v$ views and dba_views?V$ views are dynamic and populated from base table like X$BH and USER$ etc etcDBA_** views are the the views built on top of v$ views in combination. for example v$session has been built from v$session,user$ etc60) Where to view the session information?SQL> select sid,status,username,logon_time,machine,sql_id,blocking_session,event from v$session where sid=;If you do not know the sid replace with any column information you know in where condition.61) Where to view the process associated with session information?select sid,status,username,action,program,machine from v$session where paddr in (select addr from v$process where spid=5046);61) Where to view the locks in oracle database?v$lock

62) What are locks?locks are low level serialization mechanism called end queues in oracle which protects the database of data changes63) What latches?latches are typically a kind of locks but held for very short time to protect the memory structures of the instance64) Where does Oracle latch or lock occurs?Oracle latch occurs in the memory structures i.e, in instance ex:buffer latch,redolog latch,shared pool latchOracle lock occurs at block level to protect the integrity of the data as the data stored in the block only ex: row lock,table lock etc65) Where to see the information about latches?v$latch and v$latch_children66) How to switch from pfile to spfile?SQL>create spfile from pfile;bounce the database;Now the database will pickup the spfile automatically67) Explain the difference between a data block, an extent and a segment.Data block is a lowest level storage structure, a block cannot span multiple extentsExtent is a set of block which resides inside the table space, an extent cannot span multiple segmentsSegment is set of extents nothing but an object, a segmentcan spawnmultiple datafiles68) How to get the DDL of a table or index? i.e create statement?SQL> select dbms_metadata.get_ddl(AISHU,T,TABLE) from dualSQL> select dbms_metadata.get_ddl(TABLE,T,AISHU) from dual;DBMS_METADATA.GET_DDL(TABLE,T,AISHU)CREATE TABLE AISHU.T( X VARCHAR2(100)) SEGMENT CREATION IMMEDISQL> set long 1000SQL> /DBMS_METADATA.GET_DDL(TABLE,T,AISHU)CREATE TABLE AISHU.T( X VARCHAR2(100)) SEGMENT CREATION IMMEDIATEPCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGINGSTORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)TABLESPACE TESTTBS2For userSQL> select dbms_metadata.get_ddl(USER,AISHU) from dual;DBMS_METADATA.GET_DDL(USER,AISHU)CREATE USER AISHU IDENTIFIED BY VALUES S:02BB0F7450ED93B75191C06AD3CD1E1E7DB11803941FB7B885803634D39F;F8EF185F1D85D4B3DEFAULT TABLESPACE TESTTBS1TEMPORARY TABLESPACE TEMP269) What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace?Temporary table space for sorting and also used for temporary tablesPermanent table space contains the permanent or business data._________________________________________________________________________________________________70) What is checkpoint? why database need it?checkponit which occurs when ever the redolog switch happens,during this ckpt process writes the check point information to control file and the data file header and tells to dbwr to flush the dirty buffer from buffer cache to disk until that check point.71) What is log switch, when does it occurs?Log switch occurs when the current redo log is full and the log writer has to go to next redo log group.71) Where to view the undo usage information?v$undostat72) How to set the log archive destination? can we have multiple destinations for archivelogs?Yes we can have multiple destination for achivelogswe can have 30 destination from 11g onwardsto see destiantion you can use follow and set accordinglyshow parameter log_archiveSQL> alter system set log_archive_dest= scope=memory;System altered.SQL> alter system set log_archive_dest_1=location=/u02/archives/paddu scope=memory;System altered.SQL> alter system set log_archive_dest_2=location=/u01/archives/paddu scope=memory;System altered.SQL>73) Can you rename a database? Provide steps?Yes, we can rename a database, we have two topinsUntil 10g,As the database name is written in control file we have to change the database name in control file and in init file.1. Alter Database backup control file to trace;2. Above step will create a text control file in user_dump_dest directory.3. Change name of the Database in above file and ininit.orafile.4. STARTUP NOMOUNT5. Run the script that was modified in step 36. ALTER DATABASE OPEN RESETLOGS;From 10g onwardsUsing NID utilityIf I am changing the database name , does mu backup are valid?Invalid, Your database name is changed so the old backup backup in invalid as the name is old, rman check with dbid and name.74) Why you need to do open resetlogs, what does it?Whenever there is recovery operation performed specifically incomplete media recovery , the database must be open with reset logs since we dont have the archives or redo information until point of failure, hence this is required. further this will reset the archive log sequence75) How to multiplex controlfiles?if we are using pfile:show parameter control_files;Note down the control file locationshut down the databasecopy the control file old location to newer locationadd the new control file location in parameter filestartup the databaseshow parameter control_files;(this shows the old and new location as well)if we are using spfile:show parameter control_files;alter system set controlfile=oldlocation,newlocation scope=spfileshut down the databasecopy the control file from old location to new locationstartup the database76) How to multiplex redo log files?alter database add log to group3;77) How to add redo log groups to a database?alter database add log size 50m group6;v$log or v$logfiles;78) Can you drop the redo log groups while the database is up and running?Yes we can drop the redolog group but the redo log should be inactive79) Can you drop the system tablespace, if so what happened to database?No we cant drop the system tablespace.Oracle will not allow it80) Can you drop the normal tablespace, if so what happened to database?Yes we can drop the normal table spaces but the associated objects will be droppedbut the table space should be empty if not we have to useSQL>drop tablespace tablespace name including contents;if you want to drop the associated datafiles also with table space we should useSQL>drop tablespace tablespace name including contents and datafiles;81) What is the difference between Oracle home and oracle baseORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside.82) Where do you check the free space of objects?SQL>dba_free_space;select * from dba_free_space;83) How to kill the blocking session, how to find the blocking session?We have to find the blocking session information by usingSQL>select sid,username,serial#,status,event,blocing_session from v$session where username=SYS';Now check the blocking_session column for the sid that is blocking and confirm with the application team to killNow executeSQL> alter system kill session sid,serial# immediate;alternatively we can also find the lock informatin in v$lock84) Can you kill the pmon or smon or ckpt ? what happens to database?These are all the mandatory process to run thedatabase.ifwe kill any of the process the DB will be crash.85) Define the parameters for different pools of oracle instance?shared pool:shared_pool_size;DB buffer cache:db_cache_size;java pool:java_pool_size;largepool:large_pool_size;stream pool:stream_pool_size;Redolog buffer:log_buffer;alternatively sga_max_size and sga_target should set to manage this pools automatically.86) Consider the scenario below,shared pool:shared_pool_size; 100mDB buffer cache:db_cache_size; 100mjava pool:java_pool_size; 100mlargepool:large_pool_size; 100mstream pool:stream_pool_size; 10mRedolog buffer:log_buffer; 5mTotal SGA manually allocated in pools: 410MI have also kept SGA_MAX_SIZE=400M in pfile and started the database which one the Oracle consider, 410M or 400M410M, if the sga_max_size is lesser than the all pools total if specified in pfile then sga_max_size parameter is ignored.86) List Process you follow to start looking into Performance issue at database level (If the application is running very slow, at what points do you need to go about the database in order to improve the performance?)Answer ( Although i have never worked directly on performance issues, the below can be steps)Run a TOP command in Unix to see CPU usage (identify CPU killer processes)Run VMSTAT, SAR, and PRSTAT command to get more information on CPU and memory usage and possible blockingRun AWR report to identify:1. TOP 5 WAIT EVENTS2. RESOURCE intensive SQL statementsSee if STATISTICS on affected tables needs to be re-generatedIF poorly written statements are culprit, run a EXPLAIN PLAN on these statements and see whether new index or use of HINT brings the cost of SQL down.87) Can you explain different modes of startup of oracle database?No mount:starts the instance and bg process onlyMount:Oracle reads the control file and identify all the datafiles and kept them ready.Open:The datafiles marked as read/write and database is now ready for operation.88) Can you explain different modes of shutdown of oracle database?close:all the changes in the buffer cache will be pushed to datafiles and existed session will be disconnected and no new sessions will be permitted.dismount: All the datafiles will be closedinstance shut down:bg wil be stopped and memory pools will be cleared from OS.89) How to know how many oracle homes or oracle instances exists in database host?Once the oracle installation is completed the installer will update the file called /etc/oratab with new home with this file we can find how many homes are existedTo find how many instances are running useps -eaf | grep pmon90) What is the difference between putty and sqlplus?Putty is an ssh client to connect to the database host from remotely.SQL database connectivity tool to connect to the database using tns names entry91) What is tns string?tns string is an entry to identify the database host,db port and the db name.Oracle will use oracle sqlplus will use this entries appropriate or right database host.92) What is tnsentry?Tns entry is a address to the database host and database written in thetnsnames.ora, generallytnsnames.oralocated at $ORACLE_HOME/network/admin92) How to change the database into archivelog mode?SQL> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination /u01/archives/padduOldest online log sequence 24Next log sequence to archive 26Current log sequence 26We have to bring the db to mount mode and then useSQL>alter database close;(This brings the db to mount mode)SQL>alter database archive log;SQL>startup force;To disable the archive log just useSQL>alter database noarchivelog;93) How to set the password to expiry of 90 days?identify the profile for that userSQL> select username,default_profile from dba_user where username=user';SQL> select * from dba_profiles where profile=DEFAULT';change the profile for password life timeSQL> alter profile default set limit=PASSWORD_LIFE_TIME=90;94) How to set the new password for Oracle user?alter user username identified by newpassword;95) How to set the same password to oracle user when the password is expired?select username,password from dba_users where username=username';SQL>alter user username identified by values above password';96) Where do you find the password for oracle user?select username,password from dba_users where username=username';97)How to set new undo tablespace in oracle database?create a new undo tablespaceSQL> create undo tablespace undotbs4 datafile /u01/oradata/paddu/undotbs4.dbs size 100m;Tablespace created.SQL> show parameter undo_tablespace;NAME TYPE VALUE undo_tablespace string UNDOTBS3SQL> alter system set undo_tablespace=UNDOTBS4 scope=spfile;System altered.SQL> shut immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 263049216 bytesFixed Size 2212448 bytesVariable Size 167775648 bytesDatabase Buffers 88080384 bytesRedo Buffers 4980736 bytesDatabase mounted.Database opened.SQL> show parameter undo_tablespace;NAME TYPE VALUE undo_tablespace string UNDOTBS4SQL>100) Renaming schemaFastest Way, since the original import will not happen only metadata creation will happen, as the transportable import has been performed, In TTS the associated datafiles will be attached to new user , hence the datafiles with existing object(tables/indexex etc) will be point to new user.1. create user new_user2. grant to new_user;3. execute dbms_tts.transport_set_check();4. alter tablespace read only;5. exp transport_tablespace=y tablespaces=6. drop tablespace including contents;7. imp transport_tablespace=y tablespaces= datafiles= fromuser=old_user touser=newuser8. create nondata objects in new_user schema9. [drop user old_user cascade;]10. alter tablespace read write;