我在将其转换为MySql时遇到问题。我最初在Oracle数据库中具有此功能,但是在第6行出现错误。如何解决此问题?
create table racewinners (
racename varchar(20) not null,
raceyear integer,
ridername varchar(20) not null,
distance integer,
winning_time INTERVAL DAY (9) TO SECOND (2),
constraint racewinners_rname_ryear_pk primary key (racename, raceyear),
constraint racewinners_raceriders_fk foreign key (ridername) references raceriders(ridername)
);
最佳答案
MySQL没有interval
数据类型。您应该可以使用datetime
。以下是为MySQL编写此代码的典型方法:
create table racewinners (
racename varchar(20) not null,
raceyear integer,
ridername varchar(20) not null,
distance int,
winning_time datetime,
primary key (racename, raceyear),
foreign key (ridername) references raceriders(ridername)
);