1.首先创建一个自增的函数 :
create sequence id_nextval
increment by 1
start with 1
minvalue 1
maxvalue 999999999;
2.创建表
create table email
(
id int primary key ,
subject varchar2(200) not null,
fromaddress varchar2(100) not null,
receiveaddress varchar2(100) not null,
sendDate Date not null,
isSeen int default 0 not null,
priority int default 0 not null,
isReplySign int default 0 not null,
emailSize varchar2(100) not null
);
comment on table email
is ‘邮件表’;
comment on column email.id
is ‘邮件主键id’;
comment on column email.subject
is ‘主题’;
comment on column email.fromaddress
is ‘发件人’;
comment on column email.receiveaddress
is ‘收件人’;
comment on column email.sendDate
is ‘发件时间’;
comment on column email.isSeen
is ‘是否已读’;
comment on column email.priority
is ‘优先级’;
comment on column email.isReplySign
is ‘是否需要回执’;
comment on column email.emailSize
is ‘邮件大小’;
- 插入两条数据
insert into pt_email values (id_nextval.nextval,‘测试’,’**@qq.com’,’****qq.com’,sysdate,1,1,1,‘1024KB’);
可以看到id自增