Oracle 程序中超好用的日志记录TYPE,可以直接Copy使用
创建类型名称:logger_factory
type 说明:
create or replace type "logger_factory" as object
(
v_program_owner varchar2(100),
v_program_name varchar2(100),
v_program_lineno varchar2(100),
v_program_type varchar2(100),
v_sub_program_name varchar2(100),
v_program_param varchar2(200),
v_log_level number(1),
v_logger_id number(10),
constructor function logger_factory(pi_pkg_name in varchar2,
pi_prc_name in varchar2,
pi_iv_id in varchar2,
pi_iv_planid in varchar2)
return self as result,
constructor function logger_factory(pi_prc_name in varchar2 default null, pi_parameters in varchar2 default null)
return self as result,
member procedure debug,
member procedure debug(message in varchar2),
member procedure info(message in varchar2),
member procedure monitor(message in varchar2),
member procedure warn(message in varchar2),
member procedure error(message in varchar2),
member procedure error
);
type 主体:
create or replace type body "logger_factory"
as
constructor function logger_factory(pi_pkg_name in varchar2,
pi_prc_name in varchar2,
pi_iv_id in varchar2,
pi_iv_planid in varchar2)
return self as result
is
v_log_level_name varchar2(10);
v_records_count number;
pragma autonomous_transaction;
begin
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
if v_program_type = 'package body'
then
v_sub_program_name := upper(substr(pi_prc_name, 1, 100));
end if;
v_program_param := substr('iv_id = ' || nvl(pi_iv_id, 'null') || ', iv_planid = ' || nvl(pi_iv_planid, 'null'), 1, 200);
select z_logger_id_seq.nextval into v_logger_id from dual;
select count(1)
into v_records_count
from z_conf_log_level
where program_owner = v_program_owner
and program_name = v_program_name;
if v_records_count > 0
then
select upper(trim(log_level))
into v_log_level_name
from z_conf_log_level
where program_owner = v_program_owner
and program_name = v_program_name
and rownum = 1;
end if;
if v_log_level_name is null
then
select count(1)
into v_records_count
from z_conf_log_level
where program_owner = v_program_owner
and program_name is null;
if v_records_count > 0
then
select upper(trim(log_level))
into v_log_level_name
from z_conf_log_level
where program_owner = v_program_owner
and program_name is null
and rownum = 1;
end if;
end if;
case v_log_level_name
when 'debug'
then
v_log_level := 4;
when 'info'
then
v_log_level := 3;
when 'warn'
then
v_log_level := 2;
when 'error'
then
v_log_level := 1;
else
v_log_level := 3;
v_log_level_name := 'info';
end case;
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message)
values (
z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'init:'||v_log_level_name,
'call from : (host=' || sys_context('userenv', 'host') || ')(ip=' || sys_context('userenv', 'ip_address') || ')' || '(os_user = ' ||
sys_context (
'userenv',
'os_user') || ') : ' || sys.login_user || '@' || sys.database_name || sys.instance_num);
commit;
return;
end;
constructor function logger_factory(pi_prc_name in varchar2 default null, pi_parameters in varchar2 default null)
return self as result
is
v_log_level_name varchar2(10);
v_records_count number;
pragma autonomous_transaction;
begin
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
if v_program_type = 'package body'
then
v_sub_program_name := upper(substr(pi_prc_name, 1, 100));
end if;
v_program_param := substr(pi_parameters, 1, 200);
select z_logger_id_seq.nextval into v_logger_id from dual;
select count(1)
into v_records_count
from z_conf_log_level
where program_owner = v_program_owner
and program_name = v_program_name;
if v_records_count > 0
then
select upper(trim(log_level))
into v_log_level_name
from z_conf_log_level
where program_owner = v_program_owner
and program_name = v_program_name
and rownum = 1;
end if;
if v_log_level_name is null
then
select count(1)
into v_records_count
from z_conf_log_level
where program_owner = v_program_owner
and program_name is null;
if v_records_count > 0
then
select upper(trim(log_level))
into v_log_level_name
from z_conf_log_level
where program_owner = v_program_owner
and program_name is null
and rownum = 1;
end if;
end if;
case v_log_level_name
when 'debug'
then
v_log_level := 4;
when 'info'
then
v_log_level := 3;
when 'warn'
then
v_log_level := 2;
when 'error'
then
v_log_level := 1;
else
v_log_level := 3;
v_log_level_name := 'info';
end case;
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message)
values (
z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'init:'||v_log_level_name,
'call from : (host=' || sys_context('userenv', 'host') || ')(ip=' || sys_context('userenv', 'ip_address') || ')' || '(os_user = ' ||
sys_context (
'userenv',
'os_user') || ') : ' || sys.login_user || '@' || sys.database_name || sys.instance_num);
commit;
return;
end;
member procedure debug
is
pragma autonomous_transaction;
begin
if v_log_level >= 4
then
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message)
values (z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'debug',
v_program_owner || '.' || v_program_name || ' : line ' || v_program_lineno);
commit;
end if;
end;
member procedure debug(message varchar2)
is
pragma autonomous_transaction;
begin
if v_log_level >= 4
then
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message)
values (z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'debug',
substr(message, 1, 1024));
commit;
end if;
end;
member procedure info(message varchar2)
is
pragma autonomous_transaction;
begin
if v_log_level >= 3
then
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message)
values (z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'info',
substr(message, 1, 1024));
commit;
end if;
end;
member procedure monitor(message varchar2)
is
pragma autonomous_transaction;
begin
if v_log_level >= 3
then
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message)
values (z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'info',
substr(message, 1, 1024));
commit;
end if;
end;
member procedure warn(message varchar2)
is
pragma autonomous_transaction;
begin
if v_log_level >= 2
then
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message)
values (z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'warn',
substr(message, 1, 1024));
commit;
end if;
end;
member procedure error(message varchar2)
is
v_error_backtrace varchar2(1024);
pragma autonomous_transaction;
begin
if v_log_level >= 1
then
--sample of dbms_utility.format_error_stack:
--ora-06512: at "spuseropag.of_reports", line 209
--ora-06512: at "spuseropag.of_reports", line 3215
v_error_backtrace := substr(dbms_utility.format_error_backtrace, 1, 1024);
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message,
err_program_owner,
err_program_name,
err_program_lineno)
values (
z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'error',
substr(v_error_backtrace || dbms_utility.format_error_stack || chr(10) || message, 1, 1024),
substr(v_error_backtrace,
instr(v_error_backtrace,
'"',
1,
1) + 1,
instr(v_error_backtrace, '.') - instr(v_error_backtrace,
'"',
1,
1) - 1),
substr(v_error_backtrace,
instr(v_error_backtrace, '.') + 1,
instr(v_error_backtrace,
'"',
1,
2) - instr(v_error_backtrace, '.') - 1),
substr(v_error_backtrace,
instr(v_error_backtrace, 'line') + 5,
instr(v_error_backtrace, chr(10)) - instr(v_error_backtrace, 'line') - 5));
commit;
end if;
end;
member procedure error
is
v_error_backtrace varchar2(1024);
pragma autonomous_transaction;
begin
if v_log_level >= 1
then
--sample of dbms_utility.format_error_stack:
--ora-06512: at "spuseropag.of_reports", line 209
--ora-06512: at "spuseropag.of_reports", line 3215
v_error_backtrace := substr(dbms_utility.format_error_backtrace, 1, 1024);
owa_util.who_called_me(v_program_owner,
v_program_name,
v_program_lineno,
v_program_type);
insert into z_log(log_seq,
logger_id,
program_owner,
program_name,
sub_program_name,
program_lineno,
program_type,
program_param,
log_level,
log_message,
err_program_owner,
err_program_name,
err_program_lineno)
values (
z_log_seq.nextval,
v_logger_id,
v_program_owner,
v_program_name,
v_sub_program_name,
v_program_lineno,
v_program_type,
v_program_param,
'error',
substr(v_error_backtrace || dbms_utility.format_error_stack, 1, 1024),
substr(v_error_backtrace,
instr(v_error_backtrace,
'"',
1,
1) + 1,
instr(v_error_backtrace, '.') - instr(v_error_backtrace,
'"',
1,
1) - 1),
substr(v_error_backtrace,
instr(v_error_backtrace, '.') + 1,
instr(v_error_backtrace,
'"',
1,
2) - instr(v_error_backtrace, '.') - 1),
substr(v_error_backtrace,
instr(v_error_backtrace, 'line') + 5,
instr(v_error_backtrace, chr(10)) - instr(v_error_backtrace, 'line') - 5));
commit;
end if;
end;
end;
引用:logger logger_factory := logger_factory;
调用:logger.info();logger.error();
创建表:
1,z_log
create table z_log
(
log_seq number(10),
log_time date default sysdate,
logger_id number(10),
program_owner varchar2(100),
program_name varchar2(100),
sub_program_name varchar2(100),
program_lineno varchar2(100),
program_type varchar2(100),
program_param varchar2(200),
log_level varchar2(10),
log_message varchar2(1024),
err_program_owner varchar2(100),
err_program_name varchar2(100),
err_program_lineno varchar2(100)
)
partition by range (log_time)
(
partition p_2015_1h values less than (to_date(' 2015-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2015_2h values less than (to_date(' 2016-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2016_1h values less than (to_date(' 2016-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2016_2h values less than (to_date(' 2017-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2017_1h values less than (to_date(' 2017-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2017_2h values less than (to_date(' 2018-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2018_1h values less than (to_date(' 2018-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2018_2h values less than (to_date(' 2019-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2019_1h values less than (to_date(' 2019-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2019_2h values less than (to_date(' 2020-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2020_1h values less than (to_date(' 2020-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2020_2h values less than (to_date(' 2021-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2021_1h values less than (to_date(' 2021-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2021_2h values less than (to_date(' 2022-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2022_1h values less than (to_date(' 2022-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2022_2h values less than (to_date(' 2023-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2023_1h values less than (to_date(' 2023-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2023_2h values less than (to_date(' 2024-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2024_1h values less than (to_date(' 2024-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2024_2h values less than (to_date(' 2025-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2025_1h values less than (to_date(' 2025-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2025_2h values less than (to_date(' 2026-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2026_1h values less than (to_date(' 2026-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2026_2h values less than (to_date(' 2027-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2027_1h values less than (to_date(' 2027-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2027_2h values less than (to_date(' 2028-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2028_1h values less than (to_date(' 2028-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2028_2h values less than (to_date(' 2029-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2029_1h values less than (to_date(' 2029-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2029_2h values less than (to_date(' 2030-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2030_1h values less than (to_date(' 2030-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2030_2h values less than (to_date(' 2031-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2031_1h values less than (to_date(' 2031-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2031_2h values less than (to_date(' 2032-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2032_1h values less than (to_date(' 2032-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2032_2h values less than (to_date(' 2033-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2033_1h values less than (to_date(' 2033-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2033_2h values less than (to_date(' 2034-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2034_1h values less than (to_date(' 2034-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2034_2h values less than (to_date(' 2035-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2035_1h values less than (to_date(' 2035-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2035_2h values less than (to_date(' 2036-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2036_1h values less than (to_date(' 2036-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2036_2h values less than (to_date(' 2037-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2037_1h values less than (to_date(' 2037-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2037_2h values less than (to_date(' 2038-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2038_1h values less than (to_date(' 2038-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2038_2h values less than (to_date(' 2039-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2039_1h values less than (to_date(' 2039-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_2039_2h values less than (to_date(' 2040-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
),
partition p_default values less than (maxvalue)
tablespace users
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8m
next 1m
minextents 1
maxextents unlimited
)
);
-- create/recreate indexes
create index idx_z_log_001 on z_log (log_time)
nologging local;
-- grant/revoke object privileges
grant select, insert, update, delete on z_log to public; -- 给公共权限
2、z_conf_log_level
create table z_conf_log_level
(
program_owner varchar2(100),
program_name varchar2(100),
log_level varchar2(10)
);
-- grant/revoke object privileges
grant select, insert, update, delete on z_conf_log_level to dml_role;
grant select, insert, update, delete on z_conf_log_level to public;
3、序列 z_log_seq
create sequence z_log_seq
minvalue 1
maxvalue 9999999999
start with 1
increment by 1
cache 1000
cycle
order;