Anda di halaman 1dari 72

Diffrence between Co-related sub query and nested sub query

Correlated subquery runs once for each row selected by the outer query. It contains a reference
to a value from the row selected by the outer query.

For example,

select e1.empname, e1.basicsal, e1.deptno from emp e1 where e1.basicsal = (select


max(basicsal) from emp e2 where e2.deptno = e1.deptno)

Nested subquery runs only once for the entire nesting (outer) query. It does not contain any
reference to the outer query row.

For example,

select empname, basicsal, deptno from emp where (deptno, basicsal) in (select deptno,
max(basicsal) from emp group by deptno)
No comments: Links to this post
Labels: .NET 3.0 Tutorial, Database

What is Cluster index and non cluster index?

Clustered Index:- A Clustered index is a special type of index that reorders the way records in
the table are physically stored. Therefore table may have only one clustered index.

Non-Clustered Index:- A Non-Clustered index is a special type of index in which the logical
order of the index does not match the physical stored order of the rows in the disk. The leaf
nodes of a non-clustered index does not consists of the data pages. instead the leaf node contains
index rows.
No comments: Links to this post
Labels: Database

The main difference of DBMS & RDBMS is

RDBMS have Normalization. Normalization means to refining the redundant and maintain the
stablization.
the DBMS hasn't normalization concept.

No comments: Links to this post


Labels: Database

What is the advantage to use trigger?

There are various advantages of using a trigger. Some of them are:


Suppose we need to validate a DML statement(insert/Update/Delete) that modifies a table
then we can write a trigger on the table that gets fired implicitly whenever DML
statement is executed on that table.

Another reason of using triggers can be for automatic updation of one or more tables
whenever a DML/DDL statement is executed for the table on which the trigger is created.

Triggers can be used to enforce constraints. For eg : Any insert/update/ Delete statements
should not be allowed on a particular table after office hours. For enforcing this constraint
Triggers should be used.

Triggers can be used to publish information about database events to subscribers.


Database event can be a system event like Database startup or shutdown or it can be a
user even like User loggin in or user logoff.

No comments: Links to this post


Labels: Database

why you need indexing ?

We cant create an Index on Index.. Index is stored in user_index table.Every object that has been
created on Schema is Schema Object like Table,View etc.If we want to share the particular data
to various users we have to use the virtual table for the Base table...So that is a view.

indexing is used for faster search or to retrieve data faster from various table. Schema containing
set of tables, basically schema means logical separation of the database. View is crated for faster
retrieval of data. It's customized virtual table. we can create a single view of multiple tables.
Only the drawback is..view needs to be get refreshed for retrieving updated data.

No comments: Links to this post


Labels: Database

What are difference between Store Procedure and Trigger?

we can call stored procedure explicitly.

but trigger is automatically invoked when the action defined in trigger is done.
ex: create trigger after Insert on

this trigger invoked after we insert something on that table.

Stored procedure can't be inactive but trigger can be Inactive.

Triggers are used to initiate a particular activity after fulfilling certain condition.It need to
define and can be enable and disable according to need.
No comments: Links to this post
Labels: Database

Guidelines to install Oracle 10g database on Microsoft Windows environment

This document provides guidelines to install Oracle 10g database on Microsoft Windows
environment. If you use other operating system other than Microsoft Windows, the process is not
too much different from that of Microsoft Windows, since Oracle uses Oracle Universal Installer
to install its software.

For more information about installing Oracle 10g under operating systems other than Microsoft
Windows, please refer to this URL :

http://www.oracle.com/pls/db102/homepage

How to get Oracle 10g :

You can download Oracle 10g database from www.oracle.com. You must registered and create
an account before you can download the software. The example in this document uses Oracle
Database 10g Release 2 (10.2.0.1.0) for Microsoft Windows.

How to uninstall Oracle database software :

Uninstall all Oracle components using the Oracle Universal Installer (OUI).
Run regedit.exe and delete the HKEY_LOCAL_MACHINE/ SOFTWARE/ORACLE key. This
contains registry entire for all Oracle products.
Delete any references to Oracle services left behind in the following part of the registry: HKEY
LOCAL MACHINE/ SYSTEM/ CurrentControlsSet/ Services/Ora*. It should be pretty obvious
which ones relate to Oracle
Reboot your machine.
Delete the C: \Oracle directory, or whatever directory is your Oracle_Base.
Delete the C:\Program Files \Oracle directory.
Empty the contents of your c:\temp directory.
Empty your recycle bin.
No comments: Links to this post
Labels: Database

Oracle Interview Questions And Answers [7]

What is the purpose of the product order option in the column property sheet?
To specify the order of individual group evaluation in a cross products.

What is the use of image_zoom built-in?


To manipulate images in image items.
How do you reference a parameter indirectly?
To indirectly reference a parameter use the NAME IN, COPY 'built-ins to indirectly set and
reference the parameters value' Example name_in ('capital parameter my param'), Copy
('SURESH','Parameter my_param')

What is a timer?
Timer is an "internal time clock" that you can programmatically create to perform an action each
time the times.

What are the two phases of block coordination?


There are two phases of block coordination: the clear phase and the population phase. During,
the clear phase, Oracle Forms navigates internally to the detail block and flushes the obsolete
detail records. During the population phase, Oracle Forms issues a SELECT statement to
repopulate the detail block with detail records associated with the new master record. These
operations are accomplished through the execution of triggers.

What are Most Common types of Complex master-detail relationships?


There are three most common types of complex master-detail relationships:
master with dependent details
master with independent details
detail with two masters

What is a text list?


The text list style list item appears as a rectangular box which displays the fixed number of
values. When the text list contains values that can not be displayed, a vertical scroll bar appears,
allowing the operator to view and select undisplayed values.

What is term?
The term is terminal definition file that describes the terminal form which you are using r20run.

What is use of term?


The term file which key is correspond to which oracle report functions.

What is pop list?


The pop list style list item appears initially as a single field (similar to a text item field). When
the operator selects the list icon, a list of available choices appears.
What is the maximum no of chars the parameter can store?
The maximum no of chars the parameter can store is only valid for char parameters, which can
be upto 64K. No parameters default to 23Bytes and Date parameter default to 7Bytes.

What are the default extensions of the files created by library module?
The default file extensions indicate the library module type and storage format .pll - pl/sql library
module binary

What are the Coordination Properties in a Master-Detail relationship?


The coordination properties are
Deferred
Auto-Query
These Properties determine when the population phase of block
coordination should occur.

How do you display console on a window ?


The console includes the status line and message line, and is displayed at the bottom of the
window to which it is assigned.To specify that the console should be displayed, set the console
window form property to the name of any window in the form. To include the console, set
console window to Null.

What are the different Parameter types?


Text ParametersData Parameters

State any three mouse events system variables?


System.mouse_button_pressedSystem.mouse_button_shift

What are the types of calculated columns available?


Summary, Formula, Placeholder column.

Explain about stacked canvas views?


Stacked canvas view is displayed in a window on top of, or "stacked" on the content canvas view
assigned to that same window. Stacked canvas views obscure some part of the underlying
content canvas view, and or often shown and hidden programmatically.

How does one do off-line database backups? (for DBA )


Shut down the database from sqlplus or server manager. Backup all files to secondary storage
(eg. tapes). Ensure that you backup all data files, all control files and all log files. When
completed, restart your database.
Do the following queries to get a list of all files that needs to be backed up:
select name from sys.v_$datafile;
select member from sys.v_$logfile;
select name from sys.v_$controlfile;
Sometimes Oracle takes forever to shutdown with the "immediate" option. As workaround to this
problem, shutdown using these commands:
alter system checkpoint;
shutdown abort
startup restrict
shutdown immediate
Note that if you database is in ARCHIVELOG mode, one can still use archived log files to roll
forward from an off-line backup. If you cannot take your database down for a cold (off-line)
backup at a convenient time, switch your database into ARCHIVELOG mode and perform hot
(on-line) backups.

What is the difference between SHOW_EDITOR and EDIT_TEXTITEM?


Show editor is the generic built-in which accepts any editor name and takes some input string
and returns modified output string. Whereas the edit_textitem built-in needs the input focus to be
in the text item before the built-in is executed.

What are the built-ins that are used to Attach an LOV programmatically to an item?
set_item_property
get_item_property
(by setting the LOV_NAME property)

How does one do on-line database backups? (for DBA )


