
注意:如果你保存了表结构,“SQL预览”下的内容将为空。
1、启动Navicat for MySQL,新建数据库连接,打开数据库,可能有点啰嗦。
2、可以先查看定时任务的是否开启。通过以下命令:show variables like '%sche%'
3、如果其设置值为为 OFF 或 0 ,通过执行下列语句,来开启event_scheduler,set global event_scheduler =1,把设置为设为ON 或 1。
4、新建一个函数 ,取名为update_qiandao ,内容为 UPDATE week7_user SET isqiandao = 0
5、参照上图,新建一个事件 ,在定义里写 call update_qiandao() --也就是之前定义的函数
在“计划”选项卡中设置 执行时间,这里我选择的是每天。
mysql添加外键:为已经添加好的数据表添加外键:
语法:alter
table
表名
add
constraint
fk_id
foreign
key(你的外键字段名)
references
外表表名(对应的表的主键字段名);
例:
alter
table
tb_active
add
constraint
fk_id
foreign
key(user_id)
references
tb_user(id)
//fk_id是外键的名称
/*
create
table
`tb_active`
(
`id`
int(11)
not
null
auto_increment,
`title`
varchar(100)
character
set
utf8
collate
utf8_unicode_ci
not
null,
`content`
text
character
set
utf8
collate
utf8_unicode_ci
not
null,
`user_id`
int(11)
not
null,
primary
key
(`id`),
key
`user_id`
(`user_id`),
key
`user_id_2`
(`user_id`),
constraint
`fk_id`
foreign
key
(`user_id`)
references
`tb_user`
(`id`)
)
engine=innodb
default
charset=latin1
*/
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)