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;

  • 相关阅读:
    Silverlight:版本控制的衍化
    SqlServer收缩日志文件不起作用
    flutter错误笔记
    IIS利用X-Forwarded-For获得来访者的真实IP
    SQL Server游标
    计算机存储单位和网络网速单位
    SQL Server中的流控制语句
    密码重复加密
    c#参数修饰符-ref
    c#参数修饰符-out
  • 原文地址:https://www.cnblogs.com/ch2020/p/12890892.html
Copyright © 2011-2022 走看看