|
Re: How I can to create foreing and primary keys? [message #371298 is a reply to message #371293] |
Sat, 30 September 2000 00:16 |
Rajendra
Messages: 23 Registered: September 2000
|
Junior Member |
|
|
pls try this..
suppose u have client table, u can set primary key by the sql code like this-
create table client(
cl_code number(7) constraint cl_prim primary key,
cl_grp char(2) not null,
cl_name char(50) not null,
cl_add1 char(40) not null,
cl_city char(20) not null,
cl_pin char(6) not null,
cl_tel char(20),
cl_fax char(20))
suppose 2nd table is bill, then u can set the foreign key by this code-
CREATE TABLE BILL(
BILL_NO NUMBER(7) PRIMARY KEY,
CL_CODE NUMBER(7) NOT NULL,
BL_DETAIL VARCHAR2(200) NOT NULL,
RATE_DET VARCHAR2(100),
BILL_AMT NUMBER(10,2) NOT NULL,
AMT_ADJ NUMBER(10,2),
CONSTRAINT fkey1 FOREIGN KEY (CL_CODE) REFERENCES CLIENT(CL_CODE))
Now you can issue the sql for extracting the values from the 2 tables -
select a.cl_name,a.cl_code,b.* from client a,bill b where a.cl_code=b.cl_code;
regards....
Rajendra
|
|
|