在对表进行操作前,我们要先选中要使用的数据库
/*use 数据库名*/
use data2023;
1、创建表
/*create table 表名(列名 类型,列名 类型......);*/
create table test(id int,name varchar(20));
创建表时,我们还可以使用comment进行说明。这里的comment的作用与注释相同
create table test2(
-> id int,
-> name varchar(20) comment '姓名',
-> password varchar(50) comment '密码',
-> age int,
-> sex varchar(1)
-> );
2、查看表
show tables;
这条代码会显示当前数据库中所有表的信息
(3)表的描述
/*desc 表名*/
desc test;
(4)删除表
/*drop table 表名*/
drop table test;