Primary Key Information [message #19675] |
Wed, 03 April 2002 08:36 |
Ray
Messages: 58 Registered: January 2000
|
Member |
|
|
I have a question concerning a multiple column primary key. I have a table that contains 14 columns and would like to set the primary key to be the first three columns. These columns do not reference other tables but the combination of these will be unique and not null. Using version 8.1.7 on a Sun box. I am looking for the actual create table script in SQL. Have searched Oracle home site and can't find any examples right now. Example follows:
**Note - Col 1,2,3 to be the PK
CREATE TABLE tablea
(column1 varchar2(6) not null,
column2 integer not null,
column3 varchar2(6) not null,
column4 varchar2(10) ,
.
.
.column14 varchar2(6))
|
|
|
Re: Primary Key Information [message #19678 is a reply to message #19675] |
Wed, 03 April 2002 09:10 |
Jill
Messages: 6 Registered: August 1999
|
Junior Member |
|
|
This is a sql example that I have used:
CREATE TABLE tablea (
a DATE NOT NULL,
b VARCHAR2(10) NOT NULL,
c VARCHAR2(10) NOT NULL,
d NUMBER(1),
e NUMBER(2),
f NUMBER(3) )
LOGGING
TABLESPACE x
INITRANS 1
MAXTRANS 255
PCTFREE 5
PCTUSED 95
ALTER TABLE a ADD (
CONSTRAINT primary_key
PRIMARY KEY (a,
b,
c)
USING INDEX
INITRANS 2
MAXTRANS 255
PCTFREE 10
TABLESPACE y
You can put storage parm clauses in there, or take the defaults of the tablespaces x and y.
|
|
|
|