Академический Документы
Профессиональный Документы
Культура Документы
Varchar means fixed length char varchar2 means variable length char
a. The biggest difference between Oracle8i and Oracle9i is that Oracle9i lets you
resize the SGA memory areas dynamically i.e., the Database Buffer Cache
DB_CACHE_SIZE or the SHARED_POOL_SIZE, etc., can be resized when the database
is up and running. The same is not possible with Oracle8i. You can get more
information from OTN
c. you can drop a column in oracle 9i using alter table command where as this is
not available in oracle 8i
OCI: - OCI refer to Oracle Call interface is set of Low Level API (Application Program
Interface Call) used to interact with Oracle Database. By OCI one can use the
operation such as Logon, Fatch, parse, execute etc. Generally these are written in
C/C++.
The NULL in C treated as Zero or void. But in SQL NULL value is Non or blank
represented it can't manipulated
5. In Oracle varchar2 takes dynamic space for storage then why char is still in
oracle?
The major difference between varchar2 and char is fixed length and variable length.
Varchar2 have variable length mean if we declare as 20 space and its use only 5
space the memory assign only 5. But in char takes declare space while use any
number space less than declare
Constraints are used to maintain the integrity and atomicity of database .in other
words it can be said they are used to prevent invalid data entry. The main 5
constraints are
NOT NULL, PRIMARY KEY, FOREIGN KEY, UNIQUE KEY and CHECK
Triggers are basically stored procedures, which automatically fired when any insert,
update or delete is issued on table
Another most imp, Diff. is that trigger affected only those row after which trigger
applied but constraint affected all row of table.
1. The process of separating data into distinct, unique sets is called normalization.
This is implemented to improve the performance of the RDBMS, such as reduces
redundancy of data and data inconsistency.
There are different types are logs which are logged by Oracle Database Engine. A
DBA has to look in for alter log which exist background dump dust. The seviourity of
the problem are analysed and escalated based on the information provided by the
alter log.
1.Oracle database usually contains one database and a single instance. But, Oracle
9i, 10g RAC (Real Application Clusters) can have multiple instances to interact with
a single database for high availability.
Instance is non-persistent, memory based background processes and structures.
Database is persistent, disk based, data and control files
10.what is the difference between primary key, unique key, and surrogate key?
Primary Key: A column in a table whose values uniquely identify the rows in the
table. A primary key value cannot be NULL.
Unique Key: Unique Keys are used to uniquely identify each row in an Oracle table.
There can be one and only one row for each unique key value.
Surrogate Key: A system generated key with no business value. Usually implemented
with database-generated sequences.
1. what are the diffrent file types that are supported by SQL*Loader?
3.What spfile/init.ora file parameter exists to force the CBO to make the execution
path of a given statement use an index, even if the index scan may appear to be
calculated as more costly?
The shared pool portion of the SGA contains three major areas: library cache,
dictionary cache, buffers for parallel execution messages, and control
structures.
b. Their creation will not affect existing and new sessions. Only sessions
marked for Virtual Index usage will become aware of their existence.
d. The Rule based optimizer did not recognize Virtual Indexes when I
Tested, however, CBO recognizes them. In all of my examples, I have used
CBO. However, I did not carry out intensive testing in RBO and you may come
across exceptions to this view.
d. Dictionary view DBA_SEGMENTS will not show an entry for Virtual Indexes.
The table DBA_INDEXES and DBA_OBJECTS will have an entry for them in
Oracle 8i; in Oracle 9i onwards, DBA_INDEXES no longer show Virtual
Indexes.
Oracle handles such indexes internally and few required dictionary tables are
updated so that the optimizer can be made aware of its presence and
generate an execution plan considering such indexes.As per Oracle, this
functionality is not intended for standalone usage. It is part of the Oracle
Enterprise Manger Tuning Pack (Virtual Index Wizard).
The virtual index wizard functionality allows the user to test a potential new
index prior to actually building the new index in the database.It allows the
CBO to evaluate the potential new index for a selected SQL statement by
building an explain plan that is aware of the potential new index.
This allows the user to determine if the optimizer would use the index, once
implemented.
Materialized view is like a view but stores both definition of a view plus the
rows resulting from execution of the view. It uses a query as the bases and
the query is executated at the time the view is created and the results are
stored in a table. You can define the Materialized view with the same storage
parametes as any other table and place it in any tablespace of your choice.
You can also index and partition the Materialized view table like other tables
to improve performance of queries executed aginst them.
a. Bitmap indexes are most appropriate for columns having low distinct
values.
b. We can use bitmap index where cardinality is very low like gender column
or color column.
10.What is an extent?
a. An extent is the smallest unit of storage allocation comprising collection of
Blocks.
b. Well an extent is a chunk of a space that is used by database segments
when a segment is created it allocates extents.
11.How to you move from dedicated server Process to a Shared Server Process
b. 1. Control files
2. Init file
3. Log files 4. Redo/archive log files 5. data files
C. Physical components of oracle database are control files, redo log files and
datafiles.
Control file: control file is read in the mount state of database. Control file is a
small binary file, which records the physical structure of database, which
includes
Database name
Names and locations of datafiles and online redo log files. Timestamp of
database creation
Checkpoint information current logs sequence number.
Redo log files: This files saves all the changes that are made to the database
as they occur. This plays a great role in the database recovery.
Datafiles: datafiles are the physical files, which stores data of all logical
structure.
Datablocks: Oracle server manage the storage space in the datafiles in units
is called data blocks or oracle blocks.
table segment, index segment, IOT, cluster, temp segment, data segment.
DBMS_OUTPUT.PUT_LINE ('strings');
Print out the strings
DBMS_UTILITY.get_time ()
get the current time
DBMS_ALERT
e.g begin
dbms_alert.register('myregister');
end
To register interst in a named alert
16. How can you check which user has which Role.
desc dba_tab_privs (OR) Can use ROLE_TAB_PRIVS also (OR) select * from
dba_role_privs order by grantee;
A view does not contain any data of its own, but is like a window through
which data from other tables can be viewed and changed
The answer depends on the type of view. In case of normal view, the ans is
NO it only contains query based on a base table but in case of materialized
view, YES it does contain data and for the updated data in the base table, it
needs to be refreshed.
NO: Because view is for view one or more tables data like query.
Yes, it can. For example if you specify a different tablepace (B) for indexes,
the indexes of the tables that the user create would be residing in B, and the
table would reside in the user's default tablespace A.
Yes: Schema objects can stored in different tablespace and a tablespace can
contained one or more schema objects data.
21.What is an Oracle index?
An index is a schema object that can speed up the retrieval of rows by using
pointers. If you do not have an index, then a full table scan occurs. Its
purpose is to reduce disk I/O by using an indexed path to locate data quickly.
If a table is dropped, the corresponding indexes are also dropped.
The primary function of the redo log is to record all changes made to data.
Redo log contains the before and after image copies of changed data.
The On-line Redo Log is a set of tow or more on-line redo files that record all
committed changes made to the database. Whenever a transaction is committed,
the corresponding redo entries temporarily stores in redo log buffers of the SGA
are written to an on-line redo log file by the background process LGWR. The
on-line redo log files are used in cyclical fashion..
It is one of the main background process in oracle . In oracle and unix environment
you can check this process using ps -ef |pg command . which is writting all the
uncommited transaction from SGA to redologfile . (or)
Log Writer (LGWR) writes redo log entries generated in the redo log buffer of the
SGA to on-line Redo Log File.
DB_BLOCK_BUFFERS
SHARED_POOL_SIZE
SORT_AREA_SIZE
DBWR_IO_SLAVES
ROLLBACK_SEGMENTS
SORT_AREA_RETAINED_SIZE
DB_BLOCK_LRU_EXTENDED_STATISTICS
SHARED_POOL_RESERVE_SIZE
You can use its wizards to guide you through a selection of options providing an easy
means of creating and tailoring your database. It allows you to provide varying
levels of detail. You can provide a minimum of input and allow Oracle to make
decisions for you, eliminating the need to spend time deciding how best to set
parameters or structure the database. Optionally, it allows you to be very specific
about parameter settings and file allocations.
It builds efficient and effective databases that take advantage of Oracle's new
features.
10.How do you find whether the instance was started with pfile or spfile
1) SELECT name, value FROM v$parameter WHERE name = 'spfile'; //This query will
return NULL if you are using PFILE
2) SHOW PARAMETER spfile // This query will returns NULL in the value column if
you are using pfile and not spfile
3) SELECT COUNT(*) FROM v$spparameter WHERE value IS NOT NULL; // if the count
is non-zero then the instance is using a spfile, and if the count is zero then it is
using a pfile:
By Default oracle will look into the default location depends on the o/s. Like in
unix, oracle will check in $oracle_home/dbs directory and on windows it will check
in oracle_home/database directory, and the content of pfile is just text based, but
spfile content is in binary format, that is understandable by oracle very well.
Also oracle server always check the spfile or pfile with these sequence :-
Oracle creates the index segment for an index or an index partition when you issue
the CREATE INDEX statement. In this statement, you can specify storage parameters
for the extents of the index segment and a tablespace in which to create the index
segment. (The segments of a table and an index associated with it do not have to
occupy the same tablespace.) Setting the storage parameters directly affects the
efficiency of data retrieval and storage
You can create a public database link for a database. All users and PL/SQL
subprograms in the database can use a public database link to access data and
database objects in the corresponding remote database.
When many users require an access path to a remote Oracle database, an
administrator can create a single public database link for all users in a database.
CREATE PUBLIC DATABASE LINK ...;
if any of the empty row is not sufficient to hold the row. then row is placed in
multiple blocks. it happenes when the block size is small and rows are of large size.
then it cause chaining. Due to chaining performance degrades and will cause more
IOs
Control file is binary file which is having all the information realted to database.
db_name, maxlogfiles, maxdatafiles, tablespaces information. Without this u cannot
open your database. Init.ora parameter file showing the location of the controlfile.
(or)
control file is a binary file which contains db_name,dbcreated,checkpoint
information,datafiles and logfiles.
15.What is a tablespace
Tablespace is nothing but a logical object comprisiing of one or more data files
which actually stores the data. (or) A tablespace is a collection of one or more
datafile.
Only SYS, SYSTEM and possibly DBSNMP should have their default tablespace set to
SYSTEM.
select USERNAME,
CREATED,
PROFILE,
DEFAULT_TABLESPACE,
TEMPORARY_TABLESPACE
from dba_users
order by USERNAME
Objects in SYSTEM TS
OBJECTS IN SYSTEM TABLESPACE NOTES:
Any user (other than SYS, SYSTEM) should have their objects moved out of the
SYSTEM tablespace
select OWNER,
SEGMENT_NAME,
SEGMENT_TYPE,
TABLESPACE_NAME,
BYTES
from dba_segments
where TABLESPACE_NAME = 'SYSTEM'
and OWNER not in ('SYS','SYSTEM')
order by OWNER, SEGMENT_NAME
Databases, tablespaces and datafiles are closely related, but they have important
differences:
(or)
When a database user is created, a corresponding schema with the same name is
created for that user. A schema is a named collection of objects that include
Tables, Triggers, constraints, Indexes, Views etc. A user can only be associated with
one schema, and that is the same name as the user's. Username and schema are
often used interchangeably.
Latch waiters may either use timers to wakeup and retry or spin (only in
multiprocessors). Since all waiters are concurrently retrying (depending on the
scheduler), anyone might get the latch and conceivably the first one to try might be
the last one to get.
21.What is a latch?
Latches are low level serialization mechanisms used to protect shared data
structures in the SGA. The implementation of latches is operating system
dependent, particularly in regard to whether a process will wait for a latch and for
how long.
A latch is a type of a lock that can be very quickly acquired and freed. Latches are
typically used to prevent more than one process from executing the same piece of
code at a given time. Associated with each latch is a cleanup procedure that will be
called if a process dies
while holding the latch. Latches have an associated level that is used to prevent
deadlocks. Once a process acquires a latch at a certain level it cannot subsequently
acquire a latch at a level that is equal to or less than that level (unless it acquires it
nowait).
What is difference between Logical Standby Database and Physical Standby
database?
The primary functional difference between logical and physical standby database
setups is that logical standby permits you to add additional objects (tables, indexes,
etc) to the database, while physical standby is always an exact structural duplicate
of the master database. The downside, though, is that logical standby is based on
newer technologies (logical standby is new in Oracle 9.2) and tends to be generally
regarded as more tempramental than physical standby.
1.COMMIT or ROLLABCK
2.time out occurs (3 secs)
3 1/3 of log is full
4.1 mb of redo
5. Checkpoint occurs
-- Edit the trace file and change the CREATE CONTROLFILE command
-- CREATE CONTROLFILE REUSE SET DATABASE "NEW_SID_NAME" RESETLOGS
-- (note the SET keyword)
-- Rename GLOBAL_NAME to
ALTER DATABASE RENAME GLOBAL_NAME TO ;
(or)
The Oracle RDBMS creates and uses storage on the computer hard disk and in
random access memory (RAM). The portion in the computer’s RAM is called memory
structure. Oracle has two memory structures in the computer’s RAM. The two
structures are the Program Global Area (PGA) and the System Global Area (SGA).
The PGA contains data and control information for a single, user process. The SGA is
the memory segment that stores data that the user has retrieved from the database
or data that the user wants to place into the database
During database mount process, Oracle would check for the existence of controlfiles
mentioned in init.ora file but it wont check the contents of the controlfile which is
done during the opening of database.
30.What is the view name where i can get the space in MB for tables or views?
You can do it at the OS level by deleting all the files of the database. The files to be
deleted can be found using:
Clean up the listener.ora and the tnsnames.ora. make sure that the oratab entry is
also removed. (or)
Go To Dbca And Click On Delete 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
Two processes wating to update the rows of a table which are locked by the other
process then deadlock arises.
In a database environment this will often happen because of not issuing 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.
(OR)
A deadlock is a condition where two or more users are waiting for data locked by
each other. Oracle automatically detects a deadlock and resolves them by rolling
back one of the statements involved in the deadlock, thus releasing one set of data
locked by that statement. Statement rolled back is usually the one which detects
the deadlock. Deadlocks are mostly caused by explicit locking because oracle does
not do lock escalation and does not use read locks. Multitable deadlocks can be
avoided by locking the tables in same order in all the applications, thus precluding a
deadlock. (OR)
System waiting for an event that may or may not happens and can be rectified using
round robin algorithm which implemented internally by operating systems