DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Import Cloning

  1. #1
    Join Date
    Feb 2002
    Posts
    41

    Question

    I'm about to import a 8i NT database into a Linux 9i.
    Since I need to create a new database I would like to know if there's a way of getting the database creation script. (The one that includes tablespaces and datafiles creation), so that I can execute that script before issuing the import.

    Thanks.

  2. #2
    Join Date
    Oct 2001
    Posts
    83
    Hello,

    You can the following :

    - Create a BD using the assistant.
    - Use this script to generate a script to create you TS :


    ********************************************
    set verify off;
    set termout off;
    set feedback off;
    set pagesize 0;


    create table ts_temp (lineno number, ts_name varchar2(30),
    text varchar2(800));

    DECLARE
    CURSOR ts_cursor IS select tablespace_name,
    initial_extent,
    next_extent,
    min_extents,
    max_extents,
    pct_increase,
    status
    from sys.dba_tablespaces
    where tablespace_name != 'SYSTEM'
    and status != 'INVALID'
    order by tablespace_name;

    CURSOR df_cursor (c_ts VARCHAR2) IS select file_name,
    bytes
    from sys.dba_data_files
    where tablespace_name = c_ts
    and tablespace_name != 'SYSTEM'
    order by file_name;

    lv_tablespace_name sys.dba_tablespaces.tablespace_name%TYPE;
    lv_initial_extent sys.dba_tablespaces.initial_extent%TYPE;
    lv_next_extent sys.dba_tablespaces.next_extent%TYPE;
    lv_min_extents sys.dba_tablespaces.min_extents%TYPE;
    lv_max_extents sys.dba_tablespaces.max_extents%TYPE;
    lv_pct_increase sys.dba_tablespaces.pct_increase%TYPE;
    lv_status sys.dba_tablespaces.status%TYPE;
    lv_file_name sys.dba_data_files.file_name%TYPE;
    lv_bytes sys.dba_data_files.bytes%TYPE;
    lv_first_rec BOOLEAN;
    lv_string VARCHAR2(800);
    lv_lineno number := 0;

    procedure write_out(p_line INTEGER, p_name VARCHAR2,
    p_string VARCHAR2) is
    begin
    insert into ts_temp (lineno, ts_name, text) values
    (p_line, p_name, p_string);
    end;

    BEGIN
    OPEN ts_cursor;
    LOOP
    FETCH ts_cursor INTO lv_tablespace_name,
    lv_initial_extent,
    lv_next_extent,
    lv_min_extents,
    lv_max_extents,
    lv_pct_increase,
    lv_status;
    EXIT WHEN ts_cursor%NOTFOUND;
    lv_lineno := 1;
    lv_string := ('CREATE TABLESPACE '||lower(lv_tablespace_name));
    lv_first_rec := TRUE;
    write_out(lv_lineno, lv_tablespace_name, lv_string);
    OPEN df_cursor(lv_tablespace_name);
    LOOP
    FETCH df_cursor INTO lv_file_name,
    lv_bytes;
    EXIT WHEN df_cursor%NOTFOUND;
    if (lv_first_rec) then
    lv_first_rec := FALSE;
    lv_string := 'DATAFILE ';
    else
    lv_string := lv_string || ',';
    end if;
    lv_string:=lv_string||''''||lv_file_name||''''||
    ' SIZE '||to_char(lv_bytes) || ' REUSE';
    END LOOP;
    CLOSE df_cursor;
    lv_lineno := lv_lineno + 1;
    write_out(lv_lineno, lv_tablespace_name, lv_string);
    lv_lineno := lv_lineno + 1;
    lv_string := (' DEFAULT STORAGE (INITIAL ' ||
    to_char(lv_initial_extent) ||
    ' NEXT ' || lv_next_extent);
    write_out(lv_lineno, lv_tablespace_name, lv_string);
    lv_lineno := lv_lineno + 1;
    lv_string := (' MINEXTENTS ' ||
    lv_min_extents ||
    ' MAXEXTENTS ' || lv_max_extents);
    write_out(lv_lineno, lv_tablespace_name, lv_string);
    lv_lineno := lv_lineno + 1;
    lv_string := (' PCTINCREASE ' ||
    lv_pct_increase || ')');
    write_out(lv_lineno, lv_tablespace_name, lv_string);
    lv_string := (' '||lv_status);
    write_out(lv_lineno, lv_tablespace_name, lv_string);
    lv_lineno := lv_lineno + 1;
    lv_string:='/';
    write_out(lv_lineno, lv_tablespace_name, lv_string);
    lv_lineno := lv_lineno + 1;
    lv_string:=' ';
    write_out(lv_lineno, lv_tablespace_name, lv_string);
    END LOOP;
    CLOSE ts_cursor;
    END;

    ***********************************************
    -- spool c:\temp\create_tablespaces.sql ;
    -- set heading off ;
    -- set recsep off ;
    -- col text format a80 word_wrap ;


    -- select text
    -- from ts_temp
    -- order by ts_name, lineno;

    -- spool off;

    -- drop table ts_temp;
    *************************************************

    You have to adapt this script (remove sql order used to create system, temp, rbs TS. Review Datafile location, size...).

    - Import you DB






  3. #3
    Join Date
    Feb 2002
    Posts
    41

    Thumbs up

    Thanks for the tip pal.

  4. #4
    Join Date
    Feb 2002
    Posts
    41

    Question

    noor

    Shouldn't I also alter autoextent off for each datafile?
    i.e add those lines to create_tablespaces.sql.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width