Sie sind auf Seite 1von 40

Oracle Concepts and Architecture

Database Structures

More Questions with Practical way explained here in this blog, Please read

1. What are the components of physical database structure of Oracle database?

Oracle database is comprised of three types of files. One or more datafiles, two are more redo log files, and one or
more control files.

2. What are the components of logical database structure of Oracle database?

There are tablespaces and database’s schema objects.

3. What is a tablespace?

A database is divided into Logical Storage Unit called tablespaces. A tablespace is used to grouped related logical
structures together.

4. What is SYSTEM tablespace and when is it created?

Every Oracle database contains a tablespace named SYSTEM, which is automatically created when the database is
created. The SYSTEM tablespace always contains the data dictionary tables for the entire database.

5. Explain the relationship among database, tablespace and data file.

Each databases logically divided into one or more tablespaces one or more data files are explicitly created for each
tablespace.

6. What is schema?

A schema is collection of database objects of a user.

7. 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.

8. Can objects of the same schema reside in different table spaces?

Yes.

9. Can a tablespace hold objects from different schemes?

Yes.

10. What is Oracle table?

A table is the basic unit of data storage in an Oracle database. The tables of a database hold all of the user
accessible data. Table data is stored in rows and columns.

11. What is an Oracle view?

A view is a virtual table. Every view has a query attached to it. (The query is a SELECT statement that identifies the
columns and rows of the table(s) the view uses.)
12. Do a view contain data?

Views do not contain or store data.

13. Can a view based on another view?

Yes.

14. What are the advantages of views?

- Provide an additional level of table security, by restricting access to a predetermined set of rows and columns of a
table.

- Hide data complexity.

- Simplify commands for the user.

- Present the data in a different perspective from that of the base table.

- Store complex queries.

15. What is an Oracle sequence?

A sequence generates a serial list of unique numbers for numerical columns of a database’s tables.

16. What is a synonym?

A synonym is an alias for a table, view, sequence or program unit.

Read this blog for more core practical dba questions

17. What are the types of synonyms?

There are two types of synonyms private and public.

18. What is a private synonym?

Only its owner can access a private synonym.

19. What is a public synonym?

Any database user can access a public synonym.

20. What are synonyms used for?

- Mask the real name and owner of an object.

- Provide public access to an object

- Provide location transparency for tables, views or program units of a remote database.

- Simplify the SQL statements for database users.

21. What is an Oracle index?

An index is an optional structure associated with a table to have direct access to rows, which can be created to
increase the performance of data retrieval. Index can be created on one or more columns of a table.
22. How are the index updates?

Indexes are automatically maintained and used by Oracle. Changes to table data are automatically incorporated into
all relevant indexes.

23. What are clusters?

Clusters are groups of one or more tables physically stores together to share common columns and are often used
together.

24. What is cluster key?

The related columns of the tables in a cluster are called the cluster key.

25. What is index cluster?

A cluster with an index on the cluster key.

26. What is hash cluster?

A row is stored in a hash cluster based on the result of applying a hash function to the row’s cluster key value. All
rows with the same hash key value are stores together on disk.

27. When can hash cluster used?

Hash clusters are better choice when a table is often queried with equality queries. For such queries the specified
cluster key value is hashed. The resulting hash key value points directly to the area on disk that stores the specified
rows.

28. What is database link?

A database link is a named object that describes a “path” from one database to another.

29. What are the types of database links?

Private database link, public database link & network database link.

30. What is private database link?

Private database link is created on behalf of a specific user. A private database link can be used only when the owner
of the link specifies a global object name in a SQL statement or in the definition of the owner’s views or procedures.

31. What is public database link?

Public database link is created for the special user group PUBLIC. A public database link can be used when any user
in the associated database specifies a global object name in a SQL statement or object definition.

32. What is network database link?

Network database link is created and managed by a network domain service. A network database link can be used
when any user of any database in the network specifies a global object name in a SQL statement or object definition.

33. What is data block?

Oracle database’s data is stored in data blocks. One data block corresponds to a specific number of bytes of physical
database space on disk.

34. How to define data block size?


A data block size is specified for each Oracle database when the database is created. A database users and
allocated free database space in Oracle data blocks. Block size is specified in init.ora file and cannot be changed
latter.

