zoukankan      html  css  js  c++  java
  • 程序媛计划——mysql修改表结构

    #查看表的结构

    mysql> desc score;
    +------------+--------------+------+-----+---------+----------------+
    | Field      | Type         | Null | Key | Default | Extra          |
    +------------+--------------+------+-----+---------+----------------+
    | id         | int(4)       | NO   | PRI | NULL    | auto_increment |
    | name       | char(20)     | NO   |     | NULL    |                |
    | score      | double(16,2) | YES  |     | NULL    |                |
    | evaluation | char(20)     | YES  |     | normal  |                |
    +------------+--------------+------+-----+---------+----------------+
    4 rows in set (0.00 sec)

    #alter对字段操作

    #添加字段

    mysql> alter table exam_score add other int(4) default 10;
    Query OK, 0 rows affected (0.05 sec)
    Records: 0  Duplicates: 0  Warnings: 0

    #修改字段变为另一个字段

    mysql> alter table exam_score change other evaluation char(20) default 'normal'; 
    Query OK, 4 rows affected (0.02 sec)
    Records: 4  Duplicates: 0  Warnings: 0

    #删除字段(即删除字段中的所有数据)

    mysql> alter table exam_score drop column other;
    Query OK, 0 rows affected (0.05 sec)
    Records: 0  Duplicates: 0  Warnings: 0

    #修改表名

    mysql> rename table exam_score to score;
    Query OK, 0 rows affected (0.01 sec)
  • 相关阅读:
    移动硬盘文件被恶意隐藏
    asp.net identity UserSecurityStamp 的作用
    Head First Python学习笔记1
    WPF 确认动态加载数据完成
    rust by example 2
    Rust by Example1
    奇葩!把类型转成object
    Lambda高手之路第一部分
    理解Lambda表达式
    贪心算法-找零钱(C#实现)
  • 原文地址:https://www.cnblogs.com/IcarusYu/p/7497289.html
Copyright © 2011-2022 走看看