1.打开我们已经建好的数据库 及表 开始我们今天的
2.增
先查看一下表内容 发现无内容现在来添加
3.更
将表中原有数据修改为我们需要的数据
update t_name set 字段1 = 新值, 字段2 = 新值 … where 条件
4.删
delete from tablename where 条件
5.改## 标题
表结构的修改:alter table |-- 增加新的字段 ALTER TABLE 表名 ADD 列名 列类型 约束条件;
alter table t_hero add address varchar(255);
|-- 修改字段的类型 ALTER
TABLE 表名 MODIFY 列名 列类型;
alter table t_hero modify id bigint; |–
修改字段名称
ALTER TABLE 表名 CHANGE 旧列名 新列名 列类型;
alter table t_hero
change id hero_id int;
|-- 修改表名称 ALTER TABLE 表名 RENAME 新表名;
alter table t_hero rename hero;
– 第二种写法 rename table hero to
t_hero;
6.查
1.查询一张表: select * from 表名;
2.查询指定字段: select 字段1,字段2,字段3….from 表名;
3.where条件查询:select 字段1,字段2,字段3 frome 表名 where 条件表达式;
例:select * from t_studect where id=1;
select * from t_student where age>22;
4.带in关键字查询: select 字段1,字段2 frome 表名 where 字段 [not]in(元素1,元素2);
例: select * from t_student where age in (21,23);
select * from t_student where age not in (21,23);