35. What is row chaining?

In circumstances, all of the data for a row in a table may not be able to fit in the same data block. When this occurs,
the data for the row is stored in a chain of data block (one or more) reserved for that segment.

36. What is an extent?

An extent is a specific number of contiguous data blocks, obtained in a single allocation and used to store a specific
type of information.

37. What is a segment?

A segment is a set of extents allocated for a certain logical structure.

38. What are the different types of segments?

Data segment, index segment, rollback segment and temporary segment.

39. What is a data segment?

Each non-clustered table has a data segment. All of the table’s data is stored in the extents of its data segment. Each
cluster has a data segment. The data of every table in the cluster is stored in the cluster’s data segment.

40. What is an index segment?

Each index has an index segment that stores all of its data.

41. What is rollback segment?

A database contains one or more rollback segments to temporarily store “undo” information.

42. What are the uses of rollback segment?

To generate read-consistent database information during database recovery and to rollback uncommitted
transactions by the users.

43. 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 segment extents are released to the system for
future use.

44. What is a datafile?

Every Oracle database has one or more physical data files. A database’s data files contain all the database data.
The data of logical database structures such as tables and indexes is physically stored in the data files allocated for a
database.

45. 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.

46. What is a redo log?


The set of redo log files for a database is collectively known as the database redo log.

47. What is the function of redo log?

The primary function of the redo log is to record all changes made to data.

48. What is the use of redo log information?

The information in a redo log file is used only to recover the database from a system or media failure prevents
database data from being written to a database’s data files.

49. What does a control file contains?

- Database name

- Names and locations of a database’s files and redolog files.

- Time stamp of database creation.

50. What is the use of control file?

When an instance of an Oracle database is started, its control file is used to identify the database and redo log files
that must be opened for database operation to proceed. It is also used in database recovery.

Data Base Administration

51. What is a database instance? Explain.

A database instance (Server) is a set of memory structure and background processes that access a set of database
files. The processes can be shared by all of the users.

The memory structure that is used to store the most queried data from database. This helps up to improve database
performance by decreasing the amount of I/O performed against data file.

52. What is Parallel Server?

Multiple instances accessing the same database (only in multi-CPU environments)

53. What is a schema?

The set of objects owned by user account is called the schema.

54. What is an index? How it is implemented in Oracle database?

An index is a database structure used by the server to have direct access of a row in a table. An index is
automatically created when a unique of primary key constraint clause is specified in create table command

55. What are clusters?

Group of tables physically stored together because they share common columns and are often used together is
called cluster.

56. What is a cluster key?

The related columns of the tables are called the cluster key. The cluster key is indexed using a cluster index and its
value is stored only once for multiple tables in the cluster.

57. What is the basic element of base configuration of an Oracle database?


It consists of

one or more data files.

one or more control files.

two or more redo log files.

The Database contains

multiple users/schemas

one or more rollback segments

one or more tablespaces

Data dictionary tables

User objects (table,indexes,views etc.,)

The server that access the database consists of

SGA (Database buffer, Dictionary Cache Buffers, Redo log buffers, Shared SQL pool)

SMON (System MONito)

PMON (Process MONitor)

LGWR (LoG Write)

DBWR (Data Base Write)

ARCH (ARCHiver)

CKPT (Check Point)

RECO

Dispatcher

User Process with associated PGS

58. What is a deadlock? Explain.

Two processes waiting to update the rows of a table, which are locked by other processes then deadlock arises.

In a database environment this will often happen because of not issuing the proper row lock commands. Poor design
of front-end application may cause this situation and the performance of server will reduce drastically.

These locks will be released automatically when a commit/rollback operation performed or any one of this processes
being killed externally.

More practical questions here in this blog

Memory Management

59. What is SGA?


The System Global Area in an Oracle database is the area in memory to facilitate the transfer of information
between users. It holds the most recently requested structural information between users. It holds the most recently
requested structural information about the database. The structure is database buffers, dictionary cache, redo log
buffer and shared pool area.

DBA Interview Question & Answers with practical examples

60. What is a shared pool?

The data dictionary cache is stored in an area in SGA called the shared pool. This will allow sharing of parsed SQL
statements among concurrent users.

