1.
What is an Oracle instance?
Overview of an Oracle Instance
Overview of an Oracle Instance
Every running Oracle database is associated with an Oracle
instance. When a
database is started on a database server (regardless of the type of computer),
Oracle allocates a memory area called the System Global Area (SGA) and starts
one or more Oracle processes. This combination of the SGA and the Oracle
processes is called an Oracle instance. The memory and processes of an instance
manage the associated database’s data efficiently and serve the one or multiple
users of the database.
database is started on a database server (regardless of the type of computer),
Oracle allocates a memory area called the System Global Area (SGA) and starts
one or more Oracle processes. This combination of the SGA and the Oracle
processes is called an Oracle instance. The memory and processes of an instance
manage the associated database’s data efficiently and serve the one or multiple
users of the database.
The Instance and the Database
After starting an instance, Oracle associates the instance with
the specified
database. This is called mounting the database. The database is then ready to be
opened, which makes it accessible to authorized users.
database. This is called mounting the database. The database is then ready to be
opened, which makes it accessible to authorized users.
Multiple instances can execute concurrently on the same computer,
each accessing
its own physical database. In clustered and massively parallel systems (MPP),
the Oracle Parallel Server allows multiple instances to mount a single database.
its own physical database. In clustered and massively parallel systems (MPP),
the Oracle Parallel Server allows multiple instances to mount a single database.
Only the database administrator can start up an instance and open
the database.
If a database is open, the database administrator can shut down the database so
that it is closed. When a database is closed, users cannot access the
information that it contains.
If a database is open, the database administrator can shut down the database so
that it is closed. When a database is closed, users cannot access the
information that it contains.
Security for database startup and shutdown is controlled via
connections to
Oracle with administrator privileges. Normal users do not have control over the
current status of an Oracle database.
Oracle with administrator privileges. Normal users do not have control over the
current status of an Oracle database.
Q: What is a view?
View
View
A view is a tailored presentation of the data contained in one or
more tables
(or other views). Unlike a table, a view is not allocated any storage space, nor
does a view actually contain data; rather, a view is defined by a query that
extracts or derives data from the tables the view references. These tables are
called base tables.
(or other views). Unlike a table, a view is not allocated any storage space, nor
does a view actually contain data; rather, a view is defined by a query that
extracts or derives data from the tables the view references. These tables are
called base tables.
Views present a different representation of the data that resides
within the
base tables. Views are very powerful because they allow you to tailor the
presentation of data to different types of users.
base tables. Views are very powerful because they allow you to tailor the
presentation of data to different types of users.
Views are often used to:
• provide an additional level of table security by restricting
access to a
predetermined set of rows and/or 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
• isolate applications from changes in definitions of base tables
• express a query that cannot be expressed without using a view
predetermined set of rows and/or 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
• isolate applications from changes in definitions of base tables
• express a query that cannot be expressed without using a view
What is referential integrity?
Rules governing the relationships between primary keys and foreign keys of
tables within a relational database that determine data consistency. Referential
integrity requires that the value of every foreign key in every table be matched
by the value of a primary key in another table.
Rules governing the relationships between primary keys and foreign keys of
tables within a relational database that determine data consistency. Referential
integrity requires that the value of every foreign key in every table be matched
by the value of a primary key in another table.
2.
Name the data dictionary
that stores user-defined constraints?
USER_CONSTRAINTS
USER_CONSTRAINTS
3.
What is a collection of
privileges?
user_tab_privs_made
user_tab_privs_recd
user_tab_privs_made
user_tab_privs_recd
4.
Snapshot: A snapshot is a read-only copy of a table or a subset of
a table.
5.
What is a collection of
privileges?
collection of privilages is role.
collection of privilages is role.
6.
What is a cursor?
Ans:
cursor is a private sql work area used to perform manipulations on data using pl\sql.
adv:
1.mainly used for multiple row manipulations and locking columns.
note: data which is populated into the cursor is known as active dataset.
Ans:
cursor is a private sql work area used to perform manipulations on data using pl\sql.
adv:
1.mainly used for multiple row manipulations and locking columns.
note: data which is populated into the cursor is known as active dataset.
cursors are of two types
1.implicit
2.explicit
1.implicit
2.explicit
implicit
———
attributes or properties for implicit cursor
1.sql%is open:attribute returns a boolean value stating wether the cursor is open or closed.
2.sql % found: returns boolean value stating whether the record is found in the cursor.
3.sql%notfound : returns a boolean value stating whether the record is not found in the cursor
4.sql %rowcount :returns a pneumeric value stating no.of rows executed in the cursor.
explicit cursors—retrives multiple rows.
************
adv: users can perform locks on th data in the cursor
attributes
1.% is open
2.% found
3.% not found
4.% rowcount
************
adv: users can perform locks on th data in the cursor
attributes
1.% is open
2.% found
3.% not found
4.% rowcount
Note: DATA which is populated in the cursor is known as active
data set.
WE CAN WRITE TWO CURSORS IN ONE PROGRAM
WE CAN WRITE A CURSOR SPECIFYING PARAMETERS
CURSOR WITH UPDATE CLAUSE IS USED TO PERFORM LOCKS ON DATA.
7.
What is a sequence?
Ans:It is a database object to auto generate numbers.
Ans:It is a database object to auto generate numbers.
8.
Name the data dictionary
that stores user-defined Stored procedures?
ans :- user_objects
ans :- user_objects
9.
Question:Why Use Sql*
Loader in Oracle Database?
Answer: The Sql Loader module of the oracle database Management System loads data into an existing ORACLE table from an external files.It is available locally only on CMS and PCs with oracle version 5. Throughout this documentation the CAR database described in Referance A is used for illustration.
There are several methods others than using SQL *Loader of inserting data into a table.
1. The Sql insert command may be used from the SQL * Plus module,
for Example :
insert into CAR values(…)
where the values to be inserted into a row of the table are listed inside the parentheses. Dates and Characters data must be Surrounded by single quotes; items are seperated by commas.
2. Sql*Forms allows you to add rows interactively using forms. The forms may contain default values and checks for invalid data.
3. ODL loads the table from a control file and separate fixed format data file. ODL is available on all versions of ORACLE . SQL * Loader is much more flexible than ODL and will eventually supersede it on all systems.
Answer: The Sql Loader module of the oracle database Management System loads data into an existing ORACLE table from an external files.It is available locally only on CMS and PCs with oracle version 5. Throughout this documentation the CAR database described in Referance A is used for illustration.
There are several methods others than using SQL *Loader of inserting data into a table.
1. The Sql insert command may be used from the SQL * Plus module,
for Example :
insert into CAR values(…)
where the values to be inserted into a row of the table are listed inside the parentheses. Dates and Characters data must be Surrounded by single quotes; items are seperated by commas.
2. Sql*Forms allows you to add rows interactively using forms. The forms may contain default values and checks for invalid data.
3. ODL loads the table from a control file and separate fixed format data file. ODL is available on all versions of ORACLE . SQL * Loader is much more flexible than ODL and will eventually supersede it on all systems.
10. We can execute a function in sql query
select functionname(paramaters) from dual;
Suppose i am created a function add which returns the addition of
two numbers then
select add(3,4) from dual;
7
7
ODBC stands for open database connectivity
trigger is a stored procedure which auotomatically fired on a
table whenever any dml operation is affected in the table.
we can create ddl trigger,database trigger(logon,logoff,startup,startoff),audit triggers
we can create ddl trigger,database trigger(logon,logoff,startup,startoff),audit triggers
pseudo column the column which does not exist in a table
ex;rownum,rowid,level etc
ex;rownum,rowid,level etc
11.
Answer to some of the questions
above:
ODBC stands for Open Database Connectivity. It is used to connect the frontend with the backend(database)
ODBC stands for Open Database Connectivity. It is used to connect the frontend with the backend(database)
Normalization is the techinque of designing the database with the
least redundancy and duplicacy of data. Types of Normalization:
1 NF
2 NF
3 NF
BCNF
5 NF
6NF : Impossible to achieve this level of normalization
1 NF
2 NF
3 NF
BCNF
5 NF
6NF : Impossible to achieve this level of normalization
12. what is a synonym ?
Ans. A synonym is an alternative name for tables,views,procedures
and other database objects
generally when we have more than one schema and we wish to access an object of a different schema then we create synonyms for that object in the schema where we wish to access the object.
generally when we have more than one schema and we wish to access an object of a different schema then we create synonyms for that object in the schema where we wish to access the object.
Syntax:
create synonym synonym-name for schemaname.object-name
create synonym synonym-name for schemaname.object-name
what is an exception ?
Exception is an event that causes suspension of normal program
execution.
In oracle there are serveral types of exceptions
1) Pre-defined exceptions like NO_DATA_FOUND,TOO_MANY_ROWS
2) User-defined exceptions which would validate the business logic
3) unnamed system exceptions which are raised due to errors in the application code .. you can name these exceptions using PRAGMA EXCEPTION_INIT
4)Unnamed programmer-defined exceptions. Exceptions that are defined and raised in the server by the programmer. In this case, the programmer provides both an error number (between -20000 and -20999) and an error message, and raises that exception with a call to RAISE_APPLICATION_ERROR.
In oracle there are serveral types of exceptions
1) Pre-defined exceptions like NO_DATA_FOUND,TOO_MANY_ROWS
2) User-defined exceptions which would validate the business logic
3) unnamed system exceptions which are raised due to errors in the application code .. you can name these exceptions using PRAGMA EXCEPTION_INIT
4)Unnamed programmer-defined exceptions. Exceptions that are defined and raised in the server by the programmer. In this case, the programmer provides both an error number (between -20000 and -20999) and an error message, and raises that exception with a call to RAISE_APPLICATION_ERROR.
for all the exceptions raised oracle fills in sqleerm and sqlcode
variable which provide the error message and error code for the exception
raised.
What are pseudo-columns in SQL? Provide examples?
A pseudocolumn behaves like a table column, but is not actually
stored in the table. You can select from pseudocolumns, but you cannot insert,
update, or delete their values.
Examples:
CURRVAL,NEXTVAL,ROWID,LEVEL
CURRVAL,NEXTVAL,ROWID,LEVEL
what is a schema ?
A schema is a oracle database user account.
A schema is a oracle database user account.
13. What is a schema ?
A database user account is called a schema.
14.
What is a schema ?
A schema is a logical collection of database objects like tables, views, pkgs, procedures, triggers, etc. It usually has an associated database user.
A schema is a logical collection of database objects like tables, views, pkgs, procedures, triggers, etc. It usually has an associated database user.
15.
What is a co-related sub-query?
It is very similar to sub-queries where the parent query is
executed based on the values returned by sub-quries. but when come’s to
co-related subqueries for every instance of parent query subquery is executed
and based on the result od sub-query the parent query will display the record
as we will have refernce of parent quries in su-queries we call these as
corelated subquries.
so, we can define co-related sub query as for every record
retrival from the sub query is processed and based on result of process the
parent record is displayed.
16.
wht is the major difference b/w oracle 8i & 9i
17.
what is trigger?
Trigger is an event. It is used prevent the invalid entries of the data.There
has a different types of trigger are available.
1)rowlevel trigger
before insert,before delete,before update
after insert,after delete,after update
2)statement level trigger
before insert,before delete,before update
after insert,after delete,after update
3)INSTEAD OF trigger
4)Schema level Triggers
5)System level Triggers
Trigger is an event. It is used prevent the invalid entries of the data.There
has a different types of trigger are available.
1)rowlevel trigger
before insert,before delete,before update
after insert,after delete,after update
2)statement level trigger
before insert,before delete,before update
after insert,after delete,after update
3)INSTEAD OF trigger
4)Schema level Triggers
5)System level Triggers
18.
Q. Is there any solution
to delete a particular colum in a database by sql?
A. This is cant be done in versions before 9i.
In 9i
SQL> alter table delete column ;
A. This is cant be done in versions before 9i.
In 9i
SQL> alter table delete column ;
19.
pseudo columns in sql are currval and nextval.These are used with
sequences to retreive the next sequence value and current sequence value.
The usage is as follows
suppose abc is the sequence name if i want to see the currval of the sequence we issue the sql statement
select abc.currval from dual;
if we want to see the next value of the sequence we issue the command
select abc.nextval from dual;
The usage is as follows
suppose abc is the sequence name if i want to see the currval of the sequence we issue the sql statement
select abc.currval from dual;
if we want to see the next value of the sequence we issue the command
select abc.nextval from dual;
20.
What is an oracle
instance?
An Oracle instance consists of the System Global Area (SGA) memory structure and the background processes used to manage a database. An instance is identified by using methods specific to each operating system. The instance can open and use only one database at a time.
An Oracle instance consists of the System Global Area (SGA) memory structure and the background processes used to manage a database. An instance is identified by using methods specific to each operating system. The instance can open and use only one database at a time.
21.
Q. Is there any solution
to delete a particular colum in a database by sql?
A. alter table drop column
or
first mark the column unused
alter table set unused column
then drop it
alter table drop unused columns.
This will drop all the columns marked as unused. If a particular column has to be dropped, mention the column name after columns
A. alter table drop column
or
first mark the column unused
alter table set unused column
then drop it
alter table drop unused columns.
This will drop all the columns marked as unused. If a particular column has to be dropped, mention the column name after columns
22. What is a schema?” is wrong.
A schema is a collection of logical objects owned by a user. A
user in that regard is an account registered with the Oracle server.
Once u login into ur account/user, u can access other user’s
schema objects like i can write scott.emp, if at all i’ve acces to scott user’s
emp table.
23.
Data Model: The logical data structure developed during the
logical database design process is a data model or entity model. It is also a
description of the structural properties that define all entries represented in
a database and all the relationships that exist among them.
%ROWTYPE is used to declare a record with the same types as found
in the specified database table, view or cursor
%TYPE is used to declare a field with the same type as that of a specified table’s column.
%TYPE is used to declare a field with the same type as that of a specified table’s column.
Index for a physical structure (b-tree) to help you query run
faster.
Table partition is a method of breaking a large table into smaller tables grouped by some logical separators. in your case, having both index and partition will make things faster.
Table partition is a method of breaking a large table into smaller tables grouped by some logical separators. in your case, having both index and partition will make things faster.
Data Control statements
These are used to control the data using DCL (data control language) ex: Grant etc.
These are used to control the data using DCL (data control language) ex: Grant etc.
Trigger : A program in a database that gets called each time a row
in a table is INSERTED, UPDATED, or DELETED. Triggers allow you to check that
any changes are correct, or to fill in missing information before it is
commited. Triggers are normally written in PL/SQL or Java.
Relation: Mathematical term for a table.
Redo Log: A set of files that record all changes made to an Oracle
database. A database MUST have at least two redo log files. Log files can be
multiplexed on multiple disks to ensure that they will not get lost. Also see
thread.
Oracle ARCHiver Process. ARCH is an Oracle background process
created when you start an instance in ARCHIVE LOG MODE. The ARCH process will
archive on-line redo log files to some backup media.
Buffer Cache: The portion of the SGA that holds copies of Oracle
data blocks. All user processes that connect to an instance share access to the
buffer cache. Performance of the buffer cache is indicated by the BCHR (Buffer
Cache Hit Ratio).
Background Process: Non-user process that is created when a
database instance is started. These processes are used to manage and monitor
database operations. Example background processes: SMON, PMON etc.
Two-Phase Commit: A strategy in which changes to a database are
temporarily applied. Once it has been determined that all parts of a change can
be made successfully, the changes are permanently posted to the database. The
steps involved are the “prepared” and “commit request”
Union: All the distinct rows are selected by either query.
Intersect: All distinct rows selected by both queries
Minus: All distinct rows that are selected by the first SELECT statement and that are not selected in the second SELECT statement.
Join: The process of combining data from two or more tables using matching columns. Types of join are Equi Join, Outer Join, Self Join, Natural Join, etc.
Equi Join: An Equi Join (aka. Inner Join or Simple Join) is a join statement that uses an equivalency operation (i.e: colA = colB) to match rows from different tables. The converse of an equi join is a nonequijoin operation.
Outer Join: Similar to the Equi Join, but Oracle will also return non matched rows from the tale with the outer join operator (+). Missing values are filled with null values.
Self Join: A join in which a table is joined with itself.
Natural Join: A join statement that compares the common columns of both tables with each other. One should check whether common columns exist in both tables before doing a natural join.
Intersect: All distinct rows selected by both queries
Minus: All distinct rows that are selected by the first SELECT statement and that are not selected in the second SELECT statement.
Join: The process of combining data from two or more tables using matching columns. Types of join are Equi Join, Outer Join, Self Join, Natural Join, etc.
Equi Join: An Equi Join (aka. Inner Join or Simple Join) is a join statement that uses an equivalency operation (i.e: colA = colB) to match rows from different tables. The converse of an equi join is a nonequijoin operation.
Outer Join: Similar to the Equi Join, but Oracle will also return non matched rows from the tale with the outer join operator (+). Missing values are filled with null values.
Self Join: A join in which a table is joined with itself.
Natural Join: A join statement that compares the common columns of both tables with each other. One should check whether common columns exist in both tables before doing a natural join.
Integer Data Types: VARCHAR2 (Size), NUMBER (Precision, Size)
Denormalization: The opposite of data normalization (almost). In a
denormalized database, some duplicated data storage is allowed. The benefits
are quicker data retrieval and/or a database structure that is easier for
end-users.
No comments:
Post a Comment