- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add a unique index on the above table TAB1 for column Enrollment ID (ascending)?
An index is a lookup table that optimizes the searching of data. An index defined on any table can increase the query speed. The index can be built up on any column of the table and DB2 will generate a logical structure at backend. This will facilitate the search on the table using indexed columns effectively.
An index can be unique and non-unique. To create a new unique index at any table we can use below command.
CREATE UNIQUE INDEX ENROTAB1 ON TAB1 (ENROLLMENT_ID) ASC;
The CREATE UNIQUE INDEX reserved words are followed by the name of the unique index which we want to create.
The ON parameter is followed by the name of the table on which index has to be built and this is followed by the name of the column in that table.
We have an option to organize the data within the index in ascending or descending order. Accordingly, we can use parameter ACS for ascending and DESC for descending.
- How to create a DB2 table TAB1 with 4 columns, Student ID, Enrollment ID, Name and Age?
- How to add a new column Address in the above DB2 table TAB1?
- How will you add a constraint on above DB2 table TAB1 for ages between 3 to 16 years?
- How to add a unique id for an element in HTML?
- How to create a view on table TAB1 for column Name, age, enrollmentId & age > 10 years. >
- How to add a row compression to a DB2 table TAB1?
- How to find out all the indexes for a DB2 table TAB1?
- How to do a full & incremental MERGECOPY for a DB2 table TAB1?
- How to delete a DB2 table TAB1?
- How to create a table TAB2 having same attributes & columns as for table TAB1
- What happens if I will add a UNIQUE constraint on the same column for multiple times?
- How to create an ALIAS TAB2 for DB2 table TAB1?
- How add unique key to existing table (with non-unique rows)?
- How add a unique key constraint to a column of a table in a database using JDBC API?
- How to specify a unique id for an element in HTML?