Each tablespace that needs to be backed-up must be switched into backup mode before copying
the files out to secondary storage (tapes). Look at this simple example.
ALTER TABLESPACE xyz BEGIN BACKUP;
! cp xyfFile1 /backupDir/
ALTER TABLESPACE xyz END BACKUP;
It is better to backup tablespace for tablespace than to put all tablespaces in backup mode.
Backing them up separately incurs less overhead. When done, remember to backup your control
files. Look at this example:
ALTER SYSTEM SWITCH LOGFILE; -- Force log switch to update control file headers
ALTER DATABASE BACKUP CONTROLFILE TO '/backupDir/control.dbf';
NOTE: Do not run on-line backups during peak processing periods. Oracle will write complete
database blocks instead of the normal deltas to redo log files while in backup mode. This will
lead to excessive database archiving and even database freezes.
How does one backup a database using RMAN? (for DBA )
The biggest advantage of RMAN is that it only backup used space in the database. Rman doesn't
put tablespaces in backup mode, saving on redo generation overhead. RMAN will re-read
database blocks until it gets a consistent image of it. Look at this simple backup example.
rman target sys/*** nocatalog
run {
allocate channel t1 type disk;
backup
format '/app/oracle/db_backup/%d_t%t_s%s_p%p'
( database );
release channel t1;
}
Example RMAN restore:
rman target sys/*** nocatalog
run {
allocate channel t1 type disk;
# set until time 'Aug 07 2000 :51';
restore tablespace users;
recover tablespace users;
release channel t1;
}
The examples above are extremely simplistic and only useful for illustrating basic concepts. By
default Oracle uses the database controlfiles to store information about backups. Normally one
would rather setup a RMAN catalog database to store RMAN metadata in. Read the Oracle
Backup and Recovery Guide before implementing any RMAN backups.
Note: RMAN cannot write image copies directly to tape. One needs to use a third-party media
manager that integrates with RMAN to backup directly to tape. Alternatively one can backup to
disk and then manually copy the backups to tape.

What are the different file extensions that are created by oracle reports?
Rep file and Rdf file.

What is strip sources generate options?


Removes the source code from the library file and generates a library files that contains only
pcode. The resulting file can be used for final deployment, but can not be subsequently edited in
the designer.ex. f45gen module=old_lib.pll userid=scott/tiger strip_source YES output_file

How does one put a database into ARCHIVELOG mode? (for DBA )
The main reason for running in archivelog mode is that one can provide 24-hour availability and
guarantee complete data recoverability. It is also necessary to enable ARCHIVELOG mode
before one can start to use on-line database backups. To enable ARCHIVELOG mode, simply
change your database startup command script, and bounce the database:
SQLPLUS> connect sys as sysdba
SQLPLUS> startup mount exclusive;
SQLPLUS> alter database archivelog;
SQLPLUS> archive log start;
SQLPLUS> alter database open;
NOTE1: Remember to take a baseline database backup right after enabling archivelog mode.
Without it one would not be able to recover. Also, implement an archivelog backup to prevent
the archive log directory from filling-up.
NOTE2: ARCHIVELOG mode was introduced with Oracle V6, and is essential for database
point-in-time recovery. Archiving can be used in combination with on-line and off-line database
backups.
NOTE3: You may want to set the following INIT.ORA parameters when enabling
ARCHIVELOG mode: log_archive_start=TRUE, log_archive_dest=... and
log_archive_format=...
NOTE4: You can change the archive log destination of a database on-line with the ARCHIVE
LOG START TO 'directory'; statement. This statement is often used to switch archiving between
a set of directories.
NOTE5: When running Oracle Real Application Server (RAC), you need to shut down all nodes
before changing the database to ARCHIVELOG mode.

What is the basic data structure that is required for creating an LOV?
Record Group.

How does one backup archived log files? (for DBA )


One can backup archived log files using RMAN or any operating system backup utility.
Remember to delete files after backing them up to prevent the archive log directory from filling
up. If the archive log directory becomes full, your database will hang! Look at this simple
RMAN backup script:
RMAN> run {
2> allocate channel dev1 type disk;
3> backup
4> format '/app/oracle/arch_backup/log_t%t_s%s_p%p'
5> (archivelog all delete input);
6> release channel dev1;
7> }

Does Oracle write to data files in begin/hot backup mode? (for DBA )
Oracle will stop updating file headers, but will continue to write data to the database files even if
a tablespace is in backup mode.
In backup mode, Oracle will write out complete changed blocks to the redo log files. Normally
only deltas (changes) are logged to the redo logs. This is done to enable reconstruction of a block
if only half of it was backed up (split blocks). Because of this, one should notice increased log
activity and archiving during on-line backups.
No comments: Links to this post
Labels: Database, Oracle

Oracle Interview Questions And Answers [6]

What is mean by Program Global Area (PGA)?


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

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.

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.

What are clusters?


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

What is cluster key?


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

Do a view contain data?


Views do not contain or store data.

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.

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.

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


DBA_FREE_SPACE
DBA_SEGMENTS
DBA_DATA_FILES.

Can a property clause itself be based on a property clause?


Yes

If a parameter is used in a query without being previously defined, what diff. exist between.
report 2.0 and 2.5 when the query is applied?
While both reports 2.0 and 2.5 create the parameter, report 2.5 gives a message that a bind
parameter has been created.

What are the sql clauses supported in the link property sheet?
Where start with having.

What is trigger associated with the timer?


When-timer-expired.

What are the trigger associated with image items?


When-image-activated fires when the operators double clicks on an image itemwhen-image-
pressed fires when an operator clicks or double clicks on an image item

What are the different windows events activated at runtimes?


When_window_activated
When_window_closed
When_window_deactivated
When_window_resized
Within this triggers, you can examine the built in system variable system. event_window to
determine the name of the window for which the trigger fired.

When do you use data parameter type?


When the value of a data parameter being passed to a called product is always the name of the
record group defined in the current form. Data parameters are used to pass data to products
invoked with the run_product built-in subprogram.

What is difference between open_form and call_form?


when one form invokes another form by executing open_form the first form remains displayed,
and operators can navigate between the forms as desired. when one form invokes another form
by executing call_form, the called form is modal with respect to the calling form. That is, any
windows that belong to the calling form are disabled, and operators cannot navigate to them until
they first exit the called form.

What is new_form built-in?


When one form invokes another form by executing new_form oracle form exits the first form
and releases its memory before loading the new form calling new form completely replace the
first with the second. If there are changes pending in the first form, the operator will be prompted
to save them before the new form is loaded.

What is the "LOV of Validation" Property of an item? What is the use of it?
When LOV for Validation is set to True, Oracle Forms compares the current value of the text
item to the values in the first column displayed in the LOV. Whenever the validation event
occurs. If the value in the text item matches one of the values in the first column of the LOV,
validation succeeds, the LOV is not displayed, and processing continues normally. If the value in
the text item does not match one of the values in the first column of the LOV, Oracle Forms
displays the LOV and uses the text item value as the search criteria to automatically reduce the
list.

What is the diff. when Flex mode is mode on and when it is off?
When flex mode is on, reports automatically resizes the parent when the child is resized.

What is the diff. when confine mode is on and when it is off?


When confine mode is on, an object cannot be moved outside its parent in the layout.

What are visual attributes?


Visual attributes are the font, color, pattern proprieties that you set for form and menu objects
that appear in your application interface.

Which of the two views should objects according to possession?


view by structure.

What are the two types of views available in the object navigator(specific to report 2.5)?
View by structure and view by type .

What are the vbx controls?


Vbx control provide a simple method of building and enhancing user interfaces. The controls can
use to obtain user inputs and display program outputs.vbx control where originally develop as
extensions for the ms visual basic environments and include such items as sliders, rides and
knobs.
What is the use of transactional triggers?
Using transactional triggers we can control or modify the default functionality of the oracle
forms.

How do you create a new session while open a new form?


Using open_form built-in setting the session option Ex. Open_form('Stocks ',active, session).
when invoke the multiple forms with open form and call_form in the same application, state
whether the following are true/False

What are the ways to monitor the performance of the report?


Use reports profile executable statement. Use SQL trace facility.

If two groups are not linked in the data model editor, What is the hierarchy between them?
Two group that is above are the left most rank higher than the group that is to right or below it.
No comments: Links to this post
Labels: Database, Oracle

Oracle Interview Questions And Answers [5]

Where are my TEMPFILES, I don't see them in V$DATAFILE or DBA_DATA_FILE? (for


DBA)
Tempfiles, unlike normal datafiles, are not listed in v$datafile or dba_data_files. Instead query
v$tempfile or dba_temp_files:
SELECT * FROM v$tempfile;
SELECT * FROM dba_temp_files;

How do I find used/free space in a TEMPORARY tablespace? (for DBA )


Unlike normal tablespaces, true temporary tablespace information is not listed in
DBA_FREE_SPACE. Instead use the V$TEMP_SPACE_HEADER view:
SELECT tablespace_name, SUM (bytes used), SUM (bytes free)
FROM V$temp_space_header
GROUP BY tablespace_name;

What is a profile ?
Each database user is assigned a Profile that specifies limitations on various system resources
available to the user.

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.

How can one see who is using a temporary segment? (for DBA )
For every user using temporary space, there is an entry in SYS.V$_LOCK with type 'TS'.
All temporary segments are named 'ffff.bbbb' where 'ffff' is the file it is in and 'bbbb' is first block
of the segment. If your temporary tablespace is set to TEMPORARY, all sorts are done in one
large temporary segment. For usage stats, see SYS.V_$SORT_SEGMENT
From Oracle 8.0, one can just query SYS.v$sort_usage. Look at these examples:
select s.username, u."USER", u.tablespace, u.contents, u.extents, u.blocks
from sys.v_$session s, sys.v_$sort_usage u
where s.addr = u.session_addr
/
select s.osuser, s.process, s.username, s.serial#,
Sum (u.blocks)*vp.value/1024 sort_size
from sys.v_$session s, sys.v_$sort_usage u, sys.v_$parameter VP
where s.saddr = u.session_addr
and vp.name = 'db_block_size'
and s.osuser like '&1'
group by s.osuser, s.process, s.username, s.serial#, vp.value
/

How does one get the view definition of fixed views/tables?


Query v$fixed_view_definition. Example: SELECT * FROM v$fixed_view_definition WHERE
view_name='V$SESSION';

What are the dictionary tables used to monitor a database spaces ?


DBA_FREE_SPACE
DBA_SEGMENTS
DBA_DATA_FILES.

How can we specify the Archived log file name format and destination?
By setting the following values in init.ora file. LOG_ARCHIVE_FORMAT = arch %S/s/T/tarc
(%S - Log sequence number and is zero left paded, %s - Log sequence number not padded. %T -
Thread number lef-zero-paded and %t - Thread number not padded). The file name created is
arch 0001 are if %S is used. LOG_ARCHIVE_DEST = path.

What is user Account in Oracle database?


An 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.
When will the data in the snapshot log be used?
We must be able to create a after row trigger on table (i.e., it should be not be already available)
After giving table privileges. We cannot specify snapshot log name because oracle uses the name
of the master table in the name of the database objects that support its snapshot log. The master
table name should be less than or equal to 23 characters. (The table name created will be
MLOGS_tablename, and trigger name will be TLOGS name).

What dynamic data replication?


Updating or Inserting records in remote database through database triggers. It may fail if remote
database is having any problem.

What is Two-Phase Commit ?


Two-phase commit is mechanism that guarantees a distributed transaction either commits on all
involved nodes or rolls back on all involved nodes to maintain data consistency across the global
distributed database. It has two phase, a Prepare Phase and a Commit Phase.

How can you Enforce Referential Integrity in snapshots ?


Time the references to occur when master tables are not in use. Peform the reference the
manually immdiately locking the master tables. We can join tables in snopshots by creating a
complex snapshots that will based on the master tables.

What is a SQL * NET?


SQL *NET is ORACLE's mechanism for interfacing with the communication protocols used by
the networks that facilitate distributed processing and distributed databases. It is used in Clint-
Server and Server-Server communications.

What is a SNAPSHOT ?
Snapshots are read-only copies of a master table located on a remote node which is periodically
refreshed to reflect changes made to the master table.

What is the mechanism provided by ORACLE for table replication ?


Snapshots and SNAPSHOT LOGs

What is snapshots?
Snapshot is an object used to dynamically replicate data between distribute database at specified
time intervals. In ver 7.0 they are read only.
What are the various type of snapshots?
Simple and Complex.

Describe two phases of Two-phase commit ?


Prepare phase - The global coordinator (initiating node) ask a participants to prepare (to promise
to commit or rollback the transaction, even if there is a failure) Commit - Phase - If all
participants respond to the coordinator that they are prepared, the coordinator asks all nodes to
commit the transaction, if all participants cannot prepare, the coordinator asks all nodes to roll
back the transaction.

What is snapshot log ?


It is a table that maintains a record of modifications to the master table in a snapshot. It is stored
in the same database as master table and is only available for simple snapshots. It should be
created before creating snapshots.

What are the benefits of distributed options in databases?


Database on other servers can be updated and those transactions can be grouped together with
others in a logical unit.
Database uses a two phase commit.

What are the options available to refresh snapshots ?


COMPLETE - Tables are completely regenerated using the snapshots query and the master tables
every time the snapshot referenced.
FAST - If simple snapshot used then a snapshot log can be used to send the changes to the
snapshot tables.
FORCE - Default value. If possible it performs a FAST refresh; Otherwise it will perform a
complete refresh.

What is a SNAPSHOT LOG ?


A snapshot log is a table in the master database that is associated with the master table. ORACLE
uses a snapshot log to track the rows that have been updated in the master table. Snapshot logs
are used in updating the snapshots based on the master table.

What is Distributed database ?


A distributed database is a network of databases managed by multiple database servers that
appears to a user as single logical database. The data of all databases in the distributed database
can be simultaneously accessed and modified.
How can we reduce the network traffic?
- Replication of data in distributed environment.
- Using snapshots to replicate data.
- Using remote procedure calls.

Differentiate simple and complex, snapshots ?


- A simple snapshot is based on a query that does not contains GROUP BY clauses, CONNECT
BY clauses, JOINs, sub-query or snashot of operations.
- A complex snapshots contain atleast any one of the above.

What are the Built-ins used for sending Parameters to forms?


You can pass parameter values to a form when an application executes the call_form, New_form,
Open_form or Run_product.

Can you have more than one content canvas view attached with a window?
Yes. Each window you create must have atleast one content canvas view assigned to it. You can
also create a window that has manipulated content canvas view. At run time only one of the
content canvas views assign to a window is displayed at a time.

Is the After report trigger fired if the report execution fails?


Yes.

Does a Before form trigger fire when the parameter form is suppressed?
Yes.
No comments: Links to this post
Labels: Database, Oracle, SQL Server

Oracle Interview Questions And Answers [4]

What is a deadlock ? Explain .


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.

What is a Schema ?
The set of objects owned by user account is called the schema.
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.

What is Parallel Server ?


Multiple instances accessing the same database (Only In Multi-CPU environments)

What are 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

What is clusters ?
Group of tables physically stored together because they share common columns and are often
used together is called Cluster.

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 comman (Ver 7.0)

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 process can be shared by all users. The memory structure that are used to store most queried
data from database. This helps up to improve database performance by decreasing the amount of
I/O performed against data file.

What is the use of ANALYZE command ?


To perform one of these function on an index,table, or cluster:
- To collect statistics about object used by the optimizer and store them in the data dictionary.
- To delete statistics about the object used by object from the data dictionary.
- To validate the structure of the object.
- To identify migrated and chained rows of the table or cluster.

What is default tablespace ?


The Tablespace to contain schema objects created without specifying a tablespace name.

What are the system resources that can be controlled through Profile ?
The number of concurrent sessions the user can establish the CPU processing time available to
the user's session the CPU processing time available to a single call to ORACLE made by a SQL
statement the amount of logical I/O available to the user's session the amout of logical I/O
available to a single call to ORACLE made by a SQL statement the allowed amount of idle time
for the user's session the allowed amount of connect time for the user's session.

What is Tablespace Quota ?


The collective amount of disk space available to the objects in a schema on a particular
tablespace.

What are the different Levels of Auditing ?


Statement Auditing, Privilege Auditing and Object Auditing.

What is Statement Auditing ?


Statement auditing is the auditing of the powerful system privileges without regard to
specifically named objects.

What are the database administrators utilities available ?


SQL * DBA - This allows DBA to monitor and control an ORACLE database. SQL * Loader - It
loads data from standard operating system files (Flat files) into ORACLE database tables. Export
(EXP) and Import (imp) utilities allow you to move existing data in ORACLE format to and
from ORACLE database.
How can you enable automatic archiving ?
Shut the database
Backup the database
Modify/Include LOG_ARCHIVE_START_TRUE in init.ora file.
Start up the database.

What are roles? How can we implement roles ?


Roles are the easiest way to grant and manage common privileges needed by different groups of
database users. Creating roles and assigning provides to roles. Assign each role to group of users.
This will simplify the job of assigning privileges to individual users.

What are Roles ?


Roles are named groups of related privileges that are granted to users or other roles.

What are the use of Roles ?


REDUCED GRANTING OF PRIVILEGES - Rather than explicitly granting the same set of
privileges to many users a database administrator can grant the privileges for a group of related
users granted to a role and then grant only the role to each member of the group.
DYNAMIC PRIVILEGE MANAGEMENT - When the privileges of a group must change, only
the privileges of the role need to be modified. The security domains of all users granted the
group's role automatically reflect the changes made to the role.
SELECTIVE AVAILABILITY OF PRIVILEGES - The roles granted to a user can be selectively
enable (available for use) or disabled (not available for use). This allows specific control of a
user's privileges in any given situation.
APPLICATION AWARENESS - A database application can be designed to automatically enable
and disable selective roles when a user attempts to use the application.

What is Privilege Auditing ?


Privilege auditing is the auditing of the use of powerful system privileges without regard to
specifically named objects.

What is Object Auditing ?


Object auditing is the auditing of accesses to specific schema objects without regard to user.

What is Auditing ?
Monitoring of user access to aid in the investigation of database use.
No comments: Links to this post
Labels: Database, Oracle, SQL Server
Oracle Interview Questions And Answers [3]

What is an Oracle sequence?


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

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

What are the types of synonyms?


There are two types of synonyms private and public.

What is a private synonym?


Only its owner can access a private synonym.

What is a public synonym?


Any database user can access a public synonym.

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.

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.

How are the index updates?


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

What is a Tablespace?
A database is divided into Logical Storage Unit called tablespace. A tablespace is used to
grouped related logical structures together
What is Rollback Segment ?
A Database contains one or more Rollback Segments to temporarily store "undo" information.

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.

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 cant be changed latter.

What does a Control file Contain ?


A Control file records the physical structure of the database. It contains the following
information.
Database Name
Names and locations of a database's files and redolog files.
Time stamp of database creation.

What is difference between UNIQUE constraint and PRIMARY KEY constraint ?


A column defined as UNIQUE can contain Nulls while a column defined as PRIMARY KEY
can't contain Nulls.

What is Index Cluster ?


A Cluster with an index on the Cluster Key

When does a Transaction end ?


When it is committed or Rollbacked.

What is the effect of setting the value "ALL_ROWS" for OPTIMIZER_GOAL parameter of the
ALTER SESSION command ? What are the factors that affect OPTIMIZER in choosing an
Optimization approach ?
Answer The OPTIMIZER_MODE initialization parameter Statistics in the Data Dictionary the
OPTIMIZER_GOAL parameter of the ALTER SESSION command hints in the statement.

What is the effect of setting the value "CHOOSE" for OPTIMIZER_GOAL, parameter of the
ALTER SESSION Command ?
The Optimizer chooses Cost_based approach and optimizes with the goal of best throughput if
statistics for atleast one of the tables accessed by the SQL statement exist in the data dictionary.
Otherwise the OPTIMIZER chooses RULE_based approach.

How does one create a new database? (for DBA)


One can create and modify Oracle databases using the Oracle "dbca" (Database Configuration
Assistant) utility. The dbca utility is located in the $ORACLE_HOME/bin directory. The Oracle
Universal Installer (oui) normally starts it after installing the database server software.
One can also create databases manually using scripts. This option, however, is falling out of
fashion, as it is quite involved and error prone. Look at this example for creating and Oracle 9i
database:
CONNECT SYS AS SYSDBA
ALTER SYSTEM SET DB_CREATE_FILE_DEST='/u01/oradata/';
ALTER SYSTEM SET DB_CREATE_ONLINE_LOG_DEST_1='/u02/oradata/';
ALTER SYSTEM SET DB_CREATE_ONLINE_LOG_DEST_2='/u03/oradata/';
CREATE DATABASE;

What database block size should I use? (for DBA)


Oracle recommends that your database block size match, or be multiples of your operating
system block size. One can use smaller block sizes, but the performance cost is significant. Your
choice should depend on the type of application you are running. If you have many small
transactions as with OLTP, use a smaller block size. With fewer but larger transactions, as with a
DSS application, use a larger block size. If you are using a volume manager, consider your
"operating system block size" to be 8K. This is because volume manager products use 8K blocks
(and this is not configurable).

What are the different approaches used by Optimizer in choosing an execution plan ?
Rule-based and Cost-based.

What does ROLLBACK do ?


ROLLBACK retracts any of the changes resulting from the SQL statements in the transaction.

How does one coalesce free space ? (for DBA)


SMON coalesces free space (extents) into larger, contiguous extents every 2 hours and even then,
only for a short period of time.
SMON will not coalesce free space if a tablespace's default storage parameter "pctincrease" is set
to 0. With Oracle 7.3 one can manually coalesce a tablespace using the ALTER
TABLESPACE ... COALESCE; command, until then use:
SQL> alter session set events 'immediate trace name coalesce level n';
Where 'n' is the tablespace number you get from SELECT TS#, NAME FROM SYS.TS$;
You can get status information about this process by selecting from the
SYS.DBA_FREE_SPACE_COALESCED dictionary view.
How does one prevent tablespace fragmentation? (for DBA)
Always set PCTINCREASE to 0 or 100.
Bizarre values for PCTINCREASE will contribute to fragmentation. For example if you set
PCTINCREASE to 1 you will see that your extents are going to have weird and wacky sizes:
100K, 100K, 101K, 102K, etc. Such extents of bizarre size are rarely re-used in their entirety.
PCTINCREASE of 0 or 100 gives you nice round extent sizes that can easily be reused. E.g..
100K, 100K, 200K, 400K, etc.

Use the same extent size for all the segments in a given tablespace. Locally Managed tablespaces
(available from 8i onwards) with uniform extent sizes virtually eliminates any tablespace
fragmentation. Note that the number of extents per segment does not cause any performance
issue anymore, unless they run into thousands and thousands where additional I/O may be
required to fetch the additional blocks where extent maps of the segment are stored.

Where can one find the high water mark for a table? (for DBA)
There is no single system table, which contains the high water mark (HWM) for a table. A table's
HWM can be calculated using the results from the following SQL statements:
SELECT BLOCKS
FROM DBA_SEGMENTS
WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
ANALYZE TABLE owner.table ESTIMATE STATISTICS;
SELECT EMPTY_BLOCKS
FROM DBA_TABLES
WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
Thus, the tables' HWM = (query result 1) - (query result 2) - 1
NOTE: You can also use the DBMS_SPACE package and calculate the HWM =
TOTAL_BLOCKS - UNUSED_BLOCKS - 1.

What is COST-based approach to optimization ?


Considering available access paths and determining the most efficient execution plan based on
statistics in the data dictionary for the tables accessed by the statement and their associated
clusters and indexes.

What does COMMIT do ?


COMMIT makes permanent the changes resulting from all SQL statements in the transaction.
The changes made by the SQL statements of a transaction become visible to other user sessions
transactions that start only after transaction is committed.

How are extents allocated to a segment? (for DBA)


Oracle8 and above rounds off extents to a multiple of 5 blocks when more than 5 blocks are
requested. If one requests 16K or 2 blocks (assuming a 8K block size), Oracle doesn't round it up
to 5 blocks, but it allocates 2 blocks or 16K as requested. If one asks for 8 blocks, Oracle will
round it up to 10 blocks.
Space allocation also depends upon the size of contiguous free space available. If one asks for 8
blocks and Oracle finds a contiguous free space that is exactly 8 blocks, it would give it you. If it
were 9 blocks, Oracle would also give it to you. Clearly Oracle doesn't always round extents to a
multiple of 5 blocks.
The exception to this rule is locally managed tablespaces. If a tablespace is created with local
extent management and the extent size is 64K, then Oracle allocates 64K or 8 blocks assuming
8K-block size. Oracle doesn't round it up to the multiple of 5 when a tablespace is locally
managed.

Can one rename a database user (schema)? (for DBA)


No, this is listed as Enhancement Request 158508. Workaround:
Do a user-level export of user A
create new user B
Import system/manager fromuser=A touser=B
Drop user A
No comments: Links to this post
Labels: Database, Oracle, SQL Server

Oracle Interview Questions And Answers [2]

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

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.

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.

What is schema?
A schema is collection of database objects of a user.

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.

Can objects of the same schema reside in different tablespaces?

Yes.

Can a tablespace hold objects from different schemes?


Yes.

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.

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

What is Partial Backup ?


A Partial Backup is any operating system backup short of a full backup, taken while the database
is open or shut down.

What is Mirrored on-line Redo Log ?


A mirrored on-line redo log consists of copies of on-line redo log files physically located on
separate disks, changes made to one member of the group are made to all members

What is Full Backup ?


A full backup is an operating system backup of all data files, on-line redo log files and control
file that constitute ORACLE database and the parameter.

Can a View based on another View ?


Yes.

Can a Tablespace hold objects from different Schemes ?


Yes.
Can objects of the same Schema reside in different tablespace ?
Yes.

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.

Do View contain Data ?


Views do not contain or store data.

What are the Referential actions supported by FOREIGN KEY integrity constraint ?
UPDATE and DELETE Restrict - A referential integrity rule that disallows the update or deletion
of referenced data. DELETE Cascade - When a referenced row is deleted all associated
dependent rows are deleted.

What are the type of Synonyms?


There are two types of Synonyms Private and Public.

What is a Redo Log ?


The set of Redo Log files YSDATE,UID,USER or USERENV SQL functions, or the pseudo
columns LEVEL or ROWNUM.

What is an Index Segment ?


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

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

What are the different type of Segments ?


Data Segment, Index Segment, Rollback Segment and Temporary Segment.

What are Clusters ?


Clusters are groups of one or more tables physically stores together to share common columns
and are often used together.
What is an Integrity Constrains ?
An integrity constraint is a declarative way to define a business rule for a column of a table.

What is an 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.

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.

What is a 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.)

What is 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.
No comments: Links to this post
Labels: Database, Oracle

Oracle Interview Questions And Answers

What is Auditing ?
The database has the ability to audit all actions that take place within it.
a) Login attempts, b) Object Accesss, c) Database Action Result of Greatest(1,NULL) or
Least(1,NULL) NULL

While designing in client/server what are the 2 imp. things to be considered ?


Network Overhead (traffic), Speed and Load of client server

When to create indexes ?


To be created when table is queried for less than 2% or 4% to 25% of the table rows.

How can you avoid indexes ?


TO make index access path unavailable - Use FULL hint to optimizer for full table scan - Use
INDEX or AND-EQUAL hint to optimizer to use one index or set to indexes instead of another. -
Use an expression in the Where Clause of the SQL.

What is the result of the following SQL :


Select 1 from dual
UNION
Select 'A' from dual;

Error

Can database trigger written on synonym of a table and if it can be then what would be the effect
if original table is accessed.
Yes, database trigger would fire.

Can you alter synonym of view or view ?


No

Can you create index on view ?


No

What is the difference between a view and a synonym ?


Synonym is just a second name of table used for multiple link of database. View can be created
with many tables, and with virtual columns and with conditions. But synonym can be on view.

What is the difference between alias and synonym ?


Alias is temporary and used with one query. Synonym is permanent and not used as alias.

What is the effect of synonym and table name used in same Select statement ?
Valid

What's the length of SQL integer ?


32 bit length

What is the difference between foreign key and reference key ?


Foreign key is the key i.e. attribute which refers to another table primary key. Reference key is
the primary key of table referred by another table.

Can dual table be deleted, dropped or altered or updated or inserted ?


Yes

If content of dual is updated to some value computation takes place or not ?


Yes

If any other table same as dual is created would it act similar to dual?
Yes

For which relational operators in where clause, index is not used ?


<> , like '% ...' is NOT functions, field +constant, field || ''

Assume that there are multiple databases running on one machine. How can you switch from one
to another ?
Changing the ORACLE_SID

What are the advantages of Oracle ?


Portability : Oracle is ported to more platforms than any of its competitors, running on more than
100 hardware platforms and 20 networking protocols.
Market Presence : Oracle is by far the largest RDBMS vendor and spends more on R & D than
most of its competitors earn in total revenue. This market clout means that you are unlikely to be
left in the lurch by Oracle and there are always lots of third party interfaces available.
Backup and Recovery : Oracle provides industrial strength support for on-line backup and
recovery and good software fault tolerence to disk failure. You can also do point-in-time
recovery.
Performance : Speed of a 'tuned' Oracle Database and application is quite good, even with large
databases. Oracle can manage > 100GB databases.
Multiple database support : Oracle has a superior ability to manage multiple databases within the
same transaction using a two-phase commit protocol.

What is a forward declaration ? What is its use ?


PL/SQL requires that you declare an identifier before using it. Therefore, you must declare a
subprogram before calling it. This declaration at the start of a subprogram is called forward
declaration. A forward declaration consists of a subprogram specification terminated by a
semicolon.

What are actual and formal parameters ?


Actual Parameters : Subprograms pass information using parameters. The variables or
expressions referenced in the parameter list of a subprogram call are actual parameters. For
example, the following procedure call lists two actual parameters named emp_num and amount:
Eg. raise_salary(emp_num, amount);
Formal Parameters : The variables declared in a subprogram specification and referenced in the
subprogram body are formal parameters. For example, the following procedure declares two
formal parameters named emp_id and increase: Eg. PROCEDURE raise_salary (emp_id
INTEGER, increase REAL) IS current_salary REAL;

What are the types of Notation ?


Position, Named, Mixed and Restrictions.

What all important parameters of the init.ora are supposed to be increased if you want to increase
the SGA size ?
In our case, db_block_buffers was changed from 60 to 1000 (std values are 60, 550 & 3500)
shared_pool_size was changed from 3.5MB to 9MB (std values are 3.5, 5 & 9MB) open_cursors
was changed from 200 to 300 (std values are 200 & 300) db_block_size was changed from 2048
(2K) to 4096 (4K) {at the time of database creation}.
The initial SGA was around 4MB when the server RAM was 32MB and The new SGA was
around 13MB when the server RAM was increased to 128MB.

If I have an execute privilege on a procedure in another users schema, can I execute his
procedure even though I do not have privileges on the tables within the procedure ?
Yes

What are various types of joins ?


Equijoins, Non-equijoins, self join, outer join

What is a package cursor ?


A package cursor is a cursor which you declare in the package specification without an SQL
statement. The SQL statement for the cursor is attached dynamically at runtime from calling
procedures.

If you insert a row in a table, then create another table and then say Rollback. In this case will the
row be inserted ?
Yes. Because Create table is a DDL which commits automatically as soon as it is executed. The
DDL commits the transaction even if the create statement fails internally (eg table already exists
error) and not syntactically.

What are the various types of queries ??


Normal Queries
Sub Queries
Co-related queries
Nested queries
Compound queries
What is a transaction ?
A transaction is a set of SQL statements between any two COMMIT and ROLLBACK
statements.

What is implicit cursor and how is it used by Oracle ?


An implicit cursor is a cursor which is internally created by Oracle. It is created by Oracle for
each individual SQL.

Which of the following is not a schema object : Indexes, tables, public synonyms, triggers and
packages ?
Public synonyms

What is PL/SQL?
PL/SQL is Oracle's Procedural Language extension to SQL. The language includes object
oriented programming techniques such as encapsulation, function overloading, information
hiding (all but inheritance), and so, brings state-of-the-art programming to the Oracle database
server and a variety of Oracle tools.

Is there a PL/SQL Engine in SQL*Plus?


No. Unlike Oracle Forms, SQL*Plus does not have a PL/SQL engine. Thus, all your PL/SQL are
send directly to the database engine for execution. This makes it much more efficient as SQL
statements are not stripped off and send to the database individually.

Is there a limit on the size of a PL/SQL block?


Currently, the maximum parsed/compiled size of a PL/SQL block is 64K and the maximum code
size is 100K. You can run the following select statement to query the size of an existing package
or procedure.
SQL> select * from dba_object_size where name = 'procedure_name'

Can one read/write files from PL/SQL?


Included in Oracle 7.3 is a UTL_FILE package that can read and write files. The directory you
intend writing to has to be in your INIT.ORA file (see UTL_FILE_DIR=... parameter). Before
Oracle 7.3 the only means of writing a file was to use DBMS_OUTPUT with the SQL*Plus
SPOOL command.
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('/home/oracle/tmp', 'myoutput','W');
UTL_FILE.PUTF(fileHandler, 'Value of func1 is %sn', func1(1));
UTL_FILE.FCLOSE(fileHandler);
END;

How can I protect my PL/SQL source code?


PL/SQL V2.2, available with Oracle7.2, implements a binary wrapper for PL/SQL programs to
protect the source code. This is done via a standalone utility that transforms the PL/SQL source
code into portable binary object code (somewhat larger than the original). This way you can
distribute software without having to worry about exposing your proprietary algorithms and
methods. SQL*Plus and SQL*DBA will still understand and know how to execute such scripts.
Just be careful, there is no "decode" command available.
The syntax is:
wrap iname=myscript.sql oname=xxxx.yyy

Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure ? How ?
From PL/SQL V2.1 one can use the DBMS_SQL package to execute dynamic SQL statements.
Eg: CREATE OR REPLACE PROCEDURE DYNSQL
AS
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur,'CREATE TABLE X (Y DATE)', DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;
No comments: Links to this post
Labels: Database, Oracle

Data Warehousing/Data Mining

1. What is Data Warehousing?


2. What are Data Marts?
3. What are Fact tables and Dimension Tables?
4. What is Snow Flake Schema design in database?
5. What is ETL process in Data warehousing?
6. How can we do ETL process in SQL Server?
7. What is Data mining?
8. Compare Data mining and Data Warehousing?
9. What is BCP?
10. How can we import and export using BCP utility?
11. In BCP we want to change field position or eliminate some fields how can we achieve this?
12. What is Bulk Insert?
13. What is DTS?
14. Can you brief about the Data warehouse project you worked on?
15. What is an OLTP (Online Transaction Processing) System?
16. What is an OLAP (On-line Analytical processing) system?
17. What is Conceptual, Logical and Physical model?
18. What is Data purging?
19. What is Analysis Services?
20. What are CUBES?
21. What are the primary ways to store data in OLAP?
22. What is META DATA information in Data warehousing projects?
23. What is multi-dimensional analysis?
24. What is MDX?
25. How did you plan your Data ware house project?
26. What are different deliverables according to phases?
27. Can you explain how analysis service works?
28. What are the different problems that Data mining can solve?
29. What are different stages of Data mining?
30. What is Discrete and Continuous data in Data mining world?
31. What is MODEL is Data mining world?
32. How are models actually derived?
33. What is a Decision Tree Algorithm?
34. Can decision tree be implemented using SQL?
35. What is Nave Bayes Algorithm?
36. Explain clustering algorithm?
37. Explain in detail Neural Networks?
38. What is Back propagation in Neural Networks?
39. What is Time Series algorithm in data mining?
40. Explain Association algorithm in Data mining?
41. What is Sequence clustering algorithm?
42. What are algorithms provided by Microsoft in SQL Server?
43. How does data mining and data warehousing work together?
44. What is XMLA?
45. What is Discover and Execute in XMLA?
No comments: Links to this post
Labels: Data Warehousing, Database

Integration Services/DTS

1. What is Integration Services import / export wizard?


2. What are prime components in Integration Services?
3. How can we develop a DTS project in Integration Services?
No comments: Links to this post
Labels: Database, Integration Services

Database Optimization

1. What are indexes


2. What are B-Trees?
3. I have a table which has lot of inserts, is it a good database design to create indexes on that
table?
4. What are Table Scans and Index Scans?
5. What are the two types of indexes and explain them in detail?
6. What is FillFactor concept in indexes?
7. What is the best value for FillFactor?
8. What are Index statistics?
9. How can we see statistics of an index?
10. How do you reorganize your index, once you find the problem?
11. What is Fragmentation?
12. How can we measure Fragmentation?
13. How can we remove the Fragmented spaces?
14. What are the criteria you will look in to while selecting an index?
15. What is Index Tuning Wizard?
16. What is an Execution plan?
17. How do you see the SQL plan in textual format?
18. What is nested join, hash join and merge join in SQL Query plan?
19. What joins are good in what situations?
20. What is RAID and how does it work
Database Objective Question
Question 1
What are the maximum number of tables that can be joined together in a query?

A) 16
B) 32
C) 256
D) 1024

Question 2
When using BCP to copy data into a table, which of the following statements apply?
Choose 2.

A) Database users will not be able to access the table because BCP will lock it.
B) Database users will see the rows inserted by BCP after each batch is complete.
C) You must have INSERT permissions on the table.
D) Existing rows are replaced by BCP.

Question 3
An UPDATE statement may modify how many tables?

A) One or more tables, provided the UPDATE statement is not operating on a view.
B) Only one, though triggers may cause additional side-effects.
C) Only one.
D) Up to sixteen

Question 4
Data and log files expand by what increment?

A) 8KB
B) 64KB
C) 512KB
D) 1MB

Question 5
Jamie is having a problem tracking down an issue users are having with a stored
procedure.
Users will occasionally have problems with the stored procedure running for an
excessive
amount of time, perhaps hours on end. There are no messages in the SQL Server
error log that
correspond to the times that users are having problems. Which of the following is
the most
likely cause and resolution?

A) The server is crashing and the users aren't able to access their data. Replace the
hardware.
B) The server is processing a database backup, and which is causing an excessive
amount of locking. Stop the automated backup jobs.
C) There is a problem with one or more user connections causing lock contention.
Use sp_who and DBCC INPUTBUFFER to track down the likely culprit.
D) There is a problem with one or more user connections causing lock contention.
Use sp_lock to track down the

Question 6
Which of the following commands are parts of the Data Definition Language (DDL)?

A) INSERT
B) CREATE TABLE
C) UPDATE
D) CREATE VIEW

Question 7
Consider the following table and trigger definitions: Table1: UserID int IDENTITY
FirstName
char(50) LastName char(50) DepartmentID int BillingID int CREATE TRIGGER
Table1_InsertUpdate ON
Table1 FOR INSERT, UPDATE AS BEGIN IF UPDATE(DepartmentID) IF (Select count(*)
from Table1
inner join Deleted on Table1.DepartmentID = deleted.departmentid) = 0 BEGIN
RAISERROR
('Cannot remove the last member from a department.', 16, 1) ROLLBACK END END
What does the
ROLLBACK statement in the trigger do?
A) It causes the transaction to roll back, aborting the INSERT or UPDATE that cause
the trigger to run,
but not aborting the transaction that the offending statement was part of.
B) It causes the transaction containing the offending statement to roll back.
C) Nothing; the keyword EXIT should have been used to abort the transaction.
D) It causes the transaction log to fill up.

Question 8
In order for her new application to process a sales record, Kim has to make sure that
the
application has collected enough information. For sales over $500, she needs to
have a valid
account manager's ID number. For sales over $1000, she needs to have a valid zip
code for
delivery to determine who gets commission. For sales over $10,000, she needs to
make sure that
enough stock is available. Which of the following would be a good way to check the
data prior
to inserting it?

A) Table constraints
B) Triggers
C) An inline table-valued function
D) A multi-statement table-valued function

Question 9
What is the maximum number of rows that a table can store in SQL Server 2000?

A) 255
B) 1,048,516
C) 2,147,483,647
D) No limit besides physical storage size

Question 10
If table_a has an insert trigger that performs an update on table_b, in which case
will the
update trigger on table_b be fired?

A) If the 'nested triggers' database option has a value of '1'.


B) If the 'nested triggers' server option is set to '1'.
C) If the 'nestable' option is set for the trigger on table_a.
D) If the 'nestable' option is set for the trigger on table_b.
Question 11
You are finding unusually high memory utilization on a SQL Server that is primarily used to
process XML data. The server will periodically freeze up and refuse to process any more XML
statements. The problem can only be fixed by restarting the SQL Server service, at which point
it work fine for a while, but the problem always returns. What is the most likely cause for
the problem?

A) Your developers are probably not deallocating their cursors after processing the XML data.
B) The system is routinely encountering malformed XML and the accumulated errors are
crashing the system.
C) The XML strings are not being removed after being prepared and used.
D) A hardware problem is the root of your trouble.

Question 12
What are two advantages of triggers over rules and constraints? Choose two.

A) The ability to define boundaries within which the data must reside.
B) The ability to use looping structures.
C) The ability to reference data in other databases.
D) The ability to check data before it is logged.

Question 13
Which of the following is a good reason to use transactional replication?

A) It provides an up-to-the-second backup in case one of the sites in the replication model goes
down.
B) It provides a method for using a lot of resources on several servers in order to provide
up-to-the-second reporting capabilities.
C) It provides the lowest-overhead replication of any other type.
D) It is veryQuestion tolerant of network outages.

Question 14
When creating a table that contains a birth date for a person,
you want to ensure that a valid date is always entered. Which of the following is the best way to
accomplish this?

A) Adding a CHECK constraint to the column


B) Adding a trigger to the table that will validate the column
C) Using a DateTime data type for the column.
D) Using a NOT NULL constraint on the column

Question 15
Which of the following EXEC statements are valid? Choose all that apply.
A) exec ReturnValue = MyProc 5, 4, 'hello', @A OUTPUT
B) exec @ReturnValue = MyProc @length = 5, 4, 'Hello', @A OUTPUT
C) exec @ReturnValue = MyProc 5, 4, 'Hello', @A OUTPUT
D) exec @ReturnValue = MyProc @length = 5, @width = 4, @message = 'Hello', @A = @A
OUTPUT

Question 16
What tool included with SQL Server is primarily used for writing and executing ad-hoc queries?

A) SQL Server Enterprise Manager


B) SQL Server Profiler
C) SQL Server Query Analyzer
D) SQL Server Index Wizard

Question 17
What are the three join operations SQL Server supports? Choose all that apply.

A) Nested loops
B) Merge join
C) Index spool
D) Hash match

Question 18
The graphical execution plan presented by SQL Server Query Analyzer uses different icons to
represent which of the following?

A) Physical operators
B) Logical Operators
C) T-SQL commands
D) Process flow

Question 19
Phil has created a new database that takes advantage of multiple physical disks on his server.
He has created his primary data file on one disk and placed a secondary data file on a separate
physical disk. The transaction log exists on the same physical disk as the primary file.
Phils plan is to put all user objects on the secondary data file and leave the system tables
on the primary data file. After creating all his objects, however, he quickly discovers that
they ended up on the primary file group. What might he have done wrong?

A) All objects are created on the primary data file until there is no more room.
Only after the primary data file is full will objects be created on the secondary data file.
B) He probably forgot to create the secondary data file as part of a separate file group.
Objects are created on file groups rather than on data files.
C) He probably forgot to declare the secondary data file as the default data file.
Objects are created on the default data file unless another data file is specified.
D) Nothing is actually wrong. SQL Server automatically assigns the secondary data file as the
primary file group so that all user defined objects will be created separately from the
primary data file.

Question 20
Which of the following best describes a situation in which the statistics for a table would
be misleading?

A) Random rows in the table have been deleted.


B) Deleting all of the records of a specific gender.
C) Dropping Foreign Key constraints on the table
D) Dropping indexes on a table

Question 21
Which of the following are results of specifying schema binding on a view?
Choose all that apply.

A) The view created with schema binding cannot be dropped.


B) The CREATE statement for the view must contain a two-part name for all objects referenced.
C) When created with schema binding, the CREATE statement is stored in an encrypted manner
and cannot be scripted out.
D) Objects referenced by the view cannot be dropped or changed while the view is schema
bound.

Question 22
George needs to write a view that can return one or more customers from a table given a last
name or part of a last name. Which of the following strategies will allow him to do that?

A) Write a view for every single last name that can be entered.
B) Write an application that automatically creates a new view for each last name in the database.
C) Pass a lastname parameter into the view.
D) Write a SELECT statement that references the view. Use the WHERE clause in the SELECT
statement to filter the data.

Question 23
Which of the following are parts of a SELECT statement? Choose all that apply.

A) FROM
B) SORT BY
C) WHERE
D) SELECT

Question 24
Which of the following features are new to SQL Server 2000? Choose all that apply.

A) Full Text Searching


B) Indexed views
C) Cascading Referential Integrity Constraints
D) Remote administration of servers

Question 25
When is it important to use the WITH RECOMPILE option when creating a stored procedure?

A) Always use WITH RECOMPILE.


B) On servers that aren't busy, WITH RECOMPILE should be used all the time.
C) Only if the query plans used by the stored procedure change frequently.
D) When any tables that are going to be used by the stored procedure are routinely dropped and
re-created.

Question 26
Given the following partial function definition, which SET statement shown below would
correctly accept the returned value? create function Area (l1 int, l2 int) returns int

A) set @A = dbo.area(5, 4)
B) set @A = area(5,4)
C) exec area(5, 4, @A OUTPUT)
D) set @A = dbo.@Area(5, 4)

Question 27
Consider the following table and trigger definitions:
Table1: UserID int IDENTITY FirstName char(50) LastName char(50) DepartmentID int
BillingID int
CREATE TRIGGER Table1_InsertUpdate ON Table1 FOR INSERT, UPDATE AS BEGIN IF
UPDATE(DepartmentID) IF (Select count(*) from Table1 inner join Deleted on
Table1.DepartmentID = deleted.departmentid) = 0 BEGIN RAISERROR
('Cannot remove the last member from a department.', 16, 1) ROLLBACK END END
What does the RAISERROR statement in the trigger do?

A) It provides the connection with an error message.


B) It provides the connection and the SQL Server error log with an error message.
C) It provides the connection, the SQL Server error log file, and the Windows NT application
event log with an error message.
D) It causes a server-wise severity one message, stopping SQL Server.

Question 28
Diane needs to enforce referential integrity on one of her tables. The data in one of the
columns should contain key values from a table residing in a database on the corporate server,
as opposed to her departmental server where her application database resides. She decides to
use constraints to enforce data integrity. How would you rate this solution?

A) This is an optimal solution. Using constraints to validate data entry is the best way to verify
referential integrity.
B) This is a fair solution. Although using constraints will work, it would be better to use triggers
to accomplish this goal.
C) This is a poor solution. It won't perform well, but it will work.
D) This solution won't work.

Question 29
Choose the statement that best describes a composite index.

A) It physically sorts the rows in a table.


B) It contains multiple keys.
C) It logically sorts the rows in a table in both ascending and descending order.
D) It contains multiple columns in its key.

Question 30
You need to install SQL Server Developer Edition on a spare machine to deliver to a new
developer in your company so he can study for his certification exam. Of the following machines
that can be spared,
what is the least powerful machine you can use for this purpose?

A) Pentium 266MHz, 32MB memory


B) Pentium 266MHz, 64MB memory
C) Pentium 166MHz, 64MB memory
D) Pentium 90MHz, 32MB Memory

Question 31
Which of the following types of columns would be good candidates for an index? Choose all that
apply.

A) Columns that make up the Primary Key


B) Columns that contain Foreign Keys
C) Columns that contain data such as gender for a large population.
D) Columns that contain data such as a tax ID or address for a large population

Question 32
What is the maximum number of rows that a table can store in SQL Server 2000?

A) 255
B) 1,048,516
C) 2,147,483,647
D) No limit besides physical storage size

Question 33
An UPDATE trigger typically accesses which of the following?

A) The updated table


B) The inserted table only
C) The INSERTED and DELETED tables
D) The DELETED table only

Question 34
Which of the following commands can best assist in diagnosing locking problems?

A) sp_lock
B) sp_who
C) DBCC SHOWLOCKS
D) SET SHOWLOCKS
Question 35
Which of the following commands can be used to interrupt processing of a While loop?

A) BREAK
B) HALT
C) EXIT
D) CONTINUE

Question 36
Choose all the statements that you could use in the WHERE clause to find only the rows
where the first name is Bobby or Bobbi. Choose all that apply.

A) WHERE name = Bobby or name = Bobbi


B) WHERE name LIKE Bobb_
C) WHERE name LIKE Bobb%
D) WHERE name LIKE Bobb[iy]

Question 37
What are the space requirements for views?

A) Views require as much space as all the tables they are created from.
B) Views require as much space as would a table that presented the same data.
C) Views do not store data and therefore use no space.
D) Views require the space used to store a few records in various system tables.

Question 38
You have written a stored procedure that takes several parameters and uses them to issue
appropriate queries to the database. Most of the parameters are optional, and if all are passed
the resulting query you have to run can be quite complex. There is a great deal of conditional
logic in the procedure based on the parameters passed. When testing this procedure you found
that when you first created it, it worked great even though you started with a rather complicated
set of parameters. Since then performance has been disappointing. Every time you re-create it,
it works fast once, but rarely shows such speed on later calls. What is the most likely cause
of the problem?

A) You have specified the With Encryption option, which is causing additional overhead because
the procedure has to be decrypted each time it is run.
B) You have specified the With Recompile option, which is causing additional overhead because
the procedure has to recompile a new query plan every time.
C) You have forgotten to specify the With Recompile option, which is causing an inappropriate
query plan to be used with subsequent runs.
D) Your stored procedure cannot be helped. Stored procedures werent intended to handle
complex conditional logic.

Question 39
How does a TRUNCATE TABLE statement differ from an unrestricted DELETE? Select all that
apply.

A) A TRUNCATE TABLE cannot be rolled back, even if it occurs within a transaction.


B) An unrestricted DELETE resets an Identity column to its original seed, whereas the
TRUNCATE TABLE does not.
C) If the table is referenced by a FOREIGN KEY constraint, only the DELETE may be used.
D) The TRUNCATE TABLE causes a DELETE trigger to be fired, whereas the DELETE does
not.

Question 40
What is a valid GROUP BY clause for the following SELECT list? SELECT Pub_ID, Type,
Max(Price)

A) GROUP BY Pub_ID, Type, Max(Price)


B) GROUP BY Pub_ID, Type, Price
C) GROUP BY Pub_ID, Type
D) GROUP BY max(Price)

Question 41
Jesse's company has a central office and three remote locations. Each remote location has
three to five employees that run an order-taking application; they don't generate any reports
or need any additional data beyond their order-taking application. Each site has a modest but
reliable network connection to the central office. Which of the following is the best way for
Jesse to provide these users with access to the database?

A) Set up snapshot replication to each remote site.


B) Use transactional replication to replicate data to the remote site.
C) Use merge replication to replicate data to the remote site.
D) Don't use replication; just connect the users directly to the remote database.

Question 42
Eric needs to build a stored procedure to count the number of snack food vendors within his
zip code. Which of the following strategies would be the easiest to implement for passing and
returning values?

A) Pass the zip code in as a parameter; pass the number of vendors out as a return value.
B) Pass the zip code in as a parameter; pass the number of vendors out as an output parameter.
C) Use the stored procedure to call a scalar-valued user-defined function.
D) Pass the zip code in as a parameter; pass the output back in a temporary table.

Question 43
Carol wants to distribute the Personnel table, but needs to leave out a couple of columns
from the replication, such as the AnnualSalary column. What's the best way to do this?

A) Implement horizontal partitioning.


B) Use SQL Server security to keep people out of that column.
C) Use vertical partitioning to turn off replication for that article.
D) Use union partitioning.

Question 44
Which of the following are good uses for the I-SQL utility? Choose 2.

A) Execution of Data Definition Language statements


B) Monitor queries issued by one or more users
C) Examine a graphical query plan
D) Schedule execution of a T-SQL script
Question 45
What role do CHECK constraints play in partitioned views?

A) CHECK constraints are required to ensure that an inserted row goes to the correct table.
B) CHECK constraints are not required but can increase performance for inserts to the
partitioned view.
C) CHECK constraints serve no purpose for partitioned views.
D) CHECK constraints could conflict with the definition of the partitioned view and therefore
cannot exist on the tables that make up a partitioned view.

Question 46
Which of the following options will create a composite unique index on the CustomerID and
ProjectID fields in the CP table?

A) create unique composite index CPidx on CP(CustomerID, ProjectID)


B) create unique index CPidx on CP.CustomerID, CP.ProjectID
C) create unique index CPidx on CP(CustomerID, ProjectID)
D) create clustered index CPidx on CP(CustomerID, ProjectID)

Question 47
Sam needs to set up her stored procedure so that when invalid data values are passed into the
stored procedure, the stored procedure will cause the application to see an error and have
SQL Server log an event into the error log. Which of the following will allow this to happen?

A) ON ERROR RESUME NEXT


B) RAISERROR 'Invalid data', 50000, 1, LOG
C) RAISERROR ('Invalid Data', 50000, 1) WITH LOG
D) RAISERROR('Invalid Data', 50000, 1)

Question 48
Roger wants to create an index on a read-only table. What is the best option
he should use when creating the index?

A) FILLFACTOR = 100
B) FILLFACTOR = 0
C) PAD_INDEX, FILLFACTOR = 100
D) PAD_INDEX, FILLFACTOR = 0

Question 49
When using BCP to transfer data out of a table, which of the following statements apply? Choose
3.
A) Database users will not be able to access the table because BCP will lock it.
B) You must have SELECT permissions on the table.
C) Data changes made by other users during the BCP will not be reflected in the data file.
D) The contents of the data file are replaced if the data file already exists.

Question 50
Insensitive cursors provider what functionality?

A) They enable users to see data inserted since the time the cursor was opened.
B) They allow faster updates because the data for the cursor is stored in tempdb.
C) They cannot be scrolled backward because the data is discarded from the temporary storage
after it is fetched.
D) They ensure an unchanging view of the data as it was when the cursor was opened.

Question 51
What is the lifetime of a user-defined variable?

A) Duration of the script


B) Duration of the statement block
C) Duration of the batch
D) Duration of the current SQL Server connection

Question 52
To use full-text searching and find all rows containing forms of the verb "swim,"
you should use which CONTAINS predicate?

A) CONTAINS(columname, FORMSOF(INFLECTIONAL, 'Swim'))


B) CONTAINS(columnname, 'swim', 'swims')
C) CONTAINS(columnname, FINDALL("Swims"))
D) CONTAINS(columnname, 'swim*')

Question 53
Which of the following will help reduce deadlocks in your database?

A) Keeping the transaction isolation level as high as possible without hurting user concurrency
B) Always accessing tables in the same order in all programs
C) Never completing transactions until a user can confirm that the changes are correct
D) Always checking the state of @@TRANCOUNT before issuing a ROLLBACK command

Question 54
Sarah needs to figure out how to replicate data from all of her warehouses back to the
corporate office. She wants to store all the inventory information in one table, and all of
the information needs to be accessible to all of the warehouses and the corporate office, and
the information should be updateable at any location. The warehouses do not have reliable
network connections back to the corporate office. Which type of replication should Sarah use?

A) Snapshot replication
B) Merge replication
C) Transactional replication
D) Snapshot replication with Updating Subscribers

Question 55
When creating a database with the CREATE DATABASE command, in what units can the file
size be
specified? Choose all that apply.

A) MB (Megabytes)
B) Number of pages
C) Number of extents
D) KB (Kilobytes)

Question 56
Eddie needs to have a database that is replicated to other locations. They have highly
redundant network connectivity to all of the other locations, and a very large central server.
Changes to the database need to be made at every site, and need to be done instantaneously at
every site, with no delay. Which type of replication would work best for Eddie?

A) Merge replication
B) Transactional replication
C) Snapshot replication
D) Snapshot replication with updates

Question 57
Which of the following are aggregate functions? Choose 3.

A) Sum
B) ABS
C) Max
D) Count

Question 58
Barney wrote this stored procedure to manage inserts to his Sales table: CREATE PROCEDURE
InsertSale @SalesPersonID int, @ProductID int, @Quantity int, @CustomerID int AS
If @Quantity > 0 Insert Sales (SalesPersonID, ProductID, Quantity, CustomerID) VALUES
(@SalesPersonID, @ProductID, @Quantity, @CustomerID) else RAISERROR
('Unable to enter negative or 0 quantity into Sales table.', 16, 1) GO
If there are no constraints on the table, how can Barney make sure that the value of
@SalesPersonID is valid?

A) Check the Sales table and see whether there are any other rows in that table for that
SalesPersonID.
B) Check the table in which SalesPersonID is a Primary Key to ensure that the value is valid.
C) Attempt the insert and check to see whether the foreign key constraint causes an error.
D) It's not possible to access more than one table in a stored procedure.

Question 59
Which queries will return all the names in the Authors table sorted by first name, then last?
Choose 2.

A) SELECT au_fname, au_lname FROM Authors SORT BY 1, 2


B) SELECT au_fname, au_lname FROM Authors ORDER BY au_fname, au_lname
C) SELECT au_fname, au_lname FROM Authors SORT BY au_fname, au_lname
D) SELECT au_fname, au_lname FROM Authors ORDER BY 1, 2

Question 60
When using an INSERT statement, data to be inserted may come from which of the following?
Select all that apply.

A) The VALUES clause


B) A stored procedure
C) Another database
D) A SELECT statement

Question 61
Which of the following are reasons to choose SQL Server 2000? Choose all that apply.

A) Internet integration
B) Scalability and availability
C) Enterprise-Level Database features
D) Data warehousing

Question 62
You were recently hired to oversee the installation of SQL Server to support a new accounting
package for a small business. The company is cost-conscious, so you need to make a
conservative
recommendation about where to install SQL Server in the company's existing structure. Which of
the following makes the best choice to support SQL Server?
A) Dual-processor machine with 512MB memory currently acting as an Exchange server
B) A single-processor 800MHz Pentium with 256MB memory currently acting as a Primary
Domain Controller.
C) A spare Pentium 90MHz laptop with 128MB of memory
D) Pentium 1GHz machine with 512MB memory recently purchased to replace the president's
workstation

Question 63
How is a NOT NULL column added to an existing table?

A) By using the ALTER TABLE statement.


B) Dropping and recreating the table.
C) By using ALTER TABLE to add a nullable column, and then using sp_changenull to change
the column's NULL option.
D) By using the sp_addnullablecolumn system stored procedure.

Question 64
Omitting the WHERE clause of an UPDATE or DELETE statement has what effect?

A) All rows in the specified table are affected.


B) The query returns an error because the WHERE clause is required.
C) Only the current row is affected.
D) Only the rows with the correct data type are affected.

Question 65
What statement could you use in the WHERE clause to select all the rows in a table where no
price is defined?

A) WHERE price IS NOT NULL


B) WHERE price IS < 0
C) WHERE price != 0
D) WHERE price IS NULL

Question 66
Consider the following table and trigger definitions: Table1: UserID int IDENTITY FirstName
char(50)
LastName char(50) DepartmentID int BillingID int CREATE TRIGGER Table1_InsertUpdate
ON Table1
FOR INSERT, UPDATE AS BEGIN IF UPDATE(DepartmentID) IF (Select count(*) from
Table1 inner join
Deleted on Table1.DepartmentID = deleted.departmentid) = 0 BEGIN RAISERROR
('Cannot remove the last member from a department.', 16, 1) ROLLBACK END END Assuming
that this
is the only trigger bound to the table, is it possible for the last member of a department to
be deleted?

A) No; the trigger prevents that from happening.


B) Yes; the trigger has not been activated yet.
C) Yes, if a new record is inserted on top of the existing one.
D) Yes, by using the DELETE command.

Question 67
Referential integrity refers to what?

A) The enforced uniqueness of a row in a table


B) The enforced uniqueness of a column in a table
C) Ensuring that a Foreign Key attribute cannot be NULL
D) The enforced synchronization of Primary Key and Foreign Key values

Question 68
Barney wrote this stored procedure to manage inserts to his Sales table:
CREATE PROCEDURE InsertSale @SalesPersonID int, @ProductID int, @Quantity int,
@CustomerID int
AS If @Quantity > 0 Insert Sales (SalesPersonID, ProductID, Quantity, CustomerID) VALUES
(@SalesPersonID, @ProductID, @Quantity, @CustomerID) else RAISERROR
('Unable to enter negative or 0 quantity into Sales table.', 16, 1) GO What does the
RAISERROR statement do?

A) The RAISERROR will cause the row to not be inserted into the database.
B) It provides feedback to the calling application so it can diagnose why the insert failed.
C) It will cause SQL Server to shut down because a severity 1 error occurred.
D) It will do nothing.

Question 69
SQL Sever maintains what types of information about a column in the table definition?

A) Name, NULL option, and constraints


B) Name, data type, and NULL option
C) Name, data type, NULL option, and bytes of overhead.
D) Name, data type, NULL option, and constraint information

Question 70
DTS Package Designer tasks can be set to run in what ways? Choose all that apply.

A) On completion
B) On failure
C) On error
D) On success

Database Optimization
1. What are indexes
2. What are B-Trees?
3. I have a table which has lot of inserts, is it a good database design to create
indexes on that table?
4. What are Table Scans and Index Scans?
5. What are the two types of indexes and explain them in detail?
6. What is FillFactor concept in indexes?
7. What is the best value for FillFactor?
8. What are Index statistics?
9. How can we see statistics of an index?
10. How do you reorganize your index, once you find the problem?
11. What is Fragmentation?
12. How can we measure Fragmentation?
13. How can we remove the Fragmented spaces?
14. What are the criteria you will look in to while selecting an index?
15. What is Index Tuning Wizard?
16. What is an Execution plan?
17. How do you see the SQL plan in textual format?
18. What is nested join, hash join and merge join in SQL Query plan?
19. What joins are good in what situations?
20. What is RAID and how does it work

SQL server : Difference between Function and Stored Procedure?

UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section
where as Stored procedures cannot be.

UDFs that return tables can be treated as another rowset. This can be used in JOINs with other
tables.

Inline UDF's can be though of as views that take parameters and can be used in JOINs and other
Rowset operations.

No comments: Links to this post


Labels: Database Questions With Answer, SQL Server Questions With Answer

SQL server : What is a NOLOCK?

Using the NOLOCK query optimiser hint is generally considered good practice in order to
improve concurrency on a busy system. When the NOLOCK hint is included in a SELECT
statement, no locks are taken when data is read. The result is a Dirty Read, which means that
another process could be updating the data at the exact time you are reading it. There are no
guarantees that your query will retrieve the most recent data. The advantage to performance is
that your reading of data will not block updates from taking place, and updates will not block
your reading of data. SELECT statements take Shared (Read) locks. This means that multiple
SELECT statements are allowed simultaneous access, but other processes are blocked from
modifying the data. The updates will queue until all the reads have completed, and reads
requested after the update will wait for the updates to complete. The result to your system is
delay(blocking).
1 comment: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

SQL Server : How to implement one-to-one, one-to-many and many-to-many


relationships while designing tables?

One-to-One relationship can be implemented as a single table and rarely as two tables with
primary and foreign key relationships.

One-to-Many relationships are implemented by splitting the data into two tables with primary
key and foreign key relationships.

Many-to-Many relationships are implemented using a junction table with the keys from both the
tables forming the composite primary key of the junction table.

No comments: Links to this post


Labels: Database Questions With Answer, SQL Server Questions With Answer

SQL Server : What are different type of Collation Sensitivity?

Case sensitivity

A and a, B and b, etc.

Accent sensitivity

a and , o and , etc.

Kana Sensitivity

When Japanese kana characters Hiragana and Katakana are treated differently, it is called Kana
sensitive.
Width sensitivity

When a single-byte character (half-width) and the same character when represented as a double-
byte character (full-width) are treated differently then it is width sensitive.

No comments: Links to this post


Labels: Database Questions With Answer, SQL Server Questions With Answer

SQL server : What are the different index configurations a table can have?

A table can have one of the following index configurations:

No indexes

A clustered index

A clustered index and many nonclustered indexes

A nonclustered index

Many nonclustered indexes

No comments: Links to this post


Labels: Database Questions With Answer, SQL Server Questions With Answer

SQL Server : What are the difference between clustered and a non-clustered
index?

A clustered index is a special type of index that reorders the way records in the table are
physically stored. Therefore table can have only one clustered index. The leaf nodes of a
clustered index contain the data pages.
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

SQL server : What is BCP? When do we use it?

BulkCopy is a tool used to copy huge amount of data from tables and views. But it won't copy
the structures of the same.
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer
SQL Server : What is log shipping?

Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature of SQL Server 2000.
We should have two SQL Server - Enterprise Editions. From Enterprise Manager we can
configure the logshipping. In logshipping the transactional log file from one server is
automatically updated into the backup database on the other server. If one server fails, the other
server will have the same db and we can use this as the DR (disaster recovery) plan.

No comments: Links to this post


Labels: Database Questions With Answer, SQL Server Questions With Answer

SQL Server : Where do you think the users names and passwords will be stored
in sql server?

They get stored in master db in the sysxlogins table.


No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : What are the authentication modes in SQL Server?

Windows mode and mixed mode (SQL & Windows).


No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : How do you troubleshoot SQL Server if its running very slow?

First check the processor and memory usage to see that processor is not above 80% utilization
and memory not above 40-45% utilization then check the disk utilization using Performance
Monitor, Secondly, use SQL Profiler to check for the users and current SQL activities and jobs
running which might be a problem. Third would be to run UPDATE_STATISTICS command to
update the indexes
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : Can you explain the role of each SQL Server service?

SQL SERVER - is for running the databases SQL AGENT - is for automation such as Jobs, DB
Maintanance, Backups DTC - Is for linking and connecting to other SQL Servers
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : What are the OS services that the SQL Server installation adds?

MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac co-ordinator)
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : Which stored procedure will you are running to add a linked server?

sp_addlinkedserver, sp_addlinkedsrvlogin
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : Can you link only other SQL Servers or any database servers such as
Oracle?

We can link any server provided we have the OLE-DB provider from Microsoft to allow a link.
For Oracle we have a OLE-DB provider for oracle that microsoft provides to add it as a linked
server to the sql server group.
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : When do you use SQL Profiler?

SQL Profiler utility allows us to basically track connections to the SQL Server and also
determine activities such as which SQL Scripts are running, failed jobs etc..
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : What is a Join in SQL Server?

Join actually puts data from two or more tables into a single result set.
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : What do you mean by COLLATION?

Collation is basically the sort order. There are three types of sort order Dictionary case sensitive,
Dictonary - case insensitive and Binary.
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer

Database : What is the difference between a HAVING CLAUSE and a WHERE


CLAUSE?

Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause
is applied to each row before they are part of the GROUP BY function in a query.
No comments: Links to this post
Labels: Database Questions With Answer, SQL Server Questions With Answer
Database : What command do we use to rename a db?

sp_renamedb 'oldname' , 'newname'

Well sometimes sp_reanmedb may not work you know because if some one is using the db it will
not accept this command so what do you think you can do in such cases? - In such cases we can
first bring to db to single user using sp_dboptions and then we can rename that db and then we
can rerun the sp_dboptions command to remove the single user mode.

Linux/Unix Interview Question with Answer


1. Q. How do you list files in a directory?
A. ls - list directory contents
ls l (-l use a long listing format)

2. Q. How do you list all files in a directory, including the hidden files?
A. ls -a (-a, do not hide entries starting with .)

3. Q. How do you find out all processes that are currently running?
A. ps -f (-f does full-format listing.)

4. Q. How do you find out the processes that are currently running or a particular
user?
A. ps -au Myname (-u by effective user ID (supports names)) (a - all users)

5. Q. How do you kill a process?


A. kill -9 8 (process_id or kill -9 %7 (job number 7)
kill -9 -1 (Kill all processes you can kill.)
killall - kill processes by name most (useful - killall java)

6. Q. What would you use to view contents of the file?


A. less filename
cat filename
pg filename
pr filename
more filename
most useful is command: tail file_name - you can see the end of the log file.

7. Q. What would you use to edit contents of the file?


A. vi screen editor or jedit, nedit or ex line editor

8. Q. What would you use to view contents of a large error log file?
A. tail -10 file_name ( last 10 rows)

9. Q. How do you log in to a remote Unix box?


A. Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login
program))

10.Q. How do you get help on a UNIX terminal?


A. man command_name
info command_name (more information)

11.Q. How do you list contents of a directory including all of its


subdirectories, providing full details and sorted by modification time?
A. ls -lac
-a all entries
-c by time

12.Q. How do you create a symbolic link to a file (give some reasons of doing so)?
A. ln /../file1 Link_name
Links create pointers to the actual files, without duplicating the contents of
the files. That is, a link is a way of providing another name to the same file.
There are two types of links to a file:Hard link, Symbolic (or soft) link;

13.Q. What is a filesystem?


A. Sum of all directories called file system.
A file system is the primary means of file storage in UNIX.
File systems are made of inodes and superblocks.

14.Q. How do you get its usage (a filesystem)?


A. By storing and manipulate files.

15.Q. How do you check the sizes of all users home directories (one command)?
A. du -s
df

The du command summarizes disk usage by directory. It recurses through all


subdirectories and shows disk usage by each subdirectory with a final total at the
end.

Q. in current directory
A. ls -ps (p- directory; s - size)

16.Q. How do you check for processes started by user 'pat'?

A. ps -fu pat (-f -full_format u -user_name )

17.Q. How do you start a job on background?

A. bg %4 (job 4)

18 Q. What utility would you use to replace a string '2001' for '2002' in a text file?
A. Grep, Kde( works on Linux and Unix)

19. Q. What utility would you use to cut off the first column in a text file?
A. awk, kde

20. Q. How to copy file into directory?


A. cp /tmp/file_name . (dot mean in the current directory)

21. Q. How to remove directory with files?


A. rm -rf directory_name

22. Q. What is the difference between internal and external commands?


A. Internal commands are stored in the; same level as the operating system while
external
commands are stored on the hard disk among the other utility programs.

23. Q. List the three main parts of an operating system command:


A. The three main parts are the command, options and arguments.

24 Q. What is the difference between an argument and an option (or switch)?


A. An argument is what the command should act on: it could be a filename,
directory or name. An option is specified when you want to request additional
information over and above the basic information each command supplies.

25. Q. What is the purpose of online help?


A. Online help provides information on each operating system command, the
syntax, the options, the arguments with descriptive information.
26. Q. Name two forms of security.
A. Two forms of security are Passwords and File Security with permissions specified.

27. Q. What command do you type to find help about the command who?
A. $ man who

28. Q. What is the difference between home directory and working directory?
A. Home directory is the directory you begin at when you log into the
system. Working directory can be anywhere on the system and it is where you are
currently
working.

29. Q. Which directory is closer to the top of the file system tree, parent directory or
current directory?
A. The parent directory is above the current directory, so it is closer to
the root or top of the
file system.

30. Q. Given the following pathname:


$ /business/acctg/payable/supplier/april
a) If you were in the directory called acctg, what would be the relative
pathname name for the file called april?
b) What would be the absolute pathname for april?
A.
a) $ payable/supplier/april
b) $ /business/acctg/payable/supplier/april

31. Q. Suppose your directory had the following files:


help. 1 help.2 help.3 help.4 help.O1 help.O2
aid.O1 aid.O2 aid.O3 back. 1 back.2 back.3
a) What is the command to list all files ending in 2?
b) What is the command to list all files starting in aid?
c) What is the command to list all "help" files with one character extension?
A.
a) ls *2
b) ls aid.*
c) ls help.?

32. Q. What are two subtle differences in using the more and the pg commands?
A. With the more command you display another screenful by pressing
the spacebar, with pg you press the return key.
The more command returns you automatically to the UNIX
shell when completed, while pg waits until you press return.

33. Q. When is it better to use the more command rather than cat command?
A. It is sometimes better to use the more command when you are viewing
a file that will display over one screen.

34. Q. What are two functions the move mv command can carry out?
A. The mv command moves files and can also be used to rename a file or directory.

35. Q. Name two methods you could use to rename a file.


A. Two methods that could be used:
a. use the mv command
b. copy the file and give it a new name and then remove the original file if no longer
needed.

36. The soccer league consists of boy and girl teams. The boy file names begin
with B, the girl teams begin with G. All of these files are in one directory
called "soccer", which is your current directory:
Bteam.abc Bteam.OOl Bteam.OO2 Bteam.OO4
Gteam.win Gteam.OOl Gteam.OO2 Gteam.OO3
Write the commands to do the following:
a) rename the file Bteam.abc to Bteam.OO3.
b) erase the file Gteam. win after you have viewed the contents of the file
c) make a directory for the boy team files called "boys", and one for the girl team
files
called" girls"
d) move all the boy teams into the "boys" directory
e) move all the girl teams into the "girls" directory
f) make a new file called Gteam.OO4 that is identical to Gteam.OOl
g) make a new file called Gteam.OO5 that is identical to Bteam.OO2
A.
a) mv Bteam.abc Bteam.OO3.
b) cat Gteam.win -or- more Gteam.win
rm Gteam. win
c) mkdir boys
mkdir girls
d) mv Bteam* boys
e) mv Gteam* girls
f) cd girls
cp Gteam.OO1 Gteam.OO4
g) There are several ways to do this. Remember that we are currently in the
directory
/soccer/girls.
cp ../boys/Bteam.OO2 Gteam.OO5
or
cd ../boys
cp Bteam.OO2 ../girls/Gteam.OO5

37. Q. Draw a picture of the final directory structure for the "soccer"
directory, showing all the files and directories.

38. Q. What metacharacter is used to do the following:


1.1 Move up one level higher in the directory tree structure
1.2 Specify all the files ending in .txt
1.3 Specify one character
1.4 Redirect input from a file
1.5 Redirect the output and append it to a file
A.
1. 1.1 double-dot or ..
1.2 asterisk or *
1.3 question or ?
1.4 double greater than sign: >>
1.5 the less than sign or <

39. Q. List all the files beginning with A


A. To list all the files beginning with A command: ls A*

40. Q. Which of the quoting or escape characters allows the dollar sign ($) to retain
its special meaning?
A. The double quote (") allows the dollar sign ($) to retain its special meaning.
Both the backslash (\) and single quote (') would remove the special meaning of the
dollar sign.

41. Q. What is a faster way to do the same command?


mv fileO.txt newdir
mv filel.txt newdir
mv file2.txt newdir
mv file3.txt newdir
A. A shortcut method would be: mv file?.txt newdir

42. Q. List two ways to create a new file:


A.
a. Copy a file to make a new file.
b. Use the output operator e.g. ls -l > newfile.txt

43. Q. What is the difference between > and >> operators?


A. The operator > either overwrites the existing file (WITHOUT WARNING) or creates
a new file.
The operator >> either adds the new contents to the end of an existing file or
creates a new file.

44. Write the command to do the following:


44.1 Redirect the output from the directory listing to a printer.
44.2 Add the file efg.txt to the end of the file abc.txt.
44.3 The file testdata feeds information into the file called program
44.4 Observe the contents of the file called xyz.txt using MORE.
44.5 Observe a directory listing that is four screens long.
A.
44.1 ls > lpr
44.2 cat efg.txt >> abc.txt
44.3 program < testdata
44.4 more < xyz.txt
44.5 ls > dirsave | more

45. Q. How do you estimate file space usage


A. Use du command (Summarize disk usage of each FILE, recursively for
directories.) Good to use arguments du -hs
(-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
(-s, --summarize display only a total for each argument)

46. Q. How can you see all mounted drives?


A. mount -l
47. Q. How can you find a path to the file in the system?
A. locate file_name (locate - list files in databases that match a pattern)

48. Q. What Linux HotKeys do you know?


A. Ctrl-Alt-F1 Exit to command prompt
Ctrl-Alt-F7 or F8 Takes you back to KDE desktop from command prompt
Crtl-Alt-Backspace Restart XWindows
Ctrl-Alt-D Show desktop

49. Q. What can you tell about the tar Command?


A. The tar program is an immensely useful archiving utility. It can combine
an entire directory tree into one large file suitable for transferring or
compression.

50. Q. What types of files you know?


A. Files come in eight flavors:
Normal files
Directories
Hard links
Symbolic links
Sockets
Named pipes
Character devices
Block devices

51. Q. How to copy files from on PC to another on the same network


A. Use the following command:scp yur_file you_login@your_IP
example: copy .conf file from your PC to alex computer-
scp /etc/X11/xorg.conf alex@10.0.10.169:

52. Q. Please describe information below:

-rw-rw-r-- 1 dotpc dotpc 102 Jul 18 2003 file.buf


drwxr-xr-x 9 dotpc dotpc 4096 Oct 21 09:34 bin
lrwxrwxrwx 1 dotpc dotpc 20 Mar 21 15:00 client -> client-2.9.5
drwxrwxr-x 11 dotpc dotpc 4096 Sep 2 2005 client-2.8.9
drwxrwxr-x 7 dotpc dotpc 4096 Dec 14 12:13 data
drwxr-xr-x 12 dotpc dotpc 4096 Oct 21 09:41 docs
drwxr-xr-x 5 dotpc dotpc 4096 Dec 7 14:22 etc
drwxr-xr-x 11 dotpc dotpc 4096 Mar 21 15:54 client-2.9.5
-rw-r--r-- 1 dotpc dotpc 644836 Mar 22 09:53 client-2.9.5.tar.gz

A. This is a result of command $ls -l


we have two files, 6 directories and one link to client-2.9.5 directory.
There is number of files in every directory, size and data of last change.
53. Q. If you would like to run two commands in sequence what operators you can
use?

A. ; or && the difference is:


if you separate commands with ; second command will be run automatically.
if you separate commands with && second command will be run only in the case
the first was run successfully.

54. Q. How you will uncompress the file?


A. Use tar command (The GNU version of the tar archiving utility):
tar -zxvf file_name.tar.gz

55. Q.How do you execute a program or script, my_script in your current directoty?
A. ./my_script

56. Q.How to find current time configuration in the file my_new.cfg


A. grep time my_new.cfg
Grep searches the named input files (or standard input if
no files are named, or the file name - is given) for lines
containing a match to the given pattern.

Q. What does grep() stand for?


A. General Regular Expression Parser.

57. Q. What does the top command display?


A. Top provides an ongoing look at processor activity in real
time. It displays a listing of the most CPU-intensive
tasks on the system, and can provide an interactive inter
face for manipulating processes. (q is to quit)

58. Q. How can you find configuration on linux?


A. by using /sin/ifconfig
If no arguments are given, ifconfig displays the status of the cur-
rently active interfaces. If a single interface argument is given, it displays the status
of the given interface only; if a single -a argu-
ment is given, it displays the status of all interfaces, even those
that are down. Otherwise, it configures an interface.

59. Q. How to find difference in two configuration files on the same server?
A. Use diff command that is compare files line by line
diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf

60. Q. What is the best way to see the end of a logfile.log file?
A. Use tail command - output the last part of files
tail -n file_name ( the last N lines, instead of the last 10 as default)
No comments: Links to this post
Labels: Linux, Unix
Linux Interview Question
What is SELinux?
What is the most graceful way to get to run level single user mode?
Write a command to find all of the files which have been accessed within the last 10
days.
How do I find whether a parameter exists in the request object?
What does Security-enhanced Linux give me that standard Linux cant?
What can you type at a command line to determine which shell you are using?
In order to display the last five commands you have entered using the fc command,
you would type?
What command should you use to check your filesystem?
What file defines the levels of messages written to system log files?
What account is created when you install Linux?
What daemon is responsible for tracking events on your system?
Where is standard output usually directed?
What utility can you use to show a dynamic listing of running processes?
Who owns the data dictionary?
Compare Linux credit based algorithm with other scheduling algorithms?
What is the main advantage of creating links to a file instead of copies of the file?
What is LILO?
What is CVS?
What is NFS? What is its job?
In Linux OS, what is the file server?
What are the techniques that you use to handle the collisions in hash tables?
What is the major advantage of a hash table?
What is Write Command ?
Why You Shouldnt Use the root Login?
How big should the swap-space partition be?
Which field is used to define the users default shell?
When you create a new partition, you need to designate its size by defining the
starting and ending?
No comments: Links to this post
PL/SQL Interview Question
How do you convert a date to a string?
What is an aggregate function?
What is the dual table?
What are cursors? Distinguish between implicit and explict cursors?
Explain how cursors are used by Oracle?
What is PL/SQL? Describe the block structure of PL/SQL?
What is a nested subquery?
What are the various types of queries ?
Which of the following is not a schema object : Index, table, public synonym, trigger
and package ?
What is dynamic sql in oracle?
What is the difference between a package, procedure and function
What is the difference between delete, drop and truncating a table
How many triggers are supported in Oracle
Are you aware of FLASHBACK concept ? What is it?
Describe oracles logical and physical structure?
What is data dictionary
What is the use of control files
How would store XML data in table ? What data type would be used for the
columns?
Difference between post and commit?
Difference between commit and rollback?
What are savepoints?
Difference between a View and Synonym
How would you fetch system date from oracle
What is the difference between primary key, unique key, foreign key?
What is the difference between NO DATA FOUND and %NOTFOUND
What is cursor for loop
What are cursor attributes
What will you use in Query : IN or EXISTS? Why
Explain the difference between a data block, an extent and a segment.
What's the difference between logical and physical I/O?
What is an anonymous block?
What is a PL/SQL collection?
How do I find the overall database size?
The biggest portion of a database's size comes from the datafiles. To find out how
many megabytes are allocated to ALL datafiles:

select sum(bytes)/1024/1024 "Meg" from dba_data_files;

To get the size of all TEMP files:

select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;

To get the size of the on-line redo-logs:

select sum(bytes)/1024/1024 "Meg" from sys.v_$log;

Putting it all together into a single query:

select a.data_size+b.temp_size+c.redo_size "total_size"

from ( select sum(bytes) data_size


from dba_data_files ) a,
( select nvl(sum(bytes),0) temp_size
from dba_temp_files ) b,
( select sum(bytes) redo_size
from sys.v_$log ) c;
No comments: Links to this post
Labels: Oracle FAQ, Oracle Interview Questions With Answer
Can one resize tablespaces and data files?
Add more files to tablespaces
To add more space to a tablespace, one can simply add another file to it. Example:
ALTER TABLESPACE USERS ADD DATAFILE '/oradata/orcl/users1.dbf' SIZE 100M;
Resize datafiles
One can manually increase or decrease the size of a datafile from Oracle 7.2 using
the following command:
ALTER DATABASE DATAFILE 'filename2' RESIZE 100M;
Because you can change the sizes of datafiles, you can add more space to your
database without adding more datafiles. This is beneficial if you are concerned
about reaching the maximum number of datafiles allowed in your database.
Manually reducing the sizes of datafiles allows you to reclaim unused space in the
database. This is useful for correcting errors in estimations of space requirements.
Extend datafiles
Also, datafiles can be allowed to automatically extend if more space is required.
Look at the following commands:
CREATE TABLESPACE pcs_data_ts
DATAFILE 'c:ora_appspcspcsdata1.dbf' SIZE 3M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
DEFAULT STORAGE ( INITIAL 10240
NEXT 10240
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0)
ONLINE
PERMANENT;
ALTER DATABASE DATAFILE 1 AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED;
No comments: Links to this post
Labels: Oracle FAQ, Oracle Interview Questions With Answer
How does one see the uptime for a database?
Look at the following SQL query:
SELECT to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') "DB Startup Time"
FROM sys.v_$instance;
Marco Bergman provided the following solution:
SELECT to_char(logon_time,'Dy dd Mon HH24:MI:SS') "DB Startup Time"
FROM sys.v_$session
WHERE sid=1 /* this is pmon */
/
Tarun Dua provided the following solution:
Check on operating system level when the PMON process was stated (UNIX/ LINUX
only):
ps -ef | grep pmon
Users still running on Oracle 7 can try one of the following queries:
column STARTED format a18 head 'STARTUP TIME'

