When I try to add a sorted ASC index on the field MyId the oracle sql developer tool says:
Index MyIdSortedIndex is defined identically to constraint PK_MyTable
CREATE TABLE MyTable
( "MyId" NVARCHAR2(50),
"DESCRIPTION" NVARCHAR2(200),
CONSTRAINT "PK_MyTable" PRIMARY KEY ("MyId")
)
How can I set a sorted ASC index on my tables Primary Key MyId in Oracle ?
It is telling you that you don’t need a new index, because you already have an index called “PK_MyTable” on “MyId” in ascending order. When you add a primary key constraint to a table Oracle automatically adds an index of the same name to help enforce it, indexing the columns of the constraint in ascending order (since ascending is the default direction).
If you don’t want to use the index Oracle created automatically you can do this:
Since your index already exists when the primary key is added Oracle will use that instead of creating its own.