开发者社区> 问答> 正文

MySQL创建后表的修改如何操作?

已解决

MySQL创建后表的修改如何操作?

展开
收起
1780169608831412 2021-10-01 08:54:07 875 0
2 条回答
写回答
取消 提交回答
  • 网络规划设计师、敏捷专家、CISP、ITSS服务经理、ACA全科目、ACP4项、ACE、CBP、CDSP、CZTP等。拥有 PRINCE2 Foundation/Practitioner、CCSK、ITIL、ISO27001、PMP等多项国际认证。 专利5+、期刊10+、知识产权师。核心期刊审稿人。
    采纳回答

    您好,以下是常见操作范例供参考:

    1. 添加列:alter table students add address char(60);
    alter table students add birthday date after age;
    
    2.修改列名,使用change需加上数据类型:
    alter table students change tel telphone char(13) default “-”;
    alter table students change name nm char(16) not null;
    
    3. 修改数据类型,使用alter:
    alter table students alter name char(10);
    
    4. 删除列:
    alter table students drop birthday;
    
    5. 重命名表:
    alter table students rename workmates;
    
    6. 清除表格数据:
    truncate table students;
    
    7. 删除整张表:
    drop table workmates;
    
    8. 删除整个数据库:
    drop database samp_db;
    
    
    2021-10-01 09:10:51
    赞同 展开评论 打赏
  • 给表添加字段

    mysql> alter table books add column id int ;
    Query OK, 0 rows affected (0.10 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    2021-10-16 17:48:10
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载
阿里云企业级自治数据库 RDS 详解 立即下载
阿里云MySQL云数据库产品体系介绍 立即下载

相关镜像