Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> non unique Index and Primary Key on same column. Is it needed?

non unique Index and Primary Key on same column. Is it needed?

From: <nn20002_at_netscape.net>
Date: Tue, 24 Aug 2004 00:00:32 -0400
Message-ID: <12C9225E.54F37FF0.00200FF8@netscape.net>


Hi ,

I saw a script creating a table and then an index on one of the column. But after that they alter the table to create an Primary Key on the same column. Why is that needed. I am of the assumption that when you create a primary key, the system automatically creates an index to enforce it. The same key could be used as an index also. Then why they create an extra index. example

CREATE TABLE MACHINE(

        MACHINE_KEY INTEGER  NOT NULL ,
        USABILITY_SETTINGS_KEY INTEGER  NULL ,
        MACHINE_ID VARCHAR2(256)  NULL ,
        NAME VARCHAR2(50)  NULL ,
        STATUS VARCHAR2(25)  NULL 
      

);
    

CREATE INDEX MACHINE_INDEX ON MACHINE(
        MACHINE_KEY
);
    

ALTER TABLE MACHINE
    ADD PRIMARY KEY ( MACHINE_KEY );        I would appreciate if you could help me. Sorry if it is a silly question. Thanks
nagarajan



Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer Search from anywhere on the Web and block those annoying pop-ups. Download now at http://channels.netscape.com/ns/search/install.jsp



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Mon Aug 23 2004 - 22:56:12 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US