Archive | February, 2008

Function Based Index

Posted on 29 February 2008 by Praveen

Function Based Index

Why do you need a Function Based Index?

Considering the example of traditional “EMP” table, if you need to query the table based on emp_name then the query could be

SELECT * FROM EMP WHERE EMP_NAME =’JOE’;
Instead of making the full table scan on the above query you can create a non-unique index on the field “EMP_NAME”. By creating the index the above query makes use of index while execution.

if your requirement is to change the above query to

SELECT * FROM EMP WHERE UPPER(EMP_NAME)=’JOE’;

Since an function has been applied on EMP_NAME column, oracle will not utilize the index in executing the above query which will result in hampering the performance of your query. So Oracle has introduced Function Based Index to encounter the above problem.
Continue Reading

Comments (0)

Tags: , , , , , ,

Calculate Size of Tablespace, Free space of a Tablespace

Posted on 26 February 2008 by Praveen

How to find the free space in a tablespace ? How to find the free space in undo tablespace? how to find size of System tablespace ?

Let us explore the above things with three data dictionary views

DBA_TABLESPACES
DBA_DATA_FILES
DBA_FREE_SPACE

DBA_TABLESPACES dictionary view provides the list of all tablespaces present in the database.

DBA_DATA_FILES dictionary view provides the list of all physical data files and their size. DBA_DATA_FILES also provides the path of the data files in the system.Each data file is associated with only one tablespace. But a tablespace is associated with more than one data file.”Bytes” column present in DBA_DATA_FILES denote the total bytes allocated to a data file.
Continue Reading

Comments (1)

Tags: , , , ,

Constraints and Data dictionary information

Posted on 25 February 2008 by Praveen

There are two data dictionary views that provide you detailed information about constraints. They are USER_CONSTRAINTS and USER_CONS_COLUMNS. These dictionary views are highly helpful to view the referntial integrity constraints information.

You can add a constraint to a table at the time of its creation or the constraint can be applied on a table by using ALTER TABLE statement.A table can have many constraints. For every constraint in a table there is a single row in USER_CONSTRAINTS table that describes that Particular constraint, including the table name to which that constraint is applied.

There are Five types of Constraints

1. NOT NULL CONSTRAINT
2. CHECK CONSTRAINT
3. Primay Key
4. Unique key Constraint
5. Foreign Key Constraint

Continue Reading

Comments (0)

How to Encrypt data in Oracle database 10g

Posted on 22 February 2008 by Praveen

How you ever been given the job of Protecting data in a database ? Is there any sensitive information which should not be shown to the developers but the should be accessible to them ? Do you want to store password information in the database. If so, Oracle provides DBMS_CRYPTO package to Encrypt the information before storing the data in to the database.

DBMS_CRYPTO PACKAGE provides a function called hash which converts the data in to MD5 Hash.

By default execute permissions are not available on dbms_crypto package to all users.

Login as Sys it execute the following command

GRANT execute ON dbms_crypto TO Your_username;

Continue Reading

Comments (2)

Connect to Oracle Database from .Net

Posted on 22 February 2008 by Praveen

There exist four main methodologies to access Oracle database from a .NET application:

  • Microsoft’s .NET data provider for ODBC (or ODBC.NET)
  • Microsoft’s .NET data provider for OLEDB (or OLEDB.NET)
  • Microsoft’s .NET data provider for Oracle
  • Oracle’s data provider for .NET (or ODP.NET)

There are several ways to connect to Oracle database from within .NET. Each of those methods having its own advantages and disadvantages. But in this post we concentrate only on how to connect to Oracle database from .Net. It is necessary to have Oracle 8i, 9i or Oracle 10g client installed on your system.

Proper Connection descriptors are to be configured on your system to connect to Oracle. The connection descriptors for oracle lies in the file called TNSNAMES.ORA . TNS stands for Transparent Network Substrate. You can locate the tnsname.ora file in your system at the Path <oracle_home>/network/admin/tnsname.ora. If it is already configured and you are able to connect to Oracle 9i database thru SQL* PLUS , then there is no need to disturb this file.
An example of connection descriptor in my system is

Continue Reading

Comments (2)

Tags: , , , , ,

Bitmap Indexes

Posted on 16 February 2008 by Praveen

Generally we deal with two types of indexes . One is B-Tree Indexes and the other is Bitmap indexes.B-tree indexes have been traditional favorites for Oltp databases.if we classify the tables based on the underlying data, there are two types 1. read write tables (Huge Inserts ,Update and Deletes) 2. Read only tables - Table which are almost having static data. Aggregated tables, Dimensional tables, Fact tables, Pre Aggregation temp tables are some of the examples of Read only tables.

Bitmap indexes are highly compressed and usually take very less space when compared to B-tree indexes and are extensively used in data warehouses.

When a bitmap index can be created on a table?

Bitmap indexes are the most suitable for columns having very few unique values (very low cardinality). Ideally to choose the bitmap indexes as the right choice for a column the cardinality should be less than or equal to 0.05%.

Table should have no insert, update , delete or very few dml statements can act as good choice for bitmap indexes.

create bitmap index Person_state on person (state);

The internal storage format of a bitmap index

Row Region North East West South
1 Ohio 1 0 0 0
2 Texas 0 1 0 0
3 New mexico 0 0 1 0
4 Pennsylvan 0 0 1 0
5 Atlanta 0 0 0 1
6 South caro 1 0 0 0