61. What is mean by Program Global Area (PGA)?

It is area in memory that is used by a single Oracle user process.

62. What is a data segment?

Data segment are the physical areas within a database block in which the data associated with tables and clusters
are stored.

63. What are the factors causing the reparsing of SQL statements in SGA?

Due to insufficient shared pool size.

Monitor the ratio of the reloads takes place while executing SQL statements. If the ratio is greater than 1 then
increase the SHARED_POOL_SIZE.

Database Logical & Physical Architecture

64. 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.

65. What is dictionary cache?

Dictionary cache is information about the database objects stored in a data dictionary table.

66. 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 parameter we can optimize the size of data
dictionary cache.

67. What is redo log buffer?

Changes made to the records 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 the redo log files, they will first brought to redo log
buffers in SGA and LGWR will write into files frequently. LOG_BUFFER parameter will decide the size.

Read here DBA Questions and answers with practical examples

68. 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.

69. List the Optional Flexible Architecture (OFA) of Oracle database? 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.

70. How will you force database to use particular rollback segment?

SET TRANSACTION USE ROLLBACK SEGMENT rbs_name.

71. 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.

72.Which parameter in Storage clause will reduce number of rows per block?

PCTFREE parameter

Row size also reduces no of rows per block.

73. 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 updating, etc.,

74. 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 updating in future)

75. What is the role of PCTFREE parameter is storage clause?

This is used to reserve certain amount of space in a block for expansion of rows.

Read also: Here

76. What is the OPTIMAL parameter?

It is used to set the optimal length of a rollback segment.

77. What is the functionality of SYSTEM table space?

To manage the database level transactions such as modifications of the data dictionary table that record information
about the free space usage.

78. 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.

79. How the space utilization takes place within rollback segments?

It will try to fit the transaction in a cyclic fashion to all existing extents. Once it found an extent is in use then it forced
to acquire a new extent (number of extents is based on the optimal size)

80. Why query fails sometimes?

Rollback segment dynamically extent to handle larger transactions entry loads.

A single transaction may wipeout all available free space in the rollback segment tablespace. This prevents other
user using rollback segments.

81. How will you monitor the space allocation?

By querying DBA_SEGMENT table/view

82. 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 corrupted.

PARTLY AVAILABLE – Contains data from an unresolved transaction involving a distributed database.

83. 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 tables for space management are updated.

Transaction Completes.

84. How can we plan storage for very large tables?

Limit the number of extents in the table

Separate table from its indexes.

Allocate sufficient temporary storage.

85. How will you estimate the space required by a non-clustered table?

Calculate the total header size

Calculate the available data space per data block

Calculate the combined column lengths of the average row

Calculate the total average row size.

Calculate the average number rows that can fit in a block

Calculate the number of blocks and bytes required for the table.

After arriving the calculation, add 10 % additional space to calculate the initial extent size for a working table.

86. It is possible to use raw devices as data files and what are the advantages over file system files?
Yes.

The advantages over file system files are that I/O will be improved because Oracle is bye-passing the kernel which
writing into disk. Disk corruption will be very less.

87. What is a Control file?

Database’s overall physical architecture is maintained in a file called control file. It will be used to maintain internal
consistency and guide recovery operations. Multiple copies of control files are advisable.

88. How to implement the multiple control files for an existing database?

Shutdown the database

Copy one of the existing control file to new location

Edit Config ora file by adding new control filename

Restart the database.

89. What is redo log file mirroring? How can be achieved?

Process of having a copy of redo log files is called mirroring.

This can be achieved by creating group of log files together, so that LGWR will automatically writes them to all the
members of the current on-line redo log group. If any one group fails then database automatically switch over to next
group. It degrades performance.

90. What is advantage of having disk shadowing / mirroring?

Shadow set of disks save as a backup in the event of disk failure. In most operating systems if any disk failure occurs
it automatically switchover to place of failed disk.

Improved performance because most OS support volume shadowing can direct file I/O request to use the shadow set
of files instead of the main set of files. This reduces I/O load on the main set of disks.

91. What is use of rollback segments in Oracle database?

They allow the database to maintain read consistency between multiple transactions.

