zoukankan      html  css  js  c++  java
  • DDL语言(MySQL表的管理)

    一、表的创建

    Create table 表名 ((列名,数据类型),(列名,数据类型),(列名,数据类型),(列名,数据类型),);

    二、表的修改

     1)列的增加(与注释)

      语法:

    Alter  table tableName add column columName columnType comment '注释' ;

      案例:

    alter table author add column name varchar(20) comment '注释';

     2)列名的修改

      语法:

    Alter table tableName change column columnName newColumnName columnType;

      案例:

    alter table author change column name  names varchar(20);

     3)列数据类型的修改

      语法:

    Alter table tableName modify column columnName columnType comment '注释';

      案例:

    alter table author modify column names varchar(10);

     4)列的删除

      语法:

    Alter table tableName drop column columnName;

      案例:

    alter table author modify column names varchar(10);

     5)表的重命名

      语法:

    Alter table tableName rename to newTableName;

      案例:

    alter table author rename to authors;

     6)表的复制

    • 全部复制

      语法:

    Create table select * from oldtable;

      案例:

    create copy3 select * from authors;
    • 部分复制

      语法 :

    Create table newTable select column1,column2,column3 from oldtable;

      案例:

    create table copy2 select id,author from authors;
    • 结构复制

      语法:

    Alter table newTableName like tableName;

      案例:

    create table copy like authors;

     三、表的删除

      语法:

    drop table table1,table2,table3;

      案例:

    drop table copy,copy2,copy3;
  • 相关阅读:
    卫星时间同步装置的安装及售后
    windowsU盘重装系统:操作流程
    vue安装正确流程
    win10以太网未识别的网络
    [UnityShader]unity中2D Sprite显示阴影和接受阴影
    [UnityShader]说厌了的遮挡显示
    [Unity]利用Mesh绘制简单的可被遮挡,可以探测的攻击指示器
    ConcurrentHashMap源码解读
    Vector底层原理
    LinkedList集合底层原理
  • 原文地址:https://www.cnblogs.com/yuknight/p/12722489.html
Copyright © 2011-2022 走看看