发布网友
共2个回答
热心网友
-- Create table
create table 电脑使用情况表
(
电脑代码 char(4) not null,
卡号 char(12) not null,
);
alter table 电脑使用情况表
add constraint PC_USE_PK primary key (电脑代码,卡号)
using index
;
create table 上机时间表
(
卡号 char(12) not null,
上机时间 smalldatetime,
下机时间 smalldatetime
);
alter table 上机时间表
add constraint ddd foreign key (卡号)
references 电脑使用情况表 (卡号);
热心网友
你上面写了连个外键? 我感觉你要的应该是下面的
create table 电脑使用情况表
(
电脑代码 char(4)not null PRIMARY KEY,
卡号 char(12)not null foreign KEY references 上机时间表(卡号)
)
create table 上机时间表
(
卡号 char(12)not null PRIMARY KEY ,
上机时间 Smalldatetime not null ,
下机时间 Smalldatetime not null
)