zoukankan      html  css  js  c++  java
  • 随笔-建表遇到的问题

    create table users(
     id bigint not null auto_increment primary key,
     email varchar(60) not null,
     pwd varchar(60) not null,
     nicheng varchar(60) not null,
     updtime timestamp not null,  (要先更新time 因为)timestamp是默认系统时间
     role tinyint not null default 1,
     msgnum int not null default 0,
     createtime timestamp not null,
     unique key emailuniq (email),
     unique key nichenguniq (nicheng)
    )ENGINE=innodb DEFAULT CHARSET=utf8;

    一.mysql表有三种(第一次知道)

    二.timestamp :默认是系统时间

    三.unique约束

    1 .unique 与主键的区别

    UNIQUE 约束唯一标识数据库表中的每条记录。

    UNIQUE 和 PRIMARY KEY 约束均为列或列集合提供了唯一性的保证。

    PRIMARY KEY 拥有自动定义的 UNIQUE 约束。

    请注意,每个表可以有多个 UNIQUE 约束,但是每个表只能有一个 PRIMARY KEY 约束。

    2.含义

     unique key emailuniq (email),

    一个邮箱只能注册用户

    unique key nichenguniq (nicheng)

    一个用户只能有一个昵称

    unique key email

    3.用法

       当表已被创建时,如需在 "Id_P" 列创建 UNIQUE 约束,请使用下列 SQL:

    ADD UNIQUE (Id_P)
    如需撤销 UNIQUE 约束
    DROP INDEX Id_P

    4.unique(Id_p) 和unique key idque(Id_p)区别(未解决)
     
  • 相关阅读:
    pptpvpn链接问题
    nginx网站架构优化思路(原)
    KEEPALIVED 检测RS原理
    linux 做gw(nat)详细配置
    pptpvpn 连接后 无法上外网
    网站最常见的错误
    Python服务器开发 -- 网络基础
    python高性能编程方法一
    一步步来用C语言来写python扩展
    http响应Last-Modified和ETag
  • 原文地址:https://www.cnblogs.com/qieyu/p/7784120.html
Copyright © 2011-2022 走看看