92. 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.

93. 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.

94. When will be a segment released?

When Segment is dropped.


When Shrink (RBS only)

When truncated (TRUNCATE used with drop storage option)

95. 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 use dd command, which is less flexible
and has limited recoveries.

96. List the factors that can affect the accuracy of the estimations?

- The space used transaction entries and deleted records, does not become free immediately after completion due to
delayed cleanout.

- Trailing nulls and length bytes are not stored.

- Inserts of, updates to and deletes of rows as well as columns larger than a single data block, can cause
fragmentation a chained row pieces.

Database Security & Administration

97. What is user Account in Oracle database?

A 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.

98. 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.

99. What are the dictionary tables used to monitor a database space?

DBA_FREE_SPACE

DBA_SEGMENTS

DBA_DATA_FILES.

SQL*Plus Statements

100. What are the types of SQL statement?

Data Definition Language: CREATE, ALTER, DROP, TRUNCATE, REVOKE, NO AUDIT & COMMIT.

Data Manipulation Language: INSERT, UPDATE, DELETE, LOCK TABLE, EXPLAIN PLAN & SELECT.

Transactional Control: COMMIT & ROLLBACK

Session Control: ALTERSESSION & SET ROLE

System Control: ALTER SYSTEM.


101. What is a transaction?

Transaction is logical unit between two commits and commit and rollback.

Read here More DBA Questions

102. What is difference between TRUNCATE & DELETE?

TRUNCATE commits after deleting entire table i.e., cannot be rolled back.

Database triggers do not fire on TRUNCATE

DELETE allows the filtered deletion. Deleted records can be rolled back or committed.

Database triggers fire on DELETE.

103. What is a join? Explain the different types of joins?

Join is a query, which retrieves related columns or rows from multiple tables.

Self Join – Joining the table with itself.

Equi Join – Joining two tables by equating two common columns.

Non-Equi Join – Joining two tables by equating two common columns.

Outer Join – Joining two tables in such a way that query can also retrieve rows that do not have corresponding join
value in the other table.

104. What is the sub-query?

Sub-query is a query whose return values are used in filtering conditions of the main query.

105. What is correlated sub-query?

Correlated sub-query is a sub-query, which has reference to the main query.

106. Explain CONNECT BY PRIOR?

Retrieves rows in hierarchical order eg.

select empno, ename from emp where.

107. Difference between SUBSTR and INSTR?

INSTR (String1, String2 (n, (m)),

INSTR returns the position of the m-th occurrence of the string 2 in string1. The search begins from nth position of
string1.

SUBSTR (String1 n, m)

SUBSTR returns a character string of size m in string1, starting from n-th position of string1.

108. Explain UNION, MINUS, UNION ALL and INTERSECT?

INTERSECT – returns all distinct rows selected by both queries.


MINUS – returns all distinct rows selected by the first query but not by the second.

UNION – returns all distinct rows selected by either query

UNION ALL – returns all rows selected by either query, including all duplicates.

109. What is ROWID?

ROWID is a pseudo column attached to each row of a table. It is 18 characters long, blockno, rownumber are the
components of ROWID.

110. What is the fastest way of accessing a row in a table?

Using ROWID.

CONSTRAINTS

111. What is an integrity constraint?

Integrity constraint is a rule that restricts values to a column in a table.

112. What is referential integrity constraint?

Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based
on the values of primary key or unique key of the referenced table.

113. What is the usage of SAVEPOINTS?

SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction.
Maximum of five save points are allowed.

114. What is ON DELETE CASCADE?

When ON DELETE CASCADE is specified Oracle maintains referential integrity by automatically removing
dependent foreign key values if a referenced primary or unique key value is removed.

115. What are the data types allowed in a table?

CHAR, VARCHAR2, NUMBER, DATE, RAW, LONG and LONG RAW.

116. What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each type?

CHAR pads blank spaces to the maximum length.

VARCHAR2 does not pad blank spaces.

For CHAR the maximum length is 255 and 2000 for VARCHAR2.

117. How many LONG columns are allowed in a table? Is it possible to use LONG columns in WHERE clause
or ORDER BY?

Only one LONG column is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.

118. What are the pre-requisites to modify datatype of a column and to add a column with NOT NULL
constraint?

- To modify the datatype of a column the column must be empty.


- To add a column with NOT NULL constrain, the table must be empty.

119. Where the integrity constraints are stored in data dictionary?

The integrity constraints are stored in USER_CONSTRAINTS.

120. How will you activate/deactivate integrity constraints?

The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE CONSTRAINT / DISABLE
CONSTRAINT.

121. If unique key constraint on DATE column is created, will it validate the rows that are inserted with
SYSDATE?

It won’t, Because SYSDATE format contains time attached with it.

122. What is a database link?

Database link is a named path through which a remote database can be accessed.

123. How to access the current value and next value from a sequence? Is it possible to access the current
value in a session before accessing next value?

Sequence name CURRVAL, sequence name NEXTVAL. It is not possible. Only if you access next value in the
session, current value can be accessed.

124. What is CYCLE/NO CYCLE in a Sequence?

CYCLE specifies that the sequence continue to generate values after reaching either maximum or minimum value.
After pan-ascending sequence reaches its maximum value, it generates its minimum value. After a descending
sequence reaches its minimum, it generates its maximum.

NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or minimum value.

125. What are the advantages of VIEW?

- To protect some of the columns of a table from other users.

- To hide complexity of a query.

- To hide complexity of calculations.

126. Can a view be updated/inserted/deleted? If Yes – under what conditions?

A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from one or
more tables then insert, update and delete is not possible.

127. If a view on a single base table is manipulated will the changes be reflected on the base table?

If changes are made to the tables and these tables are the base tables of a view, then the changes will be reference
on the view.
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_MODIFIABLE VARCHAR2(5) Indicates whether the parameter can be changed with ALTER

SESSION (TRUE) or not (FALSE)

ISSYS_MODIFIABLE VARCHAR2(9) Indicates whether the parameter can be changed with ALTER

SYSTEM and when the change takes effect:

 IMMEDIATE – Parameter can be changed with ALTER

SYSTEM regardless of the type of parameter file used to start the

instance. The change takes effect immediately.

 DEFERRED – Parameter can be changed with ALTER

SYSTEM regardless of the type of parameter file used to start the

instance. The change takes effect in subsequent sessions.

 FALSE – Parameter cannot be changed with ALTER SYSTEM unless a

server parameter file was used to start the instance. The change takes

effect in subsequent instances.

SQL> desc v$parameter

SQL> 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 block

5) List types of Oracle objects

table,index,cluster table,IOT (Index Organisation Table),function,package,synonym,trigger,sequence

6) What is an index, how many types of indexes you know? Why you need an index

Index 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.for example: gender column

function 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_SYNONYMS

Query: 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 column

example: employee num,account id

create 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,user

undo: to store undo segments

temp: to store the sort segments

10) 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 file

DMT: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 only

11) 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 the table.We need

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: System

SQL> desc dba_data_files

SQL> select * from dba_data_files where tablespace_name=’SYSTEM';

15) How to see which undo tablespace is used for database?

SQL> show parameter undo_tablespace


NAME TYPE VALUE

———————————— ———– ——————————

undo_tablespace string UNDOTBS3

SQL>

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_NAME

——————————

PROPERTY_VALUE

——————————————————————————–

DEFAULT_TEMP_TABLESPACE

TEMP2

17) How to see what is the default block size for a database?

SQL> show parameter block_size;

NAME TYPE VALUE

———————————— ———– ——————————

db_block_size integer 8192

18) Is it possible to have multiple block sizes in a database if so how? Explain

Yes it is possible but we have to create multiple DB buffer pools while setting the required block size parameter.

To do that it require database bounce.

For example if you want to have 2k size along with default 8k

SQL> show parameter db_2k_cache_size

SQL>alter system set db_2k_cache_size=100M scope=spfile;

SQL>shut immediate

Now we can create the table space using new 2k block size

example: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?

Absolutely no because once the Datafiles are 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 files
Option 1
1) Using NID utility
a)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/dbs
d) cp initaishu.ora initketan.ora
e)vi initketan.ora
find db_name parameter and change it to ketan
f)vi /etc/oratab
change the name aishu to ketan
g) . oraenv
set the variable ORACLE_SID=ketan
f) startup the database
SQL> startup (but the database open will error out since the datbase should open with resetlogs)
h) alter database open resetlogs;

