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

    1.alter操作表字段

    (1)增加字段

      alter table 表名 add 字段名 字段类型;

      alter table student add name varchar(10);

    (2)修改字段

       alter table 表名 change 旧字段名 新字段名 字段类型;

       alter table 表名 modify 字段名 字段类型;//修改字段类型

       alter table student change name name varchar(20)not null default 'liming';//修改字段类型 default后边是

        字段默认的值

       alter table student change name name1 varchar(20)not null default 'liming';//修改字段名

    (3)删除字段

       alter table 表名 drop 字段名;

       alter table student drop name;

    2.alter 索引操作

     (1)增加索引

        alter table 表名 add index 索引名 (字段名1,字段名2.....);

        alter table student add index stu_name(name);

      (2)删除索引

         alter table 表名 drop index 索引名;

         alter table student drop index stu_name;

      (3)查看某个表的索引

         show index from 表名;

       (4)增加唯一限制条件的索引

         alter table 表名 add unique 索引名(字段名);

     3.主键操作

        增加主键:

       alter table 表名 add primary key(字段名);

       删除主键:

       alter table 表名 drop primary key;(主键不是自动增长情况下)

        alter table 表名 modify 字段 字段类型, drop primary key;(主键是自动增长情况下)

      alter table 123 modify id int,drop primary key;

  • 相关阅读:
    EntityFramework4.5使用Expression类创建动态查询及动态查询导航属性
    EF 5.0 帮助类
    EF异常:“System.InvalidOperationException”类型的未经处理的异常在 mscorlib.dll 中发生
    EF框架学习手记
    Entity Framework 学习
    C#特性-表达式树
    LINQ to SQL 运行时动态构建查询条件
    一点css 基础
    JQuery 判断复选框是否选中
    Asp.Net Server.MapPath()用法
  • 原文地址:https://www.cnblogs.com/kabi/p/5908758.html
Copyright © 2011-2022 走看看