Basic Oracle Concepts and Programming Question:
Download Job Interview Questions and Answers PDF
How To Rebuild an Index in Oracle?
Answer:
If you want to rebuild an index, you can use the "ALTER INDEX ... REBUILD statement as shown in the following SQL script:
SELECT index_name, table_name, uniqueness
FROM USER_INDEXES WHERE table_name = 'EMPLOYEES';
<pre>INDEX_NAME TABLE_NAME UNIQUENES
----------------------- --------------------- ---------
EMP_EMAIL_UK EMPLOYEES UNIQUE
EMP_EMP_ID_PK EMPLOYEES UNIQUE
EMP_DEPARTMENT_IX EMPLOYEES NONUNIQUE
EMP_JOB_IX EMPLOYEES NONUNIQUE
EMP_MANAGER_IX EMPLOYEES NONUNIQUE
EMP_NAME_IX EMPLOYEES NONUNIQUE</pre>
ALTER INDEX EMP_NAME_IX REBUILD;
Statement processed.
SELECT index_name, table_name, uniqueness
FROM USER_INDEXES WHERE table_name = 'EMPLOYEES';
<pre>INDEX_NAME TABLE_NAME UNIQUENES
----------------------- --------------------- ---------
EMP_EMAIL_UK EMPLOYEES UNIQUE
EMP_EMP_ID_PK EMPLOYEES UNIQUE
EMP_DEPARTMENT_IX EMPLOYEES NONUNIQUE
EMP_JOB_IX EMPLOYEES NONUNIQUE
EMP_MANAGER_IX EMPLOYEES NONUNIQUE
EMP_NAME_IX EMPLOYEES NONUNIQUE</pre>
ALTER INDEX EMP_NAME_IX REBUILD;
Statement processed.
Download Oracle Database Interview Questions And Answers
PDF
Previous Question | Next Question |
What Happens to the Indexes If a Table Is Recovered? | How To See the Table Columns Used in an Index? |