select C.INSTANCE,
to_date(JUL.VALUE, 'J')
|| to_char(floor(SEC.VALUE/3600), '09' )
|| ':'
-- || substr (to_char(mod(SEC.VALUE/60, 60), '09'), 2, 2)
|| substr (to_char(floor(mod(SEC.VALUE/60, 60)), '09'), 2, 2)
|| '.'
|| substr (to_char(mod(SEC.VALUE, 60), '09'), 2, 2) STARTED
from SYS.V_$INSTANCE JUL,
SYS.V_$INSTANCE SEC,
SYS.V_$THREAD C
where JUL.KEY like '%JULIAN%'
and SEC.KEY like '%SECOND%';
select to_date(JUL.VALUE, 'J')
|| to_char(to_date(SEC.VALUE, 'SSSSS'), ' HH24:MI:SS') STARTED
from SYS.V_$INSTANCE JUL,
SYS.V_$INSTANCE SEC
where JUL.KEY like '%JULIAN%'
and SEC.KEY like '%SECOND%';
select to_char(to_date(JUL.VALUE, 'J') + (SEC.VALUE/86400), -- Return a DATE
'DD-MON-YY HH24:MI:SS') STARTED
from V$INSTANCE JUL,
V$INSTANCE SEC
where JUL.KEY like '%JULIAN%'
and SEC.KEY like '%SECOND%';
No comments: Links to this post
Labels: Oracle FAQ, Oracle Interview Questions With Answer
Can one rename a tablespace?
From Oracle 10g Release 1, users can rename tablespaces. Example:
ALTER TABLESPACE ts1 RENAME TO ts2;
However, you must adhere to the following restrictions:
COMPATIBILITY must be set to at least 10.0.1
Cannot rename SYSTEM or SYSAUX
Cannot rename an offline tablespace
Cannot rename a tablespace that contains offline datafiles
For older releases, use the following workaround:
Export all of the objects from the tablespace
Drop the tablespace including contents
Recreate the tablespace
Import the objects
No comments: Links to this post
Labels: Oracle FAQ, Oracle Interview Questions With Answer
Can one rename a database user (schema)?
No, this is listed as Enhancement Request 158508. Workaround:

-->Do a user-level export of user A


-->create new user B
-->import system/manager fromuser=A touser=B
-->drop user A
Puzzles For Freshers [1]
Arjan, Bhuvan, Guran and Lakha had 90, 50, 55 and 45 sheep respectively.

Assume that Arjan, Bhuvan, Guran and Lakha had A, B, G and L sheep respectively.
As it is given that at the end each would have an equal number of sheep, comparing
the final numbers from the above table.

Arjan's sheep = Bhuvan's sheep


2A/3 = A/4 + 3B/4
8A = 3A + 9B
5A = 9B

Arjan's sheep = Guran's sheep


2A/3 = A/15 + B/5 + 4G/5
2A/3 = A/15 + A/9 + 4G/5 (as B=5A/9)
30A = 3A + 5A + 36G
22A = 36G
11A = 18G

Arjan's sheep = Lakha's sheep


2A/3 = A/60 + B/20 + G/5 + L
2A/3 = A/60 + A/36 + 11A/90 + L (as B=5A/9 and G=11A/18)
2A/3 = A/6 + L
A/2 = L
A = 2L

Also, it is given that Guran had ten more sheep than Lakha.
G = L + 10
11A/18 = A/2 + 10
A/9 = 10
A = 90 sheep

Thus, Arjan had 90 sheep, Bhuvan had 5A/9 i.e. 50 sheep, Guran had 11A/18 i.e. 55
sheep and Lakha had A/2 i.e. 45 sheep.