Option 2
By changing the control file
a)alter database backup control file to trace;

b)go to trace directory and edit the control file trace


c)In control file trace update database name aishu to ketan
d)shut down the database
e)remove the control file
f)vi init file and change the dbname aishu to ketan
g)startup nomount
h)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;

cp spfilepaddu.ora spfilekarthika.ora

export ORACLE_SID=karthika
startup
23) 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 user

exp / as sysdba owner=paddu file=/home/oracle/paddu.dmp

sqlplus / as sysdba

SQL> drop user paddu cascade;

QL>create user aishu identified by aishu;

SQL>grant connect,resource to aishu;

SQL> exit

imp file=/home/oracle/paddu.dmp fromuser=paddu touser=aishu

sqlplus / as sysdba

SQL>select username from dba_users;

25) Can you rename the table once it is created?

Yes

connect to user aishu

SQL>connect aishu/aishu

SQl>select * from tab

SQL> create table t as select * from user_tables;

(or)

SQL> create table dummy (id number,name varchar2(50),salary number);

SQL>rename t to t1

26) Can you rename the column in a table?

yes

SQL>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 views

v$ views are dynamic views

DBA views are available once the database is in open mode only

V$ can be viewed even the database is in mount state.

30) What is the difference between a role and privilege, can you provide an example?

Set of privileges is nothing but a role.

Providing authorization to an user such as create, alter, delete, drop, truncate, insert, update.

How many types of privileges are there ?

system privileges : create session/user

object privileges : insert,update,delete or create table

31) Where to view the roles and privileges assigned to a user?

For roles:-desc

dba_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 role

dba_role_privs can be used to know the grantees assigned to that role

For privileges:-

dba_tab_privs: can be used to know what all privileges assigned to a user

SQL> 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 user

SQL> 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 user

admin option : can be used for sysdba privileges to grant other

grant 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 column

a unique constraint will not allow any duplicate value in the column

a 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 number

constraint 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 size

1) 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.ora entry=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 OFA
3)prepare the create db command

4)create catalog views (compile,invalid)


5)add entries in listner.ora,tnsnames.ora

6) add entry in /etc/oratab

42) What is OFA? What is the benefit of it?

Oracle Flexible Architecture

Different 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 space

for example oracle session statistics,system statistics,awr data( automatic work load repository),oracle execution

statistics

44) 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 database

There 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 about no.of rows,no.ofblocks,avg row

length etc.We can view

SQL>select table_name,num_rows,blocks,avg_row_len from dba_tables

for index oracle collect statistics on index column about no.of rows,no.of root blocks,no.ofbranch blocks,no.of leaf

blocks,no.of distinct values etc.

46. Why you need statistics to be collected?

These statistics will help the query execution engine called optimizer to determine how best the data can the

accessed

45) Where to find the table size?

table=create segment in a tablespace, that segment contains extents and that extents contains blocks
T=100 * 8192 = 819200000

dba_segments

SQL>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 mode

ALTER DATABASE DATAFILE ‘/u02/oracle/rbdb1/stuff01.dbf’ RESIZE 100M;.

Can i resize the datafile to lesser than it has?

I have 1gb

I want to 100MB,

But the data in that datafile is upto 500MB

can 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/tbs1′

Note:The drop datafile will only works if the datafile is empty

50) 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 <tablespace name> OFFLINE; command.

3.Copy the datafiles from old location to new location using OS cp


4.Modify the name or location of datafiles in Oracle data dictionary using following command syntax:

ALTER database RENAME DATAFILE ‘<old location>’ TO ‘<new location>';


5.Bring the tablespace online again with ALTER TABLESPACE alter tablespace <tablespace name> ONLINE;

command

51) 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 user

For an example password complexity,password reuse,password expiry,idle time etc

SQL>desc dba_profiles;

SQL> select username,profile from dba_users;

52) How to change the profile of a user?

alter user username profile profile name

53) 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 command

grant 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 admin

56) 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 file

Yes 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 directory

57) 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 high watermark. This leads the table to grow larger than

