DB2初学者学习
来源:互联网 发布:网上商城java源码 编辑:程序博客网 时间:2024/05/19 12:40
我是一名新学习DB2的学员,本文档供初学者借鉴!
1.下载地址:(我是在一个博客上看到的,很详细,直接提供他博客地址)
http://happyqing.iteye.com/blog/2082305
(备注:windows10不适用这个链接下的版本!)
2.安装完成,打开方式
window+R(运行)输入db2cc 或者db2cmd就可以db2的控制中心
3.写SQL语句
选择数据库-右键-查询:弹出【命令编辑器的窗口】,在这个窗口你可以写sql语句命令
下面直接用例子操作,以便于更加明白
a.创建tstudent学生表并实现id自增
create table tstudent(
id numeric not null primary key
generated always as identity(start with 1 increment by 1 minvalue 1 maxvalue 9999 no cycle cache 20 no order) ,
name varchar(30) ,
sex varchar(10),
classcode varchar(30)
);
b.为字段添加注释
comment on table tstudent is '测试学生表';
comment on column tstudent.id is '学生编号';
comment on column tstudent.name is'学生姓名';
c.增加一列
alter table tstudent add column hobby varchar(200);
alter table tstudent add column birthdate date;
d.建立索引
create index l_TSTUDENT_CLASSCODE on tstudent(classcode);
e.插入数据
insert into tstudent(name,sex,classcode,hobby) values('小明','男','C131','唱歌,游泳');
insert into tstudent(name,sex,classcode,hobby) values('小张','男','C132','读书,听音乐');
f.修改数据
update tstudent set sex='女' where name='小张';
g.删除数据
1).delete from tstudent;
2).alter table tstudent activate not logged initially with empty table;(删除不记录日志)
3)drop table tstudent;(把数据删了连同表结构一起删除)
h.分页查询
select * from (
select row_number() over (order by id asc ) as row_number ,t.* from tstudent t ) a
where a.row_number > 10
fetch first 10 rows only
(备注:第一页,row_number>0每页查询10条记录,第二页,row_number>10 以此类推)
- DB2初学者学习
- 初学者学习
- 初学者学习
- DB2常用命令学习笔记
- DB2常用命令学习笔记
- DB2基础学习
- DB2 学习笔记(四)
- 关于db2的学习
- 学习DB2中
- DB2 730考试学习
- DB2之实例学习
- DB2学习--索引结构
- DB2学习第一步
- db2学习笔记
- DB2学习笔记-0001
- DB2学习网站
- Db2学习笔记
- DB2个人学习笔记
- github的ssh通过http代理来配置实现
- perl socket 返回发送成功数据的长度
- datatable分页动态加载
- 【九度OJ】题目1087:约数的个数 解题报告
- Google Java Style 中文版
- DB2初学者学习
- Echarts海南地图过小解决方案
- Android WebView 跳转第三方App
- windows下面自动打包exe批处理
- vue.js获取数据库数据
- 营救
- 如何使 vlc 支持 fdk-aac 编码(windows平台
- jstl的fmt标签(格式标签)
- 设备模型三(潜谈sysfs)