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

Home -> Community -> Usenet -> c.d.o.misc -> Primary keys

Primary keys

From: Robert Diggle <rob_at_nospam.org>
Date: Sat, 8 Mar 2003 19:41:16 -0000
Message-ID: <yHraa.3411$EA6.561572@newsfep2-win.server.ntli.net>


Hi,

I am new to Oracle and would like some advice in creating primary keys. I have created a with the SQL syntax below.

I have a few of questions:

  1. When creating primary keys that are just numbers, should I just set the datatype to INTEGER or use LONG (if that works)? Also should I also define the precision?
  2. Is there a way to get the key to auto increment when inserting a new record?
  3. Should I create an index for this primary key in this case as I will be searching records using the primary key.

Regards,
Robert

CREATE INDEX student_dob
 ON student (dob);

CREATE INDEX student_gender
 ON student (gender);

CREATE INDEX student_surname
 ON student (surname);

ALTER TABLE student
 ADD (CONSTRAINT addr_stud FOREIGN KEY (homeaddress_id)  REFERENCES address (address_id),
 CONSTRAINT addr_stud2 FOREIGN KEY (termaddress_id)  REFERENCES address (address_id)
);
Received on Sat Mar 08 2003 - 13:41:16 CST

Original text of this message

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