I Have two Tables.
CREATE TABLE One(
Oneid int,
Twoid int,
data char(20),
PRIMARY KEY(Oneid,Twoid) )
Table One is Oneid and Twoid as primary key.
CREATE TABLE Two(
Twoid int,
data char(20),
PRIMARY KEY(Twoid) )
And I want to One.Twoid is foreign key for Table Two. How to solve it. Thank a lot.
Add the constraint in the
CREATE TABLE
statement:See fiddle.
Or use
ALTER TABLE
if your tables already exist:See fiddle.