zoukankan      html  css  js  c++  java
  • mysql 常用操作命令

    建库

    create database 库名

    选择库

    use 库名;

    显示数据库中的所有表

    show tables;

    显示数据库中的一个表

    show create table 表名;

    创建表

    create table 表名;

    删除表

    drop table 表名;

    添加列

    alter table 表名 add column 列名 not null ;

    修改列

    alter table 表名 modify column 列名 not null;

    添加主键

    alter table 表名 add primary key (列名);

    删除主键

    alter table 表名 drop primary key;

    添加索引

    alter table 表名 add index 索引名(列名);

    删除索引

    alter table 表名 drop index 索引名(列名);

    添加外键

    alter table 表名 add constraint 外键名 foreign key (列名)  references 指向的表名 (列名) on delete cascade on update cascade

    删除外键

    alter table 表名 drop constraint 外键名

    alter table 表名 drop foreign key 外键名

    修改引擎

    alter table 表名 type=InnoDB;

  • 相关阅读:
    freopen
    字符
    map映射
    P3512 [POI2010]PIL-Pilots-洛谷luogu
    快读
    单调队列&单调栈
    简写
    邻接表&链式前向星
    mysql参数详解
    网络管理指南
  • 原文地址:https://www.cnblogs.com/zhaozhilu/p/2759103.html
Copyright © 2011-2022 走看看