CREATE sequence T_SEG_SEQ minvalue 1000000000 maxvalue 9999999999 START WITH 1000000440 INCREMENT BY 1 cache 20;
创建触发器
CREATE TRIGGER T_SEG_TRI before INSERT ON T_SEG FOR each ROW
BEGIN
SELECT
T_SEG_SEQ.nextval INTO:new.ID
FROM
dual; END;
使用sql语句建表并设置主键自增
Create table
create table
(
ID VARCHAR2(40) default TO_CHAR("C##CARD_AP"."SEQ_T_EASYVISITOR"."NEXTVAL") not null,
xm VARCHAR2(10) not null,
sfzh VARCHAR2(15) not null,
tw VARCHAR2(15) not null,
fzjg VARCHAR2(5) not null,
mz VARCHAR2(10) not null,
bfsj TIMESTAMP(6) default sysdate not null,
phone VARCHAR2(20) not null,
csrq TIMESTAMP(6) not null,
fzsj TIMESTAMP(6) not null
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Add comments to the table
comment on table T_EASYVISITOR
is '访客易信息表';
-- Add comments to the columns
comment on column T_EASYVISITOR.ID
is 'ID(主键)自增';
comment on column T_EASYVISITOR.xm
is '姓名';
comment on column T_EASYVISITOR.sfzh
is '身份证号';
comment on column T_EASYVISITOR.tw
is '体温';
comment on column T_EASYVISITOR.fzjg
is '发证机关';
comment on column T_EASYVISITOR.mz
is '民族';
comment on column T_EASYVISITOR.bfsj
is '拜访时间';
comment on column T_EASYVISITOR.phone
is '电话号码';
comment on column T_EASYVISITOR.csrq
is '出生日期';
comment on column T_EASYVISITOR.fzsj
is '发证时间';
-- Create/Recreate primary, unique and foreign key constraints
alter table T_EASYVISITOR
add constraint PRI_EASYVISITOR_ID primary key (ID)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
使用触发器实现主键自增**创建表并设置主键**
Create table
create table T_CITY_BANK_OPEN
(
cbid VARCHAR2(40) not null,
citycode VARCHAR2(32),
bankcode VARCHAR2(16) not null,
bankname VARCHAR2(32) not null,
del VARCHAR2(5),
create_time TIMESTAMP(6) default sysdate not null,
update_time TIMESTAMP(6)
)
tablespace SISP_PUBLIC_TBS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table T_CITY_BANK_OPEN
add constraint PK_T_CITY_BANK_OPEN primary key (CBID)
using index
tablespace SISP_PUBLIC_TBS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);