Creating UPI/USI on Primary Key coloumn

Database

Creating UPI/USI on Primary Key coloumn

ct tmp(

a int not null,

b int,

primary key(a))

unique primary index(a);

ct tmp(

a int not null,

b int,

primary key(a))

unique index(a)

When i executed the above two sql statements it is giving the error "3519:  Two indexes with the same columns."

Please help me on this

Thanks,

Rakesh

3 REPLIES
Junior Supporter

Re: Creating UPI/USI on Primary Key coloumn

Rakesh

Primary keys are a logical, not physical, and they are implemented as UPI's or USI's. In your case, the PRIMARY KEY clause makes TD create a UPI on the column 'a', and then a second time when it finds the PRIMARY INDEX clause... with the error.

HTH.

Cheers.

Carlos.

Re: Creating UPI/USI on Primary Key coloumn

Thanks Carlos for your response.

I am executing it in TD 13.10 version in which PI is optional.I think till TD 12 version,PI is implicitly created if we dont define it explicitly.from TD13 onwards we have NOPI concept.

so why it is taking column "a" as PI even i didn't mention it explicitly.

Thanks

Rakesh.

Enthusiast

Re: Creating UPI/USI on Primary Key coloumn

As documentation says...

"If you define a table and you do not specify a PRIMARY INDEX clause, NO PRIMARY

INDEX clause, PRIMARY KEY constraint, or UNIQUE constraint, the default behavior is for

the system to create the table using the first column as the nonunique primary index. (If you

prefer that the system creates a NoPI table without a primary index, use DBS Control to

change the value of the PrimaryIndexDefault General field.)"

HTH

--Sen