zoukankan      html  css  js  c++  java
  • mysql学习笔记--列属性

    一、是否为空----null || not null

    二、默认值----default

    三、自动增长----auto_increment

    四、主键----primary key

      1. 主键:唯一标识表中记录的一个或一组列

      2. 主键的特点:不能重复,不能为空

      3. 一个表只能有一个主键,主键可以由多个字段组成

      4. 添加主键方式:

        a. 创建表时添加

          create table t1(

            id int primary key

          );

        b. 创建表时添加(单键、组合键)

          create table t1(

            id int,

            class int,

            primary key(id, class)

          );

        c. 更改表时添加

          alter table t4 add primary key (id);

      5. 删除主键

        a. alter table t4 drop primary key;

      6. 主键的作用

        a. 保证数据的完整性

        b. 加快查询的速度

      7. 自动增长列必须是主键

    五、唯一键

      1. 特点:不能重复,可以为空

      2. 一个表可以有多个唯一键

      3. 作用:

        a. 保证数据完整性

        b. 加快数据访问

      4. 创建表的唯一键

        a. create table t1(

          id int primary key,

          name varchar(20) unique,

          age varchar(2) unique

          );

        b. alter table t1 add unique (name),add unique(addr);

        c. alter table t1 add unique(name,addr);添加组合键

        d. alter table t1 add unique UQ_name(name);添加唯一键,并给唯一键起名字

      5. 删除唯一键

        alter table t1 drop index 键名

    六、备注

      comment

    七、注释

      1. 单行注释 #、--

      2. 多行注释 /*。。。。*/

      

          

  • 相关阅读:
    让textarea完全显示文章并且不滚动、不可拖拽、不可编辑
    解决css3毛玻璃效果(blur)有白边问题
    mysql_binlog恢复
    SED_AWK_正则
    进程;线程
    网络编程
    面向对象
    python_递归_协程函数(yield关键字)_匿名函数_模块
    Python 函数对象 命名空间与作用域 闭包函数 装饰器 迭代器 内置函数
    python_字符_函数
  • 原文地址:https://www.cnblogs.com/DjanFey/p/10672281.html
Copyright © 2011-2022 走看看