错误原因:添加外键所在表里面存有数据,把数据删了才能添加外键 alter table user_post add constraint fk_member_no foreign key(owner_id) references users(id)