zoukankan      html  css  js  c++  java
  • python set enum 完整性约束

    # create table biao (  id int,gender enum('ss','ssd')); 只能添加ss和ssd,填写其他添加不进去
    # create table biao1 ( id int,hobby set ('a','b','c'));
    # insert into biao1 values(1,'a,b');   多选  insert into biao1 values(1,'a,a,a,b,d');  还能去重和去掉没有的


    #约束某一个字段 # 无符号的
    int unsigned id int unsigned # 不能为空的 not null id int unsigned not null # 默认值 default male enum('a','b')not null default 'a' # 不能重复/唯一约束 unique 值不能重复,null可以多次写入 #联合唯一 :unique ip and 端口不能重复 #create table t( # id int # server_name char(12) # ip char(15) # port char(5) # unique(ip,port)); # 自增 auto_increment #只能对数字有效,自带非空约束 #至少是unique的约束之后才能使用auto_increment # 主键 primary key # 外键 foregin key(自己的字段)references 外表(外表字段) #外表字段必须是唯一的 #非空+唯一约束 #create table t( # id int not unique # username char(12)not null unique # ); #第一个被定义为非空+唯一约束的那一列会成为这张表的primary 可以 #一张表只能定义一个主键 #联合主键 #create table t( # id int # username char(12) # primary key(id,username) # ); #外键 #foregin key(数据)references 关联表(数据); #foregin key(数据)references 关联表(数据) on update cascade on delete cascade; # 修改表名 # alter table 表名 add 字段名 数据类型
  • 相关阅读:
    机房收费系统——报表(2)
    机房收费系统——报表(1)
    机房收费系统之结账
    机房管理系统——vb与excel链接2
    机房管理系统——VB与Excel的链接
    Unity
    Android Dev Tips
    Android JSON And Object Cast
    Android Screen Orientation
    iOS8 with Swift
  • 原文地址:https://www.cnblogs.com/shaohuagu/p/12299782.html
Copyright © 2011-2022 走看看