标签:
杂谈 |
分类: oracle |
确保权限:
select * from dba_role_privs where grantee='LOGANALYSER';
创建存储过程:
create or replace procedure p_create_table
is
v_count number(10);
tableName VARCHAR2(20);begin
tableName := 'LOGDETAILS_'||to_char( sysdate,'yyyymmdd' );
--oracle存储过程实现mysql语法中的drop table table_name if exists
select count(*)
into v_count
from user_objects
where object_name = upper( tableName);
if v_count > 0 then
execute immediate 'drop table ' || tableName ||' cascade constraints';
end if;
--动态建表 Oracle中存储过程不可以执行DDL语句,但是我们可以利用动态sql语句来建立表格
Execute Immediate 'create table '||tableName||'
(
ID NUMBER(11) not null,
SYSTEM_ID NUMBER(11),
SOURCETYPE_ID NUMBER(11),
IP NVARCHAR2(20),
HITTIME TIMESTAMP(6) not null,
URL_SOURCE NVARCHAR2(1024),
URL NVARCHAR2(1000),
SIZES NUMBER(10,2) not null,
STATUS NVARCHAR2(7),
SERVERINFO NVARCHAR2(100),
SERVERSOURCE NVARCHAR2(50),
TOOLS NVARCHAR2(1024)
)tablespace TBS_LOGANALYSER
pctfree 10
initrans 1
maxtrans 255
storage