zoukankan      html  css  js  c++  java
  • mysql表字段属性

    mysql> alter table a1 change id idname int(20) unsigned not null;
    

      修改表字段属性关键字change,语法:alter table  表名  change  旧字段名称   新字段名称   新字段属性;需要注意地方,unsigned 必须紧跟在int属性后面,否则会提示报错

    mysql> create table a2 ( id int unsigned auto_increment primary key ); 
    

      auto_increment自增长字段属性特性,要求该字段类型必须为主键(primary key),否则会创建失败

    mysql> alter table a1 add password varchar(50) not null default '123456' after work;
    Query OK, 0 rows affected (0.01 sec)
    

      default 默认值字段属性特性,需要注意的是,默认值需要使用   ’单引号括起来,否则会报错。after表示跟在某个字段的后面。

    mysql> alter table a1 add primary key(id);
    Query OK, 0 rows affected (0.01 sec)
    

      primary key为字段添加主键索引,需要注意的是,要添加的主键索引字段需要用()括起来,否则报错。

  • 相关阅读:
    59. Spiral Matrix II
    58. Length of Last Word
    57. Insert Interval
    56. Merge Intervals
    55. Jump Game
    54. Spiral Matrix
    53. Maximum Subarray
    52. N-Queens II
    51. N-Queens
    java封装学习
  • 原文地址:https://www.cnblogs.com/xiaofeng666/p/13177784.html
Copyright © 2011-2022 走看看