Advantage of Bitmap Indexes

Due to the nature of highly compressed structure of an bitmap index, Data can be accessed much faster than traditional B-tree indexes.

Bitmap index represent a good trade-off between disk usage and Cpu cost. A bitmap index requires more cpu cycles to decompress but requires less amount of work from disk I/O.

Disadvantages of Bitmap Indexes

Bitmap Indexes are traditionally meant to be developed for data warehouses. A modification to a bitmap index requires more work than a modification to b-tree indexes.

Deadlock’s On bitmap indexes

Bitmap indexes are not suitable for large concurrent single row Dml operations. Though bitmap indexes can be used in this form

insert into <bitmap_index_table> select * from <table> .

If there are 3 or more sessions simultaneously working to insert into a table which is bitmap indexed a dead lock situation can occur with an error message shown below

ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource

And an other error you can face with bitmap index is

ORA-28611: bitmap index is corrupted - see trace file for diagnostics

Cause: Bitmap index might have corrupted due to validation

Action: Rebuild the Bitmap index. Like B-tree index you cannot build a bitmap index online. Try alter index <bitmap_index_demo> rebuild;

Comments (1)

Tags: , , , ,

Relational Databases and Sql - Learn Sql :Series 1

Posted on 16 February 2008 by Praveen

What is a database ?

A Database is a collection of Organized data belonging to some organization or an Organizational process.Say if you are storing your friends contacts and organizing them in some fashion , then you are said to have an contacts database. As Long as you’re collecting and storing the data in an Organized form for a specific purpose , you have got a databse. Mainly we are going to discuss of Operational databases.

Operational databases are the backbone of many companies and Organizations throughout the world today. This type of database is primarily used to collect,store, modify and maintain data on a day-to-day basis. An example of Operational database could be retail stores, Manufacturing companies, Hospitals, clinics and Publishing houses.

Continue Reading

Comments (0)

Tags: , , , ,

Oracle Partitioning - Partition Types

Posted on 14 February 2008 by Praveen

Oracle Partitioning is the splitting of data groups belonging to the same table  into separate physical areas using separate partition tablespaces. Partitions can actually coexist in the same physical data file, but the same effect of partitioning might not be achieved. Separate partitions can be accessed in Parallel or individually or in groups.

How can partitioning improve the performance of Sql queries ?
Partitioning can be used to break large tables into smaller subsets.Processing of small subsets individually or in parallel ways is much faster than executing serial procession on large data sets. Partitioning is the most useful in very large database applications.

Benefits of Oracle Partitioning

  • Parallel processing is a way of splitting data into separately located physical files. Separating table and index datafiles onto separate disks in a nonpartitioned database is a form of simple partitioning. It is often highly beneficial to read index and data spaces from separate locations because table and index physical spaces are often read almost in parallel.Partitioning can enhance the benefits of splitting datafiles.
  • Different partitions within the same table can have different physical storage structures. Different partitions within a table can even be
    both read-write and read only, perhaps allowing separation of archived and current data.
  • Backup, recovery, and utility usage (SQL*Loader, Export, andImport) can utilize parallel processing and activities on individual partitions.

Continue Reading

Comments (5)

Tags: ,

Dual Table In Oracle

Posted on 14 February 2008 by Praveen

The DUAL Table

Why do you need a DUAL TABLE in oracle ?

Dual Table is used  to solve simple expressions  from a query which do not involve data retrieval from a table . “Select Statement” which works with a basic syntax of[select {column list} from table ], a dummy table has been introduced in oracle called “DUAL“. A DUAL Table in oracle consists of only one row and one column. So if any expression is computed by using this table , it will result in only one row. The same functionality of DUAL Table can be achieved by creating a table with one row and a column.

Every DML statement creates an implicit cursor. A cursor is an area in memory allocated for the results of an SQL statement. SELECT statements require a source table for the implicit cursor to operate on. The DUAL table is required as a dummy table, to allow the SELECT statement to retrieve data not stored in a table, view, or other database object.The DUAL table acts as a temporary repository for the result of an expression. The result of the expression is selected from the DUAL table,

as in the following examples:

SELECT * FROM DUAL;

SELECT a.*, b.* FROM DUAL a, dif_typ b;

SELECT ‘Hello’||’world’ FROM DUAL;

SELECT 10 * 20 FROM DUAL;

The DUAL table also can be used to retrieve Oracle Database settings (constant, variable, or pseudocolumn) in a SELECT statement:

SELECT SYSDATE FROM DUAL;

SELECT USER FROM DUAL;

Comments (0)

Tags: , , ,

how to find obselete parameters in an oracle database 10g

Posted on 14 February 2008 by Praveen

Oracle has grown by leaps and bounds. Thousand’s of new features have been added from oracle 7.3 to oracle 11g . In this course some of the parameters are also deprecated. Instead if are using obselete parameters in init.ora they don’t have any significance. Inturn Oracle has Provided a dynamic view describing which parameters are obselete parameters and whether you have used them in init.ora  or not.

Below query is used to find out whether obselete parameters are configured in init.ora

SELECT ' parameter  - '||name||' is obsolete in this version of  database!'  para
FROM   sys.v_$obsolete_parameter
WHERE   isspecified = 'TRUE'
ORDER BY  1

Below query is used to find out all the Obselete parameters in your version of Oracle database

Select  *  from sys.v_$obselete_parameter

Comments (0)







Page 1 of 212»