zoukankan      html  css  js  c++  java
  • 数据库MySQL--修改数据表

    创建数据库::create database 数据库名;

    如果数据不存在则创建,存在不创建:Create database if not exists 数据库名 ;

    删除数据库::drop database 数据库名;

    修改数据表::关键字alter

    修改数据表名:

          :alter table 数据表名 rename to 新表名;

    删除数据表中i字段(关键字:drop):

    :alter table 数据表名 drop i;

    向数据表添加k 字段,并定义类型(关键字:add):

    :alter table 数据表名 add k int;

    向数据表添加k 字段到指定字段名后,并定义类型(关键字:after):

          :alter table 数据表名 add k int after m; 

      # 设置为第一列 关键字为first

    修改数据表字段名的数据类型(关键字:modify):

          :alter table 数据表名 modify 字段名 新数据类型;

    修改数据表字段名:(关键字:change):

    ## 关键字后紧跟这是要修改的字段名,其后是指定的新名字及新类型 ##

         :alter table 数据表名 change 就名字 新名字 字段类型;

    修改数据表字段名时,设置字段默认值(关键字:not null default):

          :alter table 数据表名 modify 字段名 数据类型 not null default 默认值;

    修改字段默认值:

          :alter table 数据表名 alter 字段名 set default 新默认值;

  • 相关阅读:
    16-异常
    Linux 常用命令
    项目依赖子项目的类
    Struts2
    博客园【上吊猫】
    LayUI【基本使用】
    idea中隐藏.iml文件
    Session 使用
    博客园右下角看板娘特效,多种样式可选
    枚举
  • 原文地址:https://www.cnblogs.com/Vera-y/p/11507713.html
Copyright © 2011-2022 走看看