mysql提示错误语句帮忙修改一下 create table [user] ( id int identity(1,1), name varchar(20) not n
gocreatetableborrowBook(idintidentity(1,1),borrowIDvarchar(20)notnull,beginTimedateti...
go
create table borrowBook
(
id int identity(1,1),
borrowID varchar(20) not null,
beginTime datetime not null,
endTime as (beginTime+30),
bookID varchar(20) not null,
foreign key(borrowID) references [user](borrowID),
foreign key(bookId) references book(bookid)
)
s
CREATE trigger borrow
on borrowBook
for insert
as
begin
if (select max(quantity) from book where bookid=(select top 1 bookid from inserted))>0
begin
update book set quantity=quantity-1 where bookID=(select top 1 bookid from inserted)
end
else
rollback
end 展开
create table borrowBook
(
id int identity(1,1),
borrowID varchar(20) not null,
beginTime datetime not null,
endTime as (beginTime+30),
bookID varchar(20) not null,
foreign key(borrowID) references [user](borrowID),
foreign key(bookId) references book(bookid)
)
s
CREATE trigger borrow
on borrowBook
for insert
as
begin
if (select max(quantity) from book where bookid=(select top 1 bookid from inserted))>0
begin
update book set quantity=quantity-1 where bookID=(select top 1 bookid from inserted)
end
else
rollback
end 展开
1个回答
展开全部
楼主信息完整点,把你的sql语句发出来啊
更多追问追答
追问
create table [user]
(
id int identity(1,1),
name varchar(20) not null,
sex char(2) not null,
age int,
department varchar(20),
borrowID varchar(20) not null,
primary key(borrowID)
)
go
create table book
(
id int identity(1,1),
title varchar(100) not null,
bookID varchar(20) not null,
engine varchar(20) not null,
quantity int,
primary key(bookID)
)还有一段
追答
identity是 Transact-SQL中的用法。 你这里是要把id作为标示列,代表唯一性。可以这样写
id int(10) unsigned NOT NULL AUTO_INCREMENT,意思数字类型长度为10位数,不为空,自动增长。另外primary key 是设置主键的,一般都是id作为主键,而且自动增长,唯一性。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |