增删改查
1.添加数据
insert student(name,age) values('xh','18');
2.删除表格
drop table dd;
我们在删除表格时,要先创建一个表格
3.添加字段数据
alter table student add phone char(10)not null;
查看一下
4.修改表中字段的名字
alter table student change phone molib char(11);
5.删除表格中字段
alter table student drop molib;
6.修改表中的数据
update 表名 set 字段=修改 指定哪条记录; 一定要指定修改哪条记录,否则会全部修改
update student set name=‘lisi’ where id=2;
有两种方法还有一个
update student set gender='F' where name='xh';
7.查询数据
select * from 表名;
* 显示表中所有的字段
select age,name 表名;
只挑选年龄和姓名字段
例子:
select * from students;
select * from students;
select age from students;
上面这些是我自己脚本文件,可能和你们的不一样不用在意,
去重 distinct
select distinct from age students;
where 条件查询
SELECT "字段" FROM "表名" WHERE "条件";
SELECT age FROM students WHERE ><= 或or 且and between;
where 后面 可以跟上 > < = org and between
例子:
找出大于20岁的人
select name,age from students where age>20;
找出20岁的人
select name,age from students where age=20;
找出小于20岁的人
select name,age from students where age<20;
找出20岁到50岁之间的人
select name,age from students where age>20 and age<50 ;
select name,age from students where age between 20 and 50;
我i就不一 一展示出来了
select name,age from students where age>20;
select name,age from student where age between 20 and 50;