系统模式:

sysibm、sysfun和sysproc:一组例程,包括函数和存储过程。不建议直接访问sysibm

syscat:只读的,对象信息

sysstat:可更新编目视图

sysibmadm:可获取性能运行信息

create schema agent authorization db2inst2

drop schema agent restrict

implicit_schema权限:隐式创建同名模式

表设计:

唯一约束(唯一键):指定的列要是not null;自动创建唯一索引

主键:只有一个主键;not null

create table test(id int not null with default 1)

create table test2(c1 int,c2 double,c3 double generated always as(c1+c2),

                   c4 generated always as (case when c1>c2 then 1 else                        null end))

create index i1 on test2(c4)

create table db2admin.actor( actor_id int generated by default as identity,actor_name varchar(20),act_yr_birth smallint)  用户可以输入值,如未输入,则有db2生成值。

create table idn1(id integer,name char(20),dn int not null generated always as identity(start with 1,increment by 1)) db2 自动生成值

>db2 create table test3(id int) not logged initially

>db2 delete from test3        (5千万条)

事务日志已满

>db2 alter table test3 activate not logged initially with empty table

>commit

命令成功完成

alter table test4 append on  从表末尾insert (考虑定期reorg)

create table test5(id int) in userspace index in index1space

启用volatile,使用索引扫描(非全表扫描),适用行数据变化大的表。

alter table test5 volatile cardinality

alter table test6 add column xuehao varchar(20)

alter table test7 drop column id

alter table test8 alter column id set data type smalllint

alter table test9 alter column id drop not null 去掉not null

alter table test10 alter column id set default ‘123’

rename table test5 to test6    表test5不能有相关视图、触发器等等。

查看表信息:

list tables

list tables for all

list tables for schema schemaname

create table emp like test3