Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create index on existing table Oracle

Is it safe to create an index on an existing table in oracle?

Like this:

CREATE INDEX table_sample_ix03
      ON table_sample
(
  col4,
  col22
)
TABLESPACE data
STORAGE
(
  INITIAL        10M    NEXT          2M
  MINEXTENTS      1     MAXEXTENTS  100
  PCTINCREASE     0
)
;
like image 925
Michael Avatar asked Aug 10 '11 10:08

Michael


People also ask

Can we CREATE INDEX on existing table in Oracle?

Yes. But if possible, you should do it while no one is updating the table, because they would suffer performance-wise (it is still safe to do it anyway, there will be no data corruption).

How do you create an index on an existing table?

To create a new index for a table, you use the CREATE INDEX statement as follows: CREATE INDEX index_name ON table_name(column1[,column2,...]) Second, specify the name of the table followed by one or more indexed columns surrounded by parentheses.

Can we CREATE INDEX on table?

The CREATE INDEX statement is used to create indexes in tables. Indexes are used to retrieve data from the database more quickly than otherwise. The users cannot see the indexes, they are just used to speed up searches/queries.

How many indexes can be created on a table Oracle?

You can also create an index for a cluster. You can create a composite index on multiple columns up to a maximum of 32 columns. A composite index key cannot exceed roughly one-half (minus some overhead) of the available space in the data block.


3 Answers

The ONLINE clause is recommended when you create the index while DML queries are being run on the table. See http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5010.htm

Example:

CREATE  INDEX "MYINDEX" ON "MYTABLE" ("MYCOLUMN")  ONLINE;
like image 150
Pierluigi Vernetto Avatar answered Oct 14 '22 11:10

Pierluigi Vernetto


Yes. But if possible, you should do it while no one is updating the table, because they would suffer performance-wise (it is still safe to do it anyway, there will be no data corruption).

like image 43
Thilo Avatar answered Oct 14 '22 13:10

Thilo


Yes. Why wouldn't it be?

I can only think of possible performance issues just after issuing the command. If the table is very large, the indexing can take some time but other than that, it should be fine.

like image 24
deltaforce2 Avatar answered Oct 14 '22 11:10

deltaforce2