每個月建立下一個月的表(儲存過程)
CREATE OR REPLACE PROCEDURE LOGIN_CREATETAB
AUTHID current_user
AS
tabname VARCHAR2(200);
tabCount NUMBER;
BEGIN
select 'T_MO_ACCESS_LOG_' || to_char(sysdate+13, 'yyyymm') into tabname from dual;
select count(1) into tabCount from user_tables where table_name=tabname;
--如果存在,則刪除該表
if tabCount=0 then
execute immediate 'create table '||tabname||'
(
ACC_ID NUMBER not null,
ACC_METHOD VARCHAR2(50),
ACC_MEMO VARCHAR2(100),
ACC_NAME VARCHAR2(30),
ACC_TIMESTAMP VARCHAR2(50),
ACC_V VARCHAR2(10),
ACC_FORMAT VARCHAR2(10),
ACC_SIG VARCHAR2(50),
ACC_CHANNEL VARCHAR2(10),
ACC_ACCOUNT VARCHAR2(50),
ACC_CREATETIME DATE not null,
ACC_IMSI VARCHAR2(50) not null,
ACC_ESN VARCHAR2(32),
ACC_CATEGORY VARCHAR2(32) not null,
ACC_TERMCODE VARCHAR2(50),
ACC_PHONE VARCHAR2(32),
ACC_AREACODE VARCHAR2(32),
ACC_APPVERSION VARCHAR2(32)
)';
end if;
--建立
END LOGIN_CREATETAB;