通过创建一个数据库mydbs以及表tb_stu和表tb_stu1来说明。

1创建数据库

create database mydbs;

mysql之表的创建

2创建表tb_stu和tb_stu1

    2.1进入到数据库mydbs

    use mydbs;

  mysql之表的创建

  2.2创建表

  create table tb_stu(name varchar(50),age int,gender char(10));

 mysql之表的创建

 create table tb_stu1(name varchar(50),age int,gender char(10));

3查看表结构

desc  tb_stu;

mysql之表的创建

4 修改表

4.1修改表名称

alter table tb_stu rename to tb_student;

mysql之表的创建

4.2 增加表的属性

alter  table tb_stu add phone  varchar(11);

mysql之表的创建

4.3 修改表的属性

alter table tb_stu modify phone int;

mysql之表的创建

4.4 删除表的属性

alter table tb_stu drop phone;

mysql之表的创建

5 查看数据库

show databases;

mysql之表的创建

6 查看数据库中的表

需要先进入某个数据库,使用use+数据库名称,然后

show tables;

mysql之表的创建

7删除表

drop table tb_stu1;

mysql之表的创建

8删除数据库

drop database mydbs;

mysql之表的创建

9修改数据库的字符编码

alter database mydbs character set utf8;

mysql之表的创建

相关文章:

  • 2021-12-04
  • 2021-08-04
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-07
  • 2021-10-13
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2021-04-27
  • 2021-11-02
相关资源
相似解决方案