本文最后更新于166 天前,其中信息可能已过时,如有错误请发送邮件到lh2406923301@163.com
1:创建数据库db_hg:
create database db_hg;
2:创建表tb_hg:
create table tb_hg(
id int auto_increment primary key, //主键,自动递增
name varchar(50) not null, //姓名,字符型,最大长度50,不能为空
age int, //年龄,整形
sex enum(‘男’,’女’,’其他’)); //性别,枚举类型,只能为男/女/其他
3:在表中插入数据:
insert into tb_hg(name,age,sex)
values(‘行哥’,18,’男’);
4:查询表中所有数据:
select * from tb_hg;
5:查询表中 id=3 的数据:
select * from tb_hg where id=3;
6:删除表中 id=3 的记录:
delete from tb_hg where id=3;
7:删除表中所有数据:
delete from tb_hg;
8:删除tb_hg表:
drop table tb_hg;
9:查看当前数据库中的表:
show tables;
10:显示所有数据库;
show databases;
11:删除数据库db_hg;
drop database db_hg;
12:退出数据库操作:
exit;









