1

我正在尝试创建一个临时表空间,它的大小是“TEMP”表空间的一半。

所以像:

create temporary tablespace Temptest
TempFile 'somepath'
size ?M;

在哪里 ?=

select bytes/2/1024/1024 
  from dba_temp_files 
 where tablespace_name='TEMP';
4

1 回答 1

1

您可以编写一个使用动态 SQL 的 PL/SQL 块。就像是

DECLARE
  l_current_temp_size_mb NUMBER;
  l_sql_stmt             VARCHAR2(1000);
BEGIN
  SELECT SUM(bytes)/1024/1024
    INTO l_current_temp_size
    FROM dba_temp_files
   WHERE tablespace_name = 'TEMP';

  l_sql_stmt :=
    'CREATE TEMPORARY TABLESPACE tempTest TEMPFILE <<somepath>> size ' || 
       to_char( l_current_temp_size_mb / 2 ) ||
       ' M';
  -- Print out the SQL statement or write it to a table so that if there is an error, 
  -- you know what SQL statement was generated and can debug it.
  dbms_output.put_line( l_sql_stmt ); 
  EXECUTE IMMEDIATE l_sql_stmt;
END;
于 2012-02-17T20:54:38.450 回答