If we create a Unique index on a table. Index will not allow duplicate values.
Example:
CREATE TABLE SAMPLE12
(
ID INT ,
NAME VARCHAR(10),
TYPE_DESC VARCHAR(50)
)
Syntax:
CREATE UNIQUE INDEX <Index Name> ON <Table Name>
(<Column Name>)
Creating index on single
column:
CREATE UNIQUE INDEX IDX_SAMPLE12_UQ ON SAMPLE12 (ID)
Result:
Drop Index:
DROP INDEX SAMPLE12.IDX_SAMPLE12_UQ
Result:
Creating index on multiple column:
CREATE UNIQUE INDEX IDX_SAMPLE12_UQ ON
SAMPLE12 (ID,NAME)
Result:
No comments:
Post a Comment