CREATE trigger T_PlayersNum before insert on Players for each row begin If (Select Count(distinct playerid) From Players) >=200 Raiserror('不能超过200个',16,-1) RollBack Tran Return End if End 这样写有问题吗?
如playerid是唯一标识的字段,就可以。
CREATE trigger T_PlayersNum before insert on Players for each row begin If (Select Count(distinct playerid) From Players) >=3 then Raiserror('不能超过3个',16,-1); RollBack Tran; Return; End if; End$$我这个在MYSQL里执行是有语法错误,请大家指点啊,谢谢.
The document said. #MAX_ROWSThe maximum number of rows you plan to store in the table. This is not a hard limit, but rather a hint to the storage engine that the table must be able to store at least this many rows.
before insert on Players for each row
begin
If (Select Count(distinct playerid) From Players) >=200
Raiserror('不能超过200个',16,-1)
RollBack Tran
Return
End if
End
这样写有问题吗?
before insert on Players for each row
begin
If (Select Count(distinct playerid) From Players) >=3 then
Raiserror('不能超过3个',16,-1);
RollBack Tran;
Return;
End if;
End$$我这个在MYSQL里执行是有语法错误,请大家指点啊,谢谢.
#MAX_ROWSThe maximum number of rows you plan to store in the table. This is not a hard limit, but rather a hint to the storage engine that the table must be able to store at least this many rows.