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;
  • 相关阅读:
    css dropdown menu
    Understanding Delegated JavaScript Events
    AngularJS-Learning ui-router angular-transitions
    javascript sorting/ v8 sorting
    Sublime Text 3 新手上路:必要的安裝、設定與基本使用教學
    express with bower in websotrm
    angularjs transitions
    create a nodejs npm package
    nodejs module/require
    stylus , another css processor
  • 原文地址:https://www.cnblogs.com/yuknight/p/12722489.html
Copyright © 2011-2022 走看看