zoukankan      html  css  js  c++  java
  • mysql 修改 添加 删除 表字段

    alter table t_alarm_target_dimension add column a tinyint COMMENT '预警类型';
    alter table t_alarm_target_dimension drop column TARGET;
    alter table t_alarm_target_dimension change column target alarm_target_code varchar(50) comment '预警指标码';
    alter table t_alarm_target_dimension modify column c VARCHAR(50);

    添加表的字段    alter table 表名  add  字段名  字段的类型

          例子:        alter table table1 add transactor varchar(10) not Null;

                          alter table   table1 add id int unsigned not Null auto_increment primary key

                          在mysql数据库中怎样在指定的一个字段后面添加一个字段:

                          alter table newexample add address varchar(110) after stu_id;

    修改表的字段类型   ALTER TABLE 表名 MODIFY COLUMN 字段名 字段类型定义;

           例子:                  ALTER TABLE chatter_users MODIFY COLUMN ip VARCHAR(50);

    修改表的字段名    alter table 表名 change 原字段名  新字段名  字段的类型

         例子: alter table student change physics physisc char(10) not null

    删除表的字段    alter table 表名 drop column 字段名

         例子:         alter table `user_movement_log` drop column Gatewayid

    调整表的顺序:  ALTER TABLE `user_movement_log` CHANGE `GatewayId` `GatewayId` int not null default 0 AFTER RegionID

    表的重命名   alter table 原表名 rename 现表名;

         例子:      alter table t1 rename t2;

    删除表的数据   delete from 表名  where  (条件)    id 不是从1开始       ,truncate table 表名     id是从1 开始的

    创建表的例子  

      CREATE TABLE hlh_message (

           id int(11) NOT NULL AUTO_INCREMENT COMMENT '健康表id',

            title varchar(40) NOT NULL COMMENT '健康标题',

            hlh_url text DEFAULT NULL COMMENT '图片地址',

            bewrite VARCHAR(350) NOT NULL COMMENT '描述',

            content VARCHAR(350) NOT NULL COMMENT '内容',

            type tinyint(1) NOT NULL DEFAULT '0' COMMENT '健康知识 0 健康咨询 1',

            create_time date DEFAULT NULL COMMENT '发布消息的时间',

            PRIMARY KEY (id)

        )ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='健康表'

  • 相关阅读:
    如何利用书签向word文档读取或写入数据[C#](
    一个较为完整的例子,还可以,简单一些的
    GridView的RowDataBound事件可做的一些事情
    ASP.NET中DataGrid和DataList控件用法比较
    GridView中绑定数据字段时可做的几种操作方法
    GridView中如何取得隐藏列的值
    一些常用的算法技巧总结
    位运算装逼指南
    小胖求学系列之文档生成利器(上)smartdoc
    系统监控之硬盘使用率
  • 原文地址:https://www.cnblogs.com/cxhfuujust/p/10595191.html
Copyright © 2011-2022 走看看