create table SCOTT.T_TJ
(
id NUMBER(10) not null PRIMARY KEY,
yewulb VARCHAR2(20),
gxdwbm VARCHAR2(12),
tj_date DATE,
ruzhu_num NUMBER(10),
is_delete NUMBER(1) default 0
);
--Add comments to the table
comment on table SCOTT.T_TJ
is '统计';
--Add comments to the columns
comment on column SCOTT.T_TJ.id
is 'id';
comment on column SCOTT.T_TJ.yewulb
is '业务类别';
comment on column SCOTT.T_TJ.gxdwbm
is '管辖单位编码';
comment on column SCOTT.T_TJ.tj_date
is '统计日期';
comment on column SCOTT.T_TJ.ruzhu_num
is '入住数量';
comment on column SCOTT.T_TJ.is_delete
is '是否已删除';
-- 创建序列
CREATE SEQUENCE t_tj_sequence
START WITH 1
INCREMENT BY 1;
-- 创建触发器
CREATE OR REPLACE TRIGGER t_tj_trigger
BEFORE INSERT ON t_tj
FOR EACH ROW
BEGIN
SELECT t_tj_sequence.NEXTVAL INTO :NEW.id FROM dual;
END;
oracle基本建表,包含id自动递增功能
于 2024-10-22 13:46:00 首次发布