MySQL数据库学习笔记03.docxVIP

  • 0
  • 0
  • 约1.48万字
  • 约 16页
  • 2022-09-14 发布于四川
  • 举报
MySQL dayO3 1、约束 唯一性约束(unique) 唯一约束修饰的字段具有唯一性,不能重复。但可以为NULL。 案例:给某一列添加uniquedrop table if exists t__user; create table t_user(id int, username varchar(255) unique // 列级约束); insert into t_user values(l/zhangsan);insert into t_user values(2,zhangsan); ERROR 1062 (23000): Duplicate entry zhangsan for key usernameinsert into t_user(id) values(2); insert into t_user(id) values(3);insert into t_user(id) values(4); 案例:给两个列或者多个列添加uniquedrop table if exists t_user; create table t_user(id int, usercode varchar(255), username varchar(255), unique(usercode,username) //多个字段联合起来添加1个约束unique【表级 约束】); insert

文档评论(0)

1亿VIP精品文档

相关文档