Consider a number 235, where last digit is the sum of first two digits i.e. 2 + 3= 5.

How many

Find the smallest number such that if its rightmost digit is placed at its left end, the
new number so formed is precisely 50% larger than the original number.
Answer

The answer is 285714.

If its rightmost digit is placed at its left end, then new number is 428571 which is
50% larger than the original number 285714
The simplest way is to write a small program. And the other way is trial and error !!!
Two identical pack of cards A and B are shuffled throughly. One card is picked from A
and shuffled with B. The top card from pack A is turned up. If this is the Queen of
Hearts, what are the chances that the top card in B will be the King of Hearts?

Answer 52 / 2703

There are two cases to be considered.

CASE 1 : King of Hearts is drawn from Pack A and shuffled with Pack B

Probability of drawing King of Hearts from Pack A = 1/51 (as Queen of Hearts is not
to be drawn)
Probability of having King of Hearts on the top of the Pack B = 2/53

So total probability of case 1 = (1/51) * (2/53) = 2 / (51 * 53)

CASE 2 : King of Hearts is not drawn from Pack A

Probability of not drawing King of Hearts from Pack A = 50/51 (as Queen of Hearts is
not to be drawn)
Probability of having King of Hearts on the top of the Pack B = 1/53

So total probability of case 2 = (50/51) * (1/53) = 50 / (51 * 53)

