DESC in primary key
DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: DESC in primary key

Hybrid View

  1. #1
    Join Date
    Mar 2001
    Location
    AL
    Posts
    18

    DESC in primary key

    Does anyone know of a way to have a DESC function on a column in a primary key? Below is what I've tried and the results:


    create table tab1 (col1 number, col2 number, col3 number);

    alter table tab1 add constraint pk1 primary key (col1) using index
    (create index indx1 on tab1 (col1 desc));

    alter table tab1 add constraint pk1 primary key (col1) using index
    *
    ERROR at line 1:
    ORA-01418: specified index does not exist


    I've also tried:

    create unique index indx1 on tab1 (col1 desc);
    alter table tab1 add constraint pk1 primary key (col1) using index indx1;

    with the same results.

    Any ideas?

    Thanks,
    J

  2. #2
    Join Date
    May 2002
    Posts
    2,645
    SQL> create table tab1
    2 (col1 number,
    3 col2 number,
    4 col3 number);

    Table created.

    SQL> create index indx1 on tab1 (col1 desc);

    Index created.

  3. #3
    Join Date
    Mar 2001
    Location
    AL
    Posts
    18
    Thanks. I knew I could do it that way, but I was specifically trying to get a "Primary Key". Technically, there's no difference, but some of our scripts are looking for the primary key constraints (where constraint_type = 'P'), and we were trying to keep from rewriting our scripts.


    J

  4. #4
    Join Date
    Jan 2001
    Posts
    3,131
    You do not alter the database to conform to your code. The data will be there long after your app has come and gone. This is a perfect example of why most DBA's want to shoot developers!

    MH
    Last edited by Mr.Hanky; 02-25-2004 at 04:09 PM.
    I remember when this place was cool.

  5. #5
    Join Date
    Mar 2001
    Location
    AL
    Posts
    18
    I would normally agree, but in this case, I'm the DBA and developer. It's not a big deal, but if it was possible I would rather keep the database consistent, and there is only one table out of 300 that I'll have without a true PK.

  6. #6
    Join Date
    Jan 2001
    Posts
    3,131
    Well, you should still find a developer to shoot!
    Just on priciple.



    MH
    I remember when this place was cool.

  7. #7
    Join Date
    Mar 2001
    Location
    AL
    Posts
    18
    Works for me! But can it be more than one...

  8. #8
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Originally posted by Mr.Hanky
    Well, you should still find a developer to shoot!
    Just on priciple.



    MH
    Oh no, I'm condemmed to suicide.

  9. #9
    Join Date
    Jan 2003
    Location
    india
    Posts
    175
    i just want to know
    what is advantage of building the index as descending?

    -Raja

  10. #10
    Join Date
    Aug 2003
    Location
    Virginia
    Posts
    392

    Shooting Develinterlopers

    Cheer up DaPi, at least you can say it is on your terms

    Has Mr. Hanky always been this way, what with wanting to shoot developers at will...?

    Rick
    Rick

    Sigh.....those were the days my friend, I thought they'd never end.
    I too remember when this place was coo.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width