增删表中的数据
1.添加数据
向db1中的student中插入值
一种写法
insert into 表名(列1,列2,...列n) values(值1,值2...值n);
insert into student(id,name,age) values(1,"张无忌“,18);
另一种写法简化
insert into 表名 values(值1,值2...值n); -- 写完列名
insert into student values(2,"赵敏",17,null,null);
注意:
1.列名和值一一对应
2.不定以列名则要写完所以值;
3.除了数字类型,其他类型需要使用(单双)引号
2.删除数据:
delete from student where id=1;
删除表
truncate table stu; -- 删除表再添加这样的空表
3.修改数据:
*语法
update 表名 set 列名1=值1,列名2=值2,...[where 条件]
update student set id =3 where name="张三丰";