安装
yum install -y postgresql14-server
2 建库表
创建 DB
create database martin;
删库
drop database martin;
选择数据库...* from aaa;
带条件的查询:
select * from aaa where id=1;
更新:
update aaa set name='martin' where id=1;
删除:
delete...from aaa where id=1;
如果需要清空表,可以使用:
truncate table aaa;
4 limit/排序/分组
为了方便后面实验,我们再造一些数据:
insert into...aaa values (1,'a',1,'a',90),(2,'b',2,'b',80),(3,'c',3,'b',92);
limit
select * from aaa limit 1;
正序排序:...select * from aaa order by score;
倒序排序:
select * from aaa order by score desc;
分组
select add,avg(score