oracle创建表以及id自增

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 ‘邮件大小’;

  1. 插入两条数据
    insert into pt_email values (id_nextval.nextval,‘测试’,’**@qq.com’,’****qq.com’,sysdate,1,1,1,‘1024KB’);
    可以看到id自增
    在这里插入图片描述
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值