Now adding both the probability, the required probability is


= 2 / (51 * 53) + 50 / (51 * 53)
= 52 / (51 * 53)
= 52 / 2703
= 0.0192378

There is a 4-character code, with 2 of them being letters and the other 2 being
numbers.

How many maximum attempts would be necessary to find the correct code? Note
that the code is case-sensitive.
Answer

The maximum number of attempts required are 16,22,400

There are 52 possible letters - a to z and A to Z, and 10 possible numbers - 0 to 9.


Now, 4 characters - 2 letters and 2 numbers, can be selected in 52*52*10*10 ways.
These 4 characters can be arranged in 4C2 i.e. 6 different ways - the number of
unique patterns that can be formed by lining up 4 objects of which 2 are
distinguished one way (i.e. they must be letters) and the other 2 are distinguished
another way (i.e. they must be numbers).

Consider an example : Let's assume that @ represents letter and # represents


number. the 6 possible ways of arranging them are : @@##, @#@#, @##@,
#@@#, #@#@, ##@@

Hence, the required answer is


= 52*52*10*10*6
= 16,22,400 attempts
= 1.6 million approx.

How many ways are there of arranging the sixteen black or white pieces of a
standard international chess set on the first two rows of the board?

Given that each pawn is identical and each rook, knight and bishop is identical to its
pair.

