zoukankan      html  css  js  c++  java
  • oracle常用知识随笔

    1、创建表空间及用户赋权

    create tablespace spaceone 
    datafile '/dev/spaceone'
    size 80m
    extent management local
    segment space management auto
    /

    extent management local
    segment space management auto 用法:

    (1)如果file 已经存在,并且在创建时指定了file size,那么就重用原文件,并应用新的size,如果没有指定file size,则保留原有的大小

    (2)如果file 不存在,oracle 将忽略该参数

    (3)如果Oracle 使用了已经存在的file,那么之前file里的数据将全部丢失

    2、创建用户及赋权

    set serveroutput on;
    set feedback off;
    set term off;
    set linesize 200;
    set define on;
    clear screen;

    declare
    susername varchar2(100):=nvl('&1','report');
    spassword varchar2(100):=nvl('&2','report');
    v_count number;
    i_l_9i number;
    i_l_count integer;
    i_l_countl integer;
    str_l_key varchar2(300):='schema_name';
    str_l_schema varchar2(300):=upper(susername);
    i_l_count3 integer;
    i_l_count4 integer;

    begin
    select count(1)
    into v_count
    from dba_users
    where username=upper(susername)

    if v_count > 0 then
    execute immediate 'drop user'||susername||'cascade';
    end if;

    execute immediate 'create user'||susername||'identified by'||spassword||
    'default tablespace ring'||
    'temporary tablespace temp'||
    'quota unlimited on ring'||
    'quota unlimited on ringidx'||
    execute immediate 'grant connect to'||susername;
    execute immediate 'grant debug connect to'||susername;
    execute immediate 'grant create trigger to'||susername;
    execute immediate 'grant create table to'||susername;
    execute immediate 'grant create view to'||susername;
    execute immediate 'grant create procedure to'||susername;
    execute immediate 'grant create database link to'||susername;
    execute immediate 'grant execute on dbms_crypto to'||susername;
    execute immediate 'grant synonym to'||susername;
    execute immediate 'grant drop any synonym to'||susername;
    execute immediate 'grant debug connect session to'||susername;
    execute immediate 'grant execute on dbms_scheduler to'||susername;
    execute immediate 'grant create job to'||susername;
    execute immediate 'grant execute on dbms_job to'||susername;
    execute immediate 'grant select_catalog_role to'||susername;
    execute immediate 'grant create external job to'||susername;
    execute immediate 'grant query rewrite to'||susername;
    execute immediate 'grant select on v_$process to'||susername;
    execute immediate 'grant select on v_$parameter to'||susername;
    execute immediate 'grant execute on dbms_lock to'||susername;
    execute immediate 'grant select on v_$lock to'||susername;
    execute immediate 'grant select on v_$session_wait to'||susername;
    execute immediate 'grant create session to'||susername;
    execute immediate 'grant select on v_$mystat to'||susername;
    execute immediate 'grant alter session to'||susername;
    execute immediate 'grant alter system to'||susername;
    execute immediate 'grant debug connect session to'||susername;
    execute immediate 'grant create sequence to'||susername
    execute immediate 'grant create type to'||susername;
    execute immediate 'grant select on all_tab_partitions to'||susername;
    execute immediate 'grant select on user_index to'||susername;
    execute immediate 'grant select on user_tables to'||susername;
    execute immediate 'grant create any directory to'||susername;

    select count(*) into i_l_9i from v$version where banner like '%9.%';

    select count(*) into i_l_count from user_tables t where t.table_name ='T_REPORT_SCHEMA';

    if (i_l_9i=0) then
    execute immediate 'grant select on v_$sga_dynamic_components to'||susername;
    end if;

    if (i_l_9i=0) then
    execute immediate 'begin dbms_stats.delete_system_stats() end';
    execute immediate 'begin dbms_stats.set_system_stats(upper(''CPUSPEEDNW''),1840) end'
    end if;

    if (i_l_count=0) then
    execute immediate 'create table T_REPORT_SCHEMA(KEY varchar2(500) not null,
    value varchar2(500) not null,
    owner varchar2(500) default user not null)';
    execute immediate 'insert into T_REPORT_SCHEMA(KEY,value,owner) values (''schema_name'',upper('||susername||'),upper('||susername||'))';
    end if;

  • 相关阅读:
    PHPStorm 2018 的安装 汉化 与使用
    aptana怎么显示空格 tab和回车等
    学习linux—— VMware 安装 ubantu 18 如何连接wifi
    [转]MAC系统下Sublime Text3 配置Python3详细教程(亲测有效)
    如何利用sql 读取辅表的最大max 和第二最大max。。。。
    利用PHPExcel导出excel 以及利用js导出excel
    yii2.0如何优化路由
    教女朋友写第一个php,php环境配置
    js 删除数组中的某一个内容
    vue 路由守卫是否携带token
  • 原文地址:https://www.cnblogs.com/dingxiansheng/p/5089852.html
Copyright © 2011-2022 走看看