使用儲存過程建立乙個表空間

2021-05-28 13:48:48 字數 1350 閱讀 6591

set echo off

set serveroutput on

create or replace procedure sp_tmp_create_tablespace(p_in_tablespace_name in varchar2,

p_in_tablespace_path in varchar2,

p_in_tablespace_size in number,

p_in_extend_size in number) as

v_tablespace_count number(8);

v_sql              varchar2(2000);

v_errmsg           varchar2(300);

begin

select count(*) into v_tablespace_count from user_tablespaces where upper(tablespace_name)=upper(p_in_tablespace_name);

if v_tablespace_count = 0 then

v_sql := 'create tablespace ' || p_in_tablespace_name || ' nologging datafile '''|| p_in_tablespace_path || '/' ||

p_in_tablespace_name || '.dbf'' size ' || p_in_tablespace_size || 'm autoextend on next ' ||p_in_extend_size || ' maxsize

unlimited';

execute immediate v_sql;

dbms_output.put_line('tablespce ' || p_in_tablespace_name || ' has created!');

else

dbms_output.put_line('tablespce ' || p_in_tablespace_name || 'already exists.');

end if;

exception

when others then

v_errmsg:=sqlerrm;

dbms_output.put_line(v_errmsg);

return;

end sp_tmp_create_tablespace;

/exec sp_tmp_create_tablespace('tabspacename','/oradata/sanexcfg',2048,64);

drop procedure sp_tmp_create_tablespace;

MySql建立乙個儲存過程

mysql 儲存過程是從 mysql 5.0 新功能。儲存過程的長處有一籮筐。只是最基本的還是執行效率和sql 封裝。特別是 sql 封裝功能,假設沒有儲存過程,在外部程式訪問資料庫時 比如 php 要組織非常多 sql 語句。特別是業務邏輯複雜的時候,一大堆的 sql 和條件夾雜在 php 中,讓...

乙個儲存過程

create or replace package abc zys is procedure daily census end abc zys 建乙個包,包中有儲存過程daily census。不涉及任何引數。create or replace package body abc zys is pro...

乙個儲存過程

首先是建立儲存過程.drop procedure if exists externalcalltocomplete delimiter create procedure externalcalltocomplete begin drop table if exists temp1 create ta...