its size.

58) What is cursor?

Cursor is some thing which resides in the PGA and dc in SGA

A cursor is a handle, or pointer, to the context area. Through the cursor, a … Cursors allow you to fetch and process

rows returned by a SELECT. statement, one …

. 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 implict and explict cursors

59) Can you tell various dynamic views you know about and their purpose?

v$session-shows about sessions information that logged into database

Ex:select sid,status,username,logon_time,blocking_session,module,event,sql_id from v$session

v$process : To view the process information to attached to the session

Ex: select pid,spid,addr from v$process

v$database: To view the database information

Ex: select dbid,name,open_mode,created from v$database;

v$instance : To view the instance information

Ex: SQL>select INSTANCE_NAME, HOST_NAME,STATUS,STARTUP_TIME from v$instance;


v$lock : To view the locked sessions

Ex:SQL> select SID,type,id1,lmode,request from v$lock;

SID is the session ID column that is requesting or holding the lock

TYPE: Type is the column that shows about what kind of end queue or lock it has

ID1 :This column says about the object id that involved in lock.Match this object id dba_objects to get the object

names

LMODE : lock mode it can be 1-6

6 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 modified

From 1-5 the locks are different types of levels which are some shared or table level locks

Row exclusive – Any DML that happens on any row locks as exclusive so that no one can modify

Row 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

exclusive

v$parameter – Displays information about parametters in database

SQL>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 sga

SQL> select * from v$sgastat;

v$sgainfo : Displays information about sga pool sizes

SQL> select * from v$sgainfo;

v$transaction: Displays information about the transactions that running in the database

SQL>select * from v$transaction;

v$pgaStat:displays about pga allocated in the database

SQL>select * from v$pgastat;

v$sga_resize_ops : Displays information about sga resize operation when sga target is set

SQL> select * from v$sga_resize_ops;


v$sysstat : Displays the systems statistics information

SQL> select * from v$sysstat;

v$sesstat : Displays the information about session statistics

SQL> select * from v$sesstat;

Display each statistics information from sysstat but for each session, so 604 statistics X each session

v$logfile : Displays information about the redo log files

SQL> select group#,member,status from v$logfile;

v$log : Displays information about redolog groups

SQL>select group#,members,status from v$log;

v$undostat : Displays the information about undo usage in the database

v$sysaux_occupants : Displays the information about objects that resides in sysaux table space

60) Difference between v$ views and dba_views?

V$ views are dynamic and populated from base table like X$BH and USER$ etc etc

DBA_** views are the the views built on top of v$ views in combination. for example v$session has been built from

v$session,user$ etc

60) 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 serialisation mechanism called end queues in oracle which protects the database of data changes

63) What latches?

latches are typically a kind of locks but held for very short time to protect the memory structures of the instance

64) 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 latch

ORacle 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 etc

65) Where to see the information about latches?

v$latch and v$latch_children

66) How to switch from pfile to spfile?

SQL>create spfile from pfile;

bounce the database;

Now the database will pickup the spfile automatically

67) 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 extents

Extent is a set of block which resides inside the table space, an extent cannot span multiple segments
Segment is set of extents nothing but an object, a segment can spawn multiple datafiles

68) How to get the DDL of a table or index? i.e create statement?

SQL> select dbms_metadata.get_ddl(‘AISHU’,’T’,’TABLE’) from dual

SQL> 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 IMMEDI


SQL> set long 1000

SQL> /

DBMS_METADATA.GET_DDL(‘TABLE’,’T’,’AISHU’)

——————————————————————————–

CREATE TABLE “AISHU”.”T”

( “X” VARCHAR2(100)

) SEGMENT CREATION IMMEDIATE

PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING

STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645

PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE

FAULT CELL_FLASH_CACHE DEFAULT)

TABLESPACE “TESTTBS2″

For user

SQL> select dbms_metadata.get_ddl(‘USER’,’AISHU’) from dual;

DBMS_METADATA.GET_DDL(‘USER’,’AISHU’)

——————————————————————————–

CREATE USER “AISHU” IDENTIFIED BY VALUES ‘S:02BB0F7450ED93B75191C06AD3CD1E1E7

