数据库相关

    1. # 创建数据库
    2. create database if not exits blog;
    3. -- 删除数据库
    4. drop database if not exits blog;
    5. -- 显示数据库
    6. show databases;
    7. -- 选择创建的数据库
    8. use blog;
    9. -- 显示表名
    10. show tables;
    11. -- 重命名表
    12. alter table articles rename article;
    13. -- 清空数据表
    14. delete from article;
    15. -- 清空数据表,且无法恢复
    16. truncate table article;

    表相关

    1. # 添加列
    2. alter table article add column `author` varchar(5) not null default '' after `title`;
    3. # 修改列名(重建表)
    4. alter table article change author authors;
    5. # 修改列属性(不重建表)
    6. alter table article modify `authors` varchar(10) not null default '' comment '';
    7. # 删除列
    8. alter table article drop authors;
    9. # 插入一行数据
    10. insert into `article` () values ();
    11. # 清空表数据,不清空表标识
    12. delete * from article;