1. 创建一个名为jack的库

    mysql> create database jack;


    ---------------------------------------------------------------------------------------

  2. 查询所有的库

    mysql> show databases

    ---------------------------------------------------------------------------------------

  3. 进入库jack,创建一张为名stu的表

    mysql> use jack;

    mysql> create table stu(

        -> id int,

        -> name varchar(20),

        -> passwd varchar(24)

        -> )engine myisam charset utf8;

    ---------------------------------------------------------------------------------------

  4. 查看jack下的表

    mysql> show tables;

    ---------------------------------------------------------------------------------------

  5. 将表jack重命名为abc

    mysql> rename table jack to abc;

    mysql> show tables;

    注:不能更改成数字,否则会出错。。

    ---------------------------------------------------------------------------------------

  6. 给abc表插入数据

    mysql> insert into abc values

       ->(1,'huqiang'),

       ->(2,'renye'),

       ->(3,'huqing');

    ---------------------------------------------------------------------------------------

  7. 查看abc表插入的数据

    mysql> select * from abc;

    ---------------------------------------------------------------------------------------

  8. 显示数据表的结构

    mysql> describe abc;

    ---------------------------------------------------------------------------------------

  9. 删掉abc这个表

    mysql> drop table abc

    ---------------------------------------------------------------------------------------

  10. 删掉jack这个库

    mysql> drop database jack;

    ---------------------------------------------------------------------------------------

  11. 清空abc这个表

    mysql> truncate abc;

    mysql> delete from abc;


    truncate和delete是有区别的,在于truncate相当于删表再重建一张同样结构的表,操作后得到一张全新表,而delete是从删掉所有的层表来操作的,truncate相当于把旧的学籍表扔了重画一张,delete相当于用橡皮把学籍表的数据擦掉,如果决定全清空用truncate更快些

    ---------------------------------------------------------------------------------------

  12. 删掉abc这个表

    mysql> drop table abc;

    ---------------------------------------------------------------------------------------