• 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;
  • 相关阅读:
    fastDFS与nginx整合2
    fastDFS分布式文件系统
    NIO编程
    Nginx正向代理与反向代理
    JAVA序列化
    FileUpload问题
    测试覆盖率实现技术
    Hutool 功能特色:
    自建右键服务器
    20191123-SWITCH后面跟的参数不能为string类型
  • 原文地址:https://www.cnblogs.com/yuknight/p/12722489.html
Copyright © 2020-2023  润新知