sql,database, – db – 数据库基本操作(一)

chengji

id name age class score
1 小米 17 语文 99
2 小明 18 数学 88
3 小李 17 体育 100
4 小米 17 体育 55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# select 列 from 表
select * from chengji
select name,score from chengji
# select 去重: select distinct 列 from 表
select distinct name from chengji
# where子句:select 列 from 表 where 列 运算符 值
select * from chengji where name = ‘小米’ # 字符串要加引号
select * from chengji where score < 60
# and 和 or
select * from chengji where score > 60 and scoure < 90
# order by
select * from chengji order by scoure
select * from chengji order by scoure desc # 倒序
# insert: insert into 表 values (值1, 值2,...)
insert into chengji values (‘小红’,17,‘语文’, 100)
# update: update 表 set 列=新值 where 列=某值
update chengji set score=60 where id=4
# delete: delete from 表 where 列=值
delete from table where id=5