DB11803941FB7B885803634D39F;F8EF185F1D85D4B3′

DEFAULT TABLESPACE “TESTTBS1″

TEMPORARY TABLESPACE “TEMP2″

69) What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace?

Temporary table space for sorting and also used for temporary tables

Permanent table space contains the permanent or business data

70) What is checkpoint? Why does a database need it?

Checkpoint which occurs whenever the redolog switch happens, during this CKPT process writes the check point

information to control file and the data file header and informs the 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$undostat

72) How to set the log archive destination? can we have multiple destinations for archivelogs?

Yes we can have multiple destination for achivelogs

we can have 30 destination from 11g onwards

to see destiantion you can use follow and set accordingly

show parameter log_archive

SQL> 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 topins
Until 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.ora file.
4. STARTUP NOMOUNT
5. Run the script that was modified in step 3
6. ALTER DATABASE OPEN RESETLOGS;
From 10g onwards
Using NID utility
If 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 sequence

75) How to multiplex control files?

if we are using pfile:

show parameter control_files;

Note down the control file location

shut down the database

copy the control file old location to newer location

add the new control file location in parameter file

startup the database

show 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=’spfile’

shut down the database

copy the control file from old location to new location

startup the database

76) 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 inactive

79) Can you drop the system tablespace, if so what happened to database?

No we can’t drop the system tablespace.Oracle will not allow it


80) 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 dropped

but the table space should be empty if not we have to use

SQL>drop tablespace [tablespace name] including contents;

if you want to drop the associated datafiles also with table space we should use

SQL>drop tablespace tablespace name including contents and datafiles;

81) What is the difference between Oracle home and oracle base

ORACLE_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 using

SQL>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 kill

Now execute

SQL> alter system kill session ‘sid,serial#’ immediate;

alternatively we can also find the lock informatin in v$lock

84) Can you kill the pmon or smon or ckpt ? what happens to database?

These are all the mandatory process to run the database.if we 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; 100m

DB buffer cache:db_cache_size; 100m

java pool:java_pool_size; 100m

largepool:large_pool_size; 100m

stream pool:stream_pool_size; 10m

Redolog buffer:log_buffer; 5m

Total SGA manually allocated in pools: 410M

I have also kept SGA_MAX_SIZE=400M in pfile and started the database which one the Oracle consider, 410M or

400M

410M, 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

blocking

Run AWR report to identify:

1. TOP 5 WAIT EVENTS

2. RESOURCE intensive SQL statements

See if STATISTICS on affected tables needs to be re-generated

IF 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 only


Mount: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 closed

instance 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 existed

To find how many instances are running use

ps -eaf | grep pmon

90) 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 entry

91) 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 the tnsnames.ora,

generally tnsnames.ora located at $ORACLE_HOME/network/admin

92) How to change the database into archivelog mode?

SQL> archive log list;

Database log mode Archive Mode

Automatic archival Enabled

Archive destination /u01/archives/paddu

Oldest online log sequence 24


Next log sequence to archive 26

Current log sequence 26


We have to bring the db to mount mode and then use

SQL>alter database close;(This brings the db to mount mode)

SQL>alter database archive log;

SQL>startup force;

To disable the archive log just use

SQL>alter database noarchivelog;

93) How to set the password to expiry of 90 days?

identify the profile for that user

SQL> select username,default_profile from dba_user where username=’user';

SQL> select * from dba_profiles where profile=’DEFAULT';

change the profile for password life time

SQL> 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 tablespace

SQL> 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 UNDOTBS3

SQL> alter system set undo_tablespace=’UNDOTBS4′ scope=spfile;

System altered.

SQL> shut immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 263049216 bytes

Fixed Size 2212448 bytes

Variable Size 167775648 bytes

Database Buffers 88080384 bytes

Redo Buffers 4980736 bytes

Database mounted.

Database opened.

SQL> show parameter undo_tablespace;

NAME TYPE VALUE

———————————— ———– ——————————

undo_tablespace string UNDOTBS4

SQL>

100) Renaming schema

Fastest 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_user…

2. 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=newuser

8. create nondata objects in new_user schema

9. [drop user old_user cascade;]

10. alter tablespace … read write;

Das könnte Ihnen auch gefallen