Answer 6,48,64,800 ways

There are total 16 pieces which can be arranged on 16 places in 16P16 = 16! ways.
(16! = 16 * 15 * 14 * 13 * 12 * ..... * 3 * 2 * 1)

But, there are some duplicate combinations because of identical pieces.


There are 8 identical pawn, which can be arranged in 8P8 = 8! ways.
Similarly there are 2 identical rooks, 2 identical knights and 2 identical bishops.
Each can be arranged in 2P2 = 2! ways.
Hence, the require answer is
= (16!) / (8! * 2! * 2! * 2!)
= 6,48,64,800

******************************************************************

A person with some money spends 1/3 for cloths, 1/5 of the remaining for food and
1/4 of the remaining for travel. He is left with Rs 100/-

How much did he have with him in the begining?

Answer Rs. 250/-

Assume that initially he had Rs. X


He spent 1/3 for cloths =. (1/3) * X
Remaining money = (2/3) * X

He spent 1/5 of remaining money for food = (1/5) * (2/3) * X = (2/15) * X


Remaining money = (2/3) * X - (2/15) * X = (8/15) * X

Again, he spent 1/4 of remaining maoney for travel = (1/4) * (8/15) * X = (2/15) * X
Remaining money = (8/15) * X - (2/15) * X = (6/15) * X

