Dynamic tablespace creation script in database

Hi,
I am looking for a script which can generate create tablespace statements dynamically from the existing database so that I can run these create tablespace statements on to the new databases.
My first try is like this
SQL> select ' create tablespace ' || tablespace_name a || ' datafile ' || ' size
s)|| ' from ' || dba_free_space where tablespace_name = a ||' extent managemen
|| select initial_extent from dba_tablespaces where tablespace_name = || ' segment space management auto ;' from dba_tablespaces;
This sql should resemble the following template.
Create tablespace D0001 datafile
'/ldata/<SITE CODE>/<FILE DB NAME>/oradata/<SID NAME>/<SID NAME>_d0034a.dbf' size 640M extent management local uniform size  64K segment space management auto;
I will add datafile location later in the create tablespace script.
I want to thank you in advance for any help on this.
Regards,
prabhath

Hi Paul,
Thanks for your reply. but the statement you have given doesnt give the full output of create tablespace statement.
The output is something like this
SQL> select dbms_metadata.get_ddl('TABLESPACE',tablespace_name) from dba_tablespaces;
CREATE TABLESPACE "SYSTEM" DATAFILE
'D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL
CREATE UNDO TABLESPACE "UNDOTBS1" DATAFILE
'D:\ORACLE\PRODUCT\10.1.0\ORADA
CREATE TABLESPACE "SYSAUX" DATAFILE
'D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL
CREATE TEMPORARY TABLESPACE "TEMP" TEMPFILE
'D:\ORACLE\PRODUCT\10.1.0\ORAD
CREATE TABLESPACE "USERS" DATAFILE
'D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL8
CREATE TABLESPACE "EXAMPLE" DATAFILE
'D:\ORACLE\PRODUCT\10.1.0\ORADATA\ORC
6 rows selected.
Regards,
prabhath

