---------------DB2数据库常用语句---------------
所有SQL语句,不区分大小写,分号可加可不加;多条语句执行时必须加上。
写作顺序
select -> from -> where -> group by -> having -> order by
执行顺序
from -> where -> group by ->having -> select -> order by
建表语句
创建table(table_name=professor)
create table professor(
khdxdh integer,
hydh varchar(12),
hymc varchar(100))
in TBS_PAS --表结构所在表空间
index in TBS_IDX --索引所在表空间
;
create unique index xpkprofessor on professor
(
khdxdh asc
);
查询
select * from professor fetch first 5 rows only
聚合函数
计数count: 计算所有行数:count(*)
计算null以外行数:count(<列名>)
计算去除重复数据后的行数:count(distinct <列名>)
求和 sum
求平均 avg
求最值 max/min
–在SQL语句中实现换行
select ‘中国’||chr(10)||‘你好!&#
db2增删改查
最新推荐文章于 2024-05-07 12:15:00 发布