Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread primary key of an integer column desc
Thu, Jan 24 2013 11:23 PMPermanent Link

Xiannong Chen

I have a table with an integer column as the primary index. I want to make it DESC sorting order. I don't see a way to change this using the db manager. I created a secondary index against the same column with DESC sorting order, when I have the " order by ... DESC" in sql, the query is very slow, it seems the secondary index is not used. Thanks, Paul
Fri, Jan 25 2013 4:07 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Xiannong Chen or Paul

Could you please post the SQL statement and the table structure
(fields/indexes) and someone in NG can help you

Eduardo


Fri, Jan 25 2013 2:10 PMPermanent Link

Xiannong Chen

Here is the SQL script to generate the column:
EXECUTE IMMEDIATE 'CREATE TABLE "bib"
(
"Ref_ID" INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"Authors" VARCHAR(250) COLLATE "UNI",
...

Here is the SQL script to generate the constraint:
EXECUTE IMMEDIATE 'ALTER TABLE "bib"
ADD CONSTRAINT "PrimaryKey" PRIMARY KEY ("Ref_ID")';

Thanks,
Paul
Sat, Jan 26 2013 4:16 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Xiannong


ElevateDB currently creates unidirectional indices.

What you need is to add a descending  index

CREATE INDEX "Downwards" ON "bib" ("RefID" DESC)

In EDBManager go to the table and in the left hand pane double click it, click Indexes and then select Create New Index in the Tasks panel.

You can then add an index or you can use the SQL above.


Roy Lambert [Team Elevate]
Sat, Jan 26 2013 10:17 AMPermanent Link

Xiannong Chen

Roy, Thank you. I remember with DBISAM, I can change the direction of primary index from ASC to DESC. It seems that is not possible in ElevateDB. Your suggestion works. Thanks, Paul
Image