Similar Messages

  • Is it possible to create Dictionary Tablespace creation in 10g database?

    Dear All,
    Is it possible to create Dictionary Tablespace creation in 10g database?
    regards,
    DB.

    Check this
    How To create dictionary managed system tablespace in 10g R2

  • Portal database creation script

    I am going to install a database for Portal very soon but ant to know if you get a creation script with it or do you have to write your own? If its the latter can anyone out there point me to a suitable script.
    Thanks in advance

    The 9i AS installation guide talks about some database requirements (supported database versions, tablespace sizes, init.ora settings, etc.) that you should review prior to beginning your install. After meeting those requirements, you can install the portal into the starter database that is created during the database install.
    null

  • Get "Creation Script" of the existing table ( in SQL database) using C# and without using SMO dlls

    Hi All,
    I need to get the "Creation Script" of the existing table using c# and without using SMO dlls (is it possible? I don't know).
    I.e. In SQL Management Studio -> right click on any table -> Script table as -> Create To  - > open in the new query editor window. This will give you the schema of the table with the constraints of the table.
    For E.g. In Northwind database, for the table "Categories", I would like to get it as show below
    USE [Northwind]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Categories](
        [CategoryID] [int] IDENTITY(1,1) NOT NULL,
        [CategoryName] [nvarchar](15) NOT NULL,
        [Description] [ntext] NULL,
        [Picture] [image] NULL,
     CONSTRAINT [PK_Categories] PRIMARY KEY CLUSTERED
        [CategoryID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO
    I would like to get the same schema using c#. Please help.
    Thanks & Regards,
    Kalai.

    SMO is the easiest way to get this. This is what Management Studio uses. If you can't use SMO, get a Profiler trace of the queries that SMO executes when generating the script and execute the same using ADO.NET.
    Regards,
    Farooq Mahmud
    Support Escalation Engineer 
    •  Microsoft Health Solutions Group

  • Can we get database creation script using any packages?

    Hi Friends,
    we will get table creation script using dbms_metadata.get_ddl package. just like that is there any way to get database creation script? i know that we can add some lines to controlfile trace to convert it into database creation script. but i would like to know whether it is possible through packages?
    thanks in advance.

    I think there's no package to use it for getting database creation script. But anyway, you can search it in [Oracle Database PL/SQL Packages and Types Reference|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/toc.htm]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Database creation scripts from a running RAC

    Hi all
    We have a two node Oracle 10g R2 RAC running on SLES 10 SP2 Itanium systems.
    We have 4 database instances running on the two nodes.
    I need to create database creation scripts for one of the databases. eg. the script should contain all current configuration of the database (i.e i dont want the script which would have been created at the time of creation of the database)
    Is this possible to achieve?
    thanks

    Hi,
    You can follow this steps to create yours scripts using notes below:
    Create Database Manually
    *How to create a RAC database using DBCA generated scripts from templates [ID 856783.1]*
    Create Database Service Manually
    *How To Configure Server Side Transparent Application Failover [ID 460982.1]*
    *10g & 11g :Configuration of TAF(Transparent Application Failover) and Load Balancing [ID 453293.1]*
    Regards,
    Levi Pereira
    Edited by: Levi Pereira on Mar 18, 2011 11:36 AM

  • VISION demo database creation scripts

    Does anyone have a copy of the VISION demo database creation scripts that they could give me. Have to try and add this into an already installed EBS system.
    rgds
    Alan

    The VISION demo database is a fully populated EBS installation delivered by rapid install. You would just use rapidwiz and select the Vision Demo, and not fresh production. You need the VISION data in order to be able to run through the various process flows. You do not want to import Vision data into a non-VISION EBS.

  • Easily fixing parameters for instance creation script

    H all,
    In the classical instance creation scripts numerous parameters are repeated even if they are similar. For example, the directory into which saving the different tablespaces is often the same. Also i'm looking for passing them as parameters. My first tries give the following:
    -> In the .bat launching the creation:
    set MY_DB_USER=sys
    set MY_DB_PWD=change_on_install
    set MY_DB_NAME=DragNFly
    set ORACLE_SID=DragNFly
    set MY_DB_CREATION_SOURCE=F:\Oracle\oradata\Instance_creation_scripts
    set MY_DB_CREATION_DESTINATION=E:\Oracle_DragNFly
    set MY_ORACLE_BIN=F:\oracle\bin
    set MY_ORACLE_HOME=F:\oracle
    mkdir %MY_ORACLE_HOME%\admin\%ORACLE_SID%\bdump
    mkdir %MY_ORACLE_HOME%\admin\%ORACLE_SID%\cdump
    mkdir %MY_ORACLE_HOME%\admin\%ORACLE_SIDD%\create
    mkdir %MY_ORACLE_HOME%\admin\%ORACLE_SID%\udump
    mkdir %MY_DB_CREATION_DESTINATION%\%ORACLE_SID%
    %MY_ORACLE_BIN%\oradim.exe -new -sid %ORACLE_SID% -startmode m
    %MY_ORACLE_BIN%\oradim.exe -edit -sid %ORACLE_SID% -startmode a
    %MY_ORACLE_BIN%\orapwd.exe file=%MY_ORACLE_HOME%\Database\PWD%MY_DB_NAME%.ora password=%MY_DB_PWD%
    %MY_ORACLE_BIN%\sqlplus /nolog connect %MY_DB_USER%/%MY_DB_PWD% @%ORACLE_SID% as sysdba
    %MY_ORACLE_BIN%\sqlplus /nolog @%MY_DB_CREATION_SOURCE%\StartCreation.sql
    -> Then in the first sql file, fixing all the variables and calling the other ones:
    DEFINE MY_DB_USER=SYS
    DEFINE MY_DB_PWD=change_on_install
    DEFINE MY_DB_NAME=DragNFly
    DEFINE MY_DB_SID=DragNFly
    DEFINE MY_DB_CREATION_DESTINATION=E:\Oracle_DragNFly
    DEFINE MY_DB_CREATION_SOURCE=F:\Oracle\oradata\Instance_creation_scripts
    DEFINE MY_ORACLE_BIN=F:\oracle\bin
    DEFINE MY_ORACLE_HOME=F:\oracle
    connect &&MY_DB_USER/&&MY_DB_PWD as SYSDBA
    -- # The following files have to be stored in the #
    -- # same repertory as the present file #
    @@CreateDBdb &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    @@CreateDBtbs &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    @@CreateDBcat &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    @@postDBcreate &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    @@CreateDBuser &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    exit;
    -> Finally one example of use in CreateDB.sql is:
    connect &&1/&&2 as SYSDBA
    set echo on
    spool &&5\&&3\Create&&3.db.log
    startup nomount pfile="&&6\init_DB.ora";
    CREATE DATABASE &&3
    MAXINSTANCES 1
    MAXLOGHISTORY 1
    MAXLOGFILES 5
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    DATAFILE '&&5\&&3\system_&&3.01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL
    DEFAULT TEMPORARY TABLESPACE &&3._TMP TEMPFILE '&&5\&&3\temp_&&3.01.dbf' SIZE 1500M REUSE
    UNDO TABLESPACE "&&3._UNDO" DATAFILE '&&5\&&3\undo_&&3.01.dbf' SIZE 500M REUSE
    CHARACTER SET WE8ISO8859P1
    NATIONAL CHARACTER SET AL16UTF16
    LOGFILE GROUP 1 ('&&5\&&3\redo_&&3.01.log', '&&5\&&3\redo_&&3.01bis.log') SIZE 102400K,
    GROUP 2 ('&&5\&&3\redo_&&3.02.log', '&&5\&&3\redo_&&3.02bis.log') SIZE 102400K,
    GROUP 3 ('&&5\&&3\redo_&&3.03.log', '&&5\&&3\redo_&&3.03bis.log') SIZE 102400K;
    spool off;
    As you can see a first problem is that i have to set the variables the first time in the .bat and a second time in the first .sql. I don't know how to use an unique file for setting all the variables i need.
    Second difficulty is: fixing names and directories is a first step but i would like to fix all the different size values in this same file. The goal is to have only one file with dozen of values to change before creating new instances instead of checking all the different parameters inside of the different files.
    What is your mind on this?
    Probably there are better examples that i don't found?
    Regards,
    Tif

    One error i didn't suspect -> don't using SID with lowercase and uppercase in the name.
    Thing i've forgotten to say: variables have to be set both in the .bat and the first .sql but they have to match too with values in the init.ora. That why i would like to simplify all these declarations with unifying them into a single file.
    If somebody can help me, please
    Tif

  • Passing variables from .bat to .sql in instance creation scripts

    Hi all,
    In the classical instance creation scripts numerous parameters are repeated even if they are similar. For example, the directory into which saving the different tablespaces is often the same. Also i'm looking for passing them as parameters from the .bat launching the instance creation. My first tries give the following:
    -> In the .bat launching the creation:
    set MY_DB_USER=sys
    set MY_DB_PWD=change_on_install
    set MY_DB_NAME=DragNFly
    set ORACLE_SID=DragNFly
    set MY_DB_CREATION_SOURCE=F:\Oracle\oradata\Instance_creation_scripts
    set MY_DB_CREATION_DESTINATION=E:\Oracle_DragNFly
    set MY_ORACLE_BIN=F:\oracle\bin
    set MY_ORACLE_HOME=F:\oracle
    mkdir %MY_ORACLE_HOME%\admin\%ORACLE_SID%\bdump
    mkdir %MY_ORACLE_HOME%\admin\%ORACLE_SID%\cdump
    mkdir %MY_ORACLE_HOME%\admin\%ORACLE_SIDD%\create
    mkdir %MY_ORACLE_HOME%\admin\%ORACLE_SID%\udump
    mkdir %MY_DB_CREATION_DESTINATION%\%ORACLE_SID%
    %MY_ORACLE_BIN%\oradim.exe -new -sid %ORACLE_SID% -startmode m
    %MY_ORACLE_BIN%\oradim.exe -edit -sid %ORACLE_SID% -startmode a
    %MY_ORACLE_BIN%\orapwd.exe file=%MY_ORACLE_HOME%\Database\PWD%MY_DB_NAME%.ora password=%MY_DB_PWD%
    %MY_ORACLE_BIN%\sqlplus /nolog connect %MY_DB_USER%/%MY_DB_PWD% @%ORACLE_SID% as sysdba
    %MY_ORACLE_BIN%\sqlplus /nolog @%MY_DB_CREATION_SOURCE%\StartCreation.sql
    -> Then in the first sql file, fixing all the variables and calling the other ones:
    DEFINE MY_DB_USER=SYS
    DEFINE MY_DB_PWD=change_on_install
    DEFINE MY_DB_NAME=DragNFly
    DEFINE MY_DB_SID=DragNFly
    DEFINE MY_DB_CREATION_DESTINATION=E:\Oracle_DragNFly
    DEFINE MY_DB_CREATION_SOURCE=F:\Oracle\oradata\Instance_creation_scripts
    DEFINE MY_ORACLE_BIN=F:\oracle\bin
    DEFINE MY_ORACLE_HOME=F:\oracle
    connect &&MY_DB_USER/&&MY_DB_PWD as SYSDBA
    -- # The following files have to be stored in the #
    -- # same repertory as the present file #
    @@CreateDBdb &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    @@CreateDBtbs &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    @@CreateDBcat &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    @@postDBcreate &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    @@CreateDBuser &&MY_DB_USER &&MY_DB_PWD &&MY_DB_NAME &&MY_DB_SID &&MY_DB_CREATION_DESTINATION &&MY_DB_CREATION_SOURCE &&MY_ORACLE_BIN &&MY_ORACLE_HOME
    exit;
    -> Finally one example of use in CreateDB.sql is:
    connect &&1/&&2 as SYSDBA
    set echo on
    spool &&5\&&3\Create&&3.db.log
    startup nomount pfile="&&6\init_DB.ora";
    CREATE DATABASE &&3
    MAXINSTANCES 1
    MAXLOGHISTORY 1
    MAXLOGFILES 5
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    DATAFILE '&&5\&&3\system_&&3.01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL
    DEFAULT TEMPORARY TABLESPACE &&3._TMP TEMPFILE '&&5\&&3\temp_&&3.01.dbf' SIZE 1500M REUSE
    UNDO TABLESPACE "&&3._UNDO" DATAFILE '&&5\&&3\undo_&&3.01.dbf' SIZE 500M REUSE
    CHARACTER SET WE8ISO8859P1
    NATIONAL CHARACTER SET AL16UTF16
    LOGFILE GROUP 1 ('&&5\&&3\redo_&&3.01.log', '&&5\&&3\redo_&&3.01bis.log') SIZE 102400K,
    GROUP 2 ('&&5\&&3\redo_&&3.02.log', '&&5\&&3\redo_&&3.02bis.log') SIZE 102400K,
    GROUP 3 ('&&5\&&3\redo_&&3.03.log', '&&5\&&3\redo_&&3.03bis.log') SIZE 102400K;
    spool off;
    As you can see a first problem is that i have to set the variables the first time in the .bat and a second time in the first .sql. I don't know how to use an unique file for setting all the variables i need.
    Second difficulty is: fixing names and directories is a first step but i would like to fix all the different size values in this same file. The goal is to have only one file with dozen of values to change before creating new instances instead of checking all the different parameters inside of the different files.
    Third problem: variables are not transmitted to the init.ora. I think that it's possible to generate it using template and the defined variables, but i don't try for the moment.
    What is your mind on this?
    Probably there are better examples that i don't found?
    Regards,
    Tif

    the problem is nothing your showed.   did you see a security warning that you ignored?
    to test, if that's the problem go here and adjust your security settings:  http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.ht ml
    if that fails, upload your files to a server and confirm everything works.  then start working on your local configuration.

  • How to exclude tablespace in logical standby database

    Dear all,
    In which way does the creation procedure of a logical standby database differ than the standard ORA9.2 procedure (http://www.oracle.com/pls/db92/db92.to_pdf?pathname=server.920%2Fa96653.pdf&remark=docindex) if I want to exclude a tablespace in my standby database?
    Excluding tablespace in physical standby database is impossible.
    Thanks in advance.

    The goal of a stand by database is to become a clone fed online with transactions coming from the active database. If the cloned database in a physical dataguard configuration diverges from the active database it is useless, as transaction control takes place at a lower level (physical addresses are involved).
    ~ Madrid

  • Data Base Creation Script

    Dear Friends,
    I had installed oracle 9i using database configuration assitance for learning purpose. Installation was successful. Now, is it possible to view the database creation script of the above created database. If it is possible, kindly share the steps. Thanks in advance.

    CHeck out the alert log of the created Database and you will find the scripts as commands in it.
    Or go to ORACLE_HOME and search for demobld.sql
    regard
    Pravin

  • Requirements to go for new TableSpace Creation ?

    Hi All,
    It is a more databse question than SAP,
    What are requirements to go for new Tablespace creation ?
    OR
    Why do we need to create new Tablespace evethough, we have around 7 default tspaces there.
    Eg : In my case TSpace PSAPVERTEX  created; vertex is US tax tool.
    I dont think database stores the application specific data in particular TSpace  like  vertex application -
    PSAPVETEX
    Please reply to me soon
    RK

    Hello Ramakrishna,
    >> Why do we need to create new Tablespace evethough, we have around 7 default tspaces there.
    That is not correct. You have one default tablespace on database level or one default tablespace for different users (user settings)... but you can never have more than one default tablespace.
    SAP creates more tablespaces to seperate the data and to structure it... but the definition, which object is stored in which tablespace is specified in the create statement of the object.
    So if objects are for the vertex application.. the create statement includes the vertex tablespace PSAPVERTEX.. if not the objects are created in the default tablespace for the user.
    Regards
    Stefan

  • Ora-12914: cannot create dictionary tablespace during tablespace creation.

    Hi All,
            I am new to Database and trying to create the dictionary tablespace in Database but its showing error like ora-12914: cannot create dictionary tablespace during tablespace creation.
    Do i need to set any parameter for this error?
    Please let me know the cause for this error.
    Regards
    Narender B

    Hi
    from doc.
    12914, 00000, "Cannot migrate tablespace to dictionary managed type"
    // *Cause: Attemp to migrate locally managed tablespace to  dictionary managed
    //         type when the database has locally managed system tablespace.
    // *Action: Command cannot be issued.
    $
    If system tablespace (I think from release 10g) is local management, all tablespaces must be local, dictionary is not possible
    HTH
    Antonio NAVARRO

  • Rollback segment is filling up during creation of the database

    Hi
    The Rollback segment is showing around 520mb immediately after
    creation of the database after following the wizard provided in
    the enterprise manager of oracle. What might be the reason. How
    to reduce it. Could any one give me a solution for this matter.
    Thanks in Advance.

    I tried creating the password file using the following command:
    orapwd file=/home/oracle/product/9.2.0/dbs/orapwHR.ora
    password=HR entries=5
    and got the same error:
    ORA-01501 Create Database failed.
    ORA-01990 -ERROR opening password file '/home/oracle/product/9.2.0/dbs/orapw'
    ORA-27037 Unable to obtain file status.
    Linux error: 2: No such file or directory.
    Additional information: 3.
    Does anybody know how to fix this problem?
    Thanks,
    Katya

  • Creation of uninitialized database 87684942 failed

    Hello,
    we get this "Error Creation of uninitialized database 87684942 failed" if we try to make a Setup-Package under MI 7.0 SP 15 with MaxDB for Client persistance.
    Our System is WebAS is NW 7.0 SP15 with usage type MI and AS ABAP and AS Java. MI is 7.0 SP 15. All on Win 2003 32-Bit with Oracle DB.
    The MaxDB is 7.6 the newest Version. The Generation-Process function well till it tries to create the DB. We've changed a lot of things in Visual Admin for MaxDB without any better result.
    Any suggestions?
    Thanks in advance.

    Hi Oliver,
    thank you.
    Maybe i have another Documentation, but this is written in the Docu:
    Installing SAP MI on the Mobile Device
    -Mobile Device Installation using Setup Packages
    --Installing MaxDB for Setup Package Creation
    ---Installing MaxDB on a system where a different version is installed
    ---Installing MaxDB on a system with no MaxDB installation
    I spend times on Installation and Setup that MI, cause the Help, Guides and Notes are so dramatically inconsistent. We can't download the DB2e from SAP nor either from IBM. Every Link is broken. If you be able to send me the DB2e we are very happy.
    For a little explanation: This is my first time i use SAP MI. All work is for my diploma. So that is too much time consuming.
    Thank you.
    Regards

Maybe you are looking for