zoukankan      html  css  js  c++  java
  • mysql中列的增删改

    增加列:
    alter table table_name add name varchar(100);
    alter table table_name add name varchar(100) after id;
    alter table table_name add name varchar(100) first;
    
    修改列名:
    
    alter table table_name change name name varchar(10);
    #change可改名字与字段类型
    mysql> alter table a change uid uid int;
    Query OK, 0 rows affected (0.04 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    alter table table_name modify name int;
    #modify只改字段类型
    mysql> desc a;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | namea | char(1) | YES  |     | NULL    |       |
    | id    | int(11) | YES  |     | NULL    |       |
    | uid   | int(11) | YES  |     | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    3 rows in set (0.01 sec)
    
    mysql>
    mysql>
    mysql> alter table a modify uid varchar(1);
    Query OK, 0 rows affected (0.07 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    mysql> desc a;
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | namea | char(1)    | YES  |     | NULL    |       |
    | id    | int(11)    | YES  |     | NULL    |       |
    | uid   | varchar(1) | YES  |     | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    3 rows in set (0.01 sec)
    
    mysql>
    
    删除列:
    alter table table_name drop column_name;
    
    
    #手册
    help modify;
  • 相关阅读:
    linux系统telnet端口不通能收到SYN但不回SYN+ACK响应问题排查(转载)
    leveldb
    SSTable and Log Structured Storage: LevelDB
    fio terse输出详解
    bash的循环中无法保存变量
    怎样当好一个师长
    共享变量的并发读写
    Storage Systems topics and related papers
    Storage System and File System Courses
    调试std::string
  • 原文地址:https://www.cnblogs.com/perl6/p/7113182.html
Copyright © 2011-2022 走看看