But after spending for travel he is left with Rs. 100/- So


(6/15) * X = 100
X = 250

Grass in lawn grows equally thick and in a uniform rate. It takes 24 days for 70 cows
and 60 days for 30 cows to eat the whole of the grass.

How many cows are needed to eat the grass in 96 days?

Answer 20 cows

g - grass at the beginning


r - rate at which grass grows, per day
y - rate at which one cow eats grass, per day
n - no of cows to eat the grass in 96 days

From given data,


g + 24*r = 70 * 24 * y - A
g + 60*r = 30 * 60 * y - B
g + 96*r = n * 96 * y - C
Solving for (B-A),
(60 * r) - (24 * r) = (30 * 60 * y) - (70 * 24 * y)
36 * r = 120 * y - D

Solving for (C-B),


(96 * r) - (60 * r) = (n * 96 * y) - (30 * 60 * y)
36 * r = (n * 96 - 30 * 60) * y
120 * y = (n * 96 - 30 * 60) * y [From D]
120 = (n * 96 - 1800)
n = 20

Hence, 20 cows are needed to eat the grass in 96 days.

There is a safe with a 5 digit number as the key. The 4th digit is 4 greater than the
second digit, while the 3rd digit is 3 less than the 2nd digit. The 1st digit is thrice
the last digit. There are 3 pairs whose sum is 11.

Find the number.

Answer 65292

As per given conditions, there are three possible combinations for 2nd, 3rd and 4th
digits. They are (3, 0, 7) or (4, 1, 8) or (5, 2, 9)

It is given that there are 3 pairs whose sum is 11. All possible pairs are (2, 9), (3, 8),
(4, 7), (5, 6). Now required number is 5 digit number and it contains 3 pairs of 11.
So it must not be having 0 and 1 in it. Hence, the only possible combination for 2nd,
3rd and 4th digits is (5, 2, 9)

Also, 1st digit is thrice the last digit. The possible combinations are (3, 1), (6, 2) and
(9, 3), out of which only (6, 2) with (5, 2, 9) gives 3 pairs of 11. Hence, the
answer is 65292.

Anda mungkin juga menyukai