zoukankan      html  css  js  c++  java
  • 修改表结构

    1.修改表名

    alter table 表名
    2.添加一个字段

    ater table 表名   add  字段名   数据类型[约束条件];add  字段名   数据类型[约束条件];

    3.将添加的字段放在某个字段之后,    放在最前面用first

    alter   table   表名    add  字段名    数据类型[约束条件]  after  字段名;

    修改主键

    alter   table   student2  drop   primary  key;

    然后再添加主键

    alter  table   student2   add  primary  key(id);(添加前要删除重复的值)

    为book表添加外键

    alter  table book  add  constraint  fk_id  foreign   key(press_id)  references  press(id);

    删除外键

    alter   table   book   drop   foreign  key   fk_id;

    4.删除字段名

    alter   table   表名   drop  字段名;

    5.修改字段   modify      char(15)变为char(19)

    alter table student2 modify name char(18);      不能修改字段名,只能改类型。

    可以去掉not  null             alter   table   student2   modify  name  char(12)  null;

    change

    alter  table  student2   change  name  sname   char(10) not null;

  • 相关阅读:
    7617:输出前k大的数
    2991:2011
    7620:区间合并
    1688 求逆序对
    Magento How To Display Product Custom Option On list.phtml
    大二实习使用的技术汇总(中)
    codility上的问题 (22)
    poj 3321
    使用ViewPager实现左右“无限”滑动的万年历
    数论练习专题
  • 原文地址:https://www.cnblogs.com/ch2020/p/12890892.html
Copyright © 2011-2022 走看看