Script to Create databases with params to support dir location for data or log files

Script to Create databases with params to support dir location for data or log files

DECLARE @Query VARCHAR(MAX)=''
DECLARE @DbName VARCHAR(400) = '<DBNAME>'
DECLARE @DbFilePath VARCHAR(400) = '<Valid DataFilePath>'
DECLARE @DBLogFilePath VARCHAR(400)='<Valid LogFile Path>'
SET @Query = @Query + 'CREATE DATABASE '+@DbName +' ON PRIMARY '
SET @Query = @Query + '( NAME = '''+@DbName +''', FILENAME = '''+@DbFilePath+@DbName +'.mdf'' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) '
SET @Query = @Query + ' LOG ON '
SET @Query = @Query + '( NAME = '''+@DbName +'_log'', FILENAME = '''+@DblogFilePath+@DbName +'_log.ldf'' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)'
print @query
exec(@query)
--Prashanth

Similar Messages

  • Creating Database with Script

    Can any body guide me how to create DB with scripts, Here is the scripts
    ls -ltrtotal 6952
    -rw-r----- 1 oracle oinstall 7061504 Dec 4 11:17 tempControl.ctl
    -rw-r----- 1 oracle oinstall 2057 Dec 4 11:17 rmanRestoreDatafiles.sql
    -rwxr-xr-x 1 oracle oinstall 948 Dec 4 11:17 PSC01P1.sql
    -rwxr-xr-x 1 oracle oinstall 645 Dec 4 11:17 PSC01P1.sh
    -rw-r----- 1 oracle oinstall 682 Dec 4 11:17 postScripts.sql
    -rw-r----- 1 oracle oinstall 2634 Dec 4 11:17 initPSC01PTemp.ora
    -rw-r----- 1 oracle oinstall 2719 Dec 4 11:17 initPSC01PTempOMF.ora
    -rw-r----- 1 oracle oinstall 2621 Dec 4 11:17 init.ora
    -rw-r----- 1 oracle oinstall 185 Dec 4 11:17 CreateClustDBViews.sql
    -rw-r----- 1 oracle oinstall 915 Dec 4 11:17 CloneRmanRestore.sql
    -rw-r----- 1 oracle oinstall 1756 Dec 4 11:17 cloneDBCreation.sql
    -rw-r----- 1 oracle oinstall 954 Dec 4 11:18 postDBCreation.sql

    None of any script will help u. Followings are the steps to create manually database
    Assume you have selected f drive for the same -
    1. Choose drive with sufficient disk space
    2. create folder (folder_name)
    3. create bdump,cdump,oradata,pfile folder in (folder_name) folder
    4. open notepad and create pfile as named "init_sidname.ora" with required parameters (check parameters in sample pfile or ask to resend
    5. go to os prompt
    6. type commands
    oradim -new -sid init_sidname.ora -startmode m -pfile (path of init_sidname.ora file with filename)
    orapwd file=f:\oracle\ora92\database\pwd_nameoffile.ora password=sysdba entries=3
    create a sql script to create database with extention .sql
    set oracle_sid=sid_name
    sqlplus /nologsql>connect sys as sysdba
    password : sysdba
    sql> create spfile from pfile=(path of pfile)
    (it will create spfile in database folder of ora92 folder)
    sql> startup nomount
    sql> execute catalog.sql and catproc.sql scripts
    your database will be create and can be checked with select commands like
    select * from dba_datafiles;
    Rajesh thakur

  • Problem when creating Database with Database, OS and hardware Configuraiton

    Problem when creating Database:
    There are two problems, which I faced during creation of database. When creating database with Oracle Database Assistant. One when creating pre tuned database from CD. And second when creating customized database giving options your self.
    Problem # 1:
    When creating pre tuned database from CD. The process of creating Database is 90 % complete and is at step # 3 Initializing Database. It gives error ORA-03113: end-of-file on communication channel.
    I searched following oracle help for this problem.
    ORA-03113: end-of-file on communication channel
    Cause: An unexpected end-of-file was processed on the communication channel. The problem could not be handled by the Net8, two-task software. This message could occur if the shadow two-task process associated with a Net8 connect has terminated abnormally, or if there is a physical failure of the interprocess communication vehicle, that is, the network or server machine went down.
    Action: If this message occurs during a connection attempt, check the setup files for the appropriate Net8 driver and confirm Net8 software is correctly installed on the server. If the message occurs after a connection is well established, and the error is not due to a physical failure, check if a trace file was generated on the server at failure time. Existence of a trace file may suggest an Oracle internal error that requires the assistance of customer support.
    Conclusion:
    What I conceive from this problem and the help available is that, I have to install NET8 again. But I am not sure about the solution, please tell me whether I am rite or not.
    Problem # 2:
    When creating database with custom option. The process of creating Database is 2 % complete and is at step # 2 Creating Database Files. It gives error ORA-12571: TNS:packet writer failure.
    I searched following oracle help for this problem.
    ORA-12571: TNS:packet writer failure
    Cause: An error occurred during a data send.
    Action: Not normally visible to the user. For further details, turn on tracing and re-execute the operation. If error persists, contact Worldwide Customer Support.
    Conclusion:
    What I conceive from this problem and the help available is that, I have to install NET8 again. But I am not sure about the solution, please tell me whether I am rite or not.
    Software & Hardware Configuration are as follow:
    Software:
    Database
    Oracle 8.1.7.0.0 (Oracle8i)
    Operating System
    Microsoft Windows 2000
    5.00.2195
    Service Pack 2
    Hardware:
    x86 Family 6 Model 8 stepping
    10
    AT/AT COMPITABLE
    260,400 KB RAM

    user563502 wrote:
    I am working on Solaris 8. What is Alert_SID.log? where can I find it?
    ThanksFor the responsible of the upgrade of Oracle database, not even know what Alert log is?
    to be honest with you, this is not your work.

  • How to create database with ASM

    HI
    How to create database with ASM?
    I install vmware workstation on window XP .On virtual machine install Linux 5 enterprise (Oracle) install.
    I install oracle DB software only. Also make 3 disk for ASM .
    1 -- When I want to install oracle DB with ASM . In this process candidate disks not show . Why?
    How I can see disks ..
    so I simple install oracle DB software only.
    2 -- Now I want to create database with ASM by DBCA .
    What process I will follow ?
    Please guide me
    Thanks

    Hi
    Steps to create database with ASM.
    1.Install oracle binary with active CRS(For single node installation CRS is activated when you run root.sh) .
    2.Create disk without file ssytem.
    3.Assign disk to raw .
    4.Change owner and permission to raw devices.
    5.Configure ASM manually or USing DBCA.
    Manually ASM Configuration.
    a.Create initialization parameter file and password file.
    b.Mandatory parameter is "instance_type=asm" as per your need configure rest of parameter like db_cache_size,large_pool_size,processes,remote_login_passwordfile,shared_pool_size etc..
    c.To discover disk configure "asm_diskstring=/dev/raw/raw*"
    Using DBCA to configure ASM.
    1.In storage type section choose ASM.It will ask for password of sysdba in 10g.
    2.ASM configuration window will open -> here it create disk group -> it shows all available ASM candidate disk automatical -> choose normal redundancy,external redundancy or high redundancy.
    ASM disk also can be conbfigured with ASMLIB .
    If ASM disk is configured you can start asm instance in nomount state and query to v$asm_disk to see all candidate disk.V$asm_disk only shows disk which is configured in asm_diskstrings.
    Hope this will help U,
    Tinku

  • Problem to create database with RAC 10g with Oracle Standard Edition

    I install CRS (Cluster Ready Services), and then install Oracle 10g database. Also, I install patches 10.1.0.4. When I create database with ASM storage give me a error to create files database.
    Any idea?
    Thanks
    Edu Alcañiz

    You were right.
    http://download-uk.oracle.com/docs/html/B14203_05/intro.htm#sthref44
    under the section
    "1.3 Configuration Tasks for Oracle Clusterware and Oracle Real Application Clusters"
    "... If you use RAC on Oracle Database 10g Standard Edition, then you must use ASM."
    Thanks, problem solved.
    - Vegard

  • I am trying to get help with WMPlayer tech support Adobe Reader cant open wmpsupport.htm files why?

    i am trying to get help with WMPlayer tech support Adobe Reader cant open wmpsupport.htm files why?

    Adobe Reader opens PDF files, nothing else.

  • My laptop had to be reimaged and all software and programs were taken off.  I installed itunes again but can't access my library.  I get an error message "the folder itunes cannot be found or created and is required.  The default location for this folder

    I can't access my itunes music on my laptop after having it re-imaged.  I installed itunes again but can't access the music folder.  I get the following message when I click to open itunes:  "The folder itunes cannot be found or created, and is required.  The default location for this folder is the Music folder.
    I have an iPad2, and iPad mini, and an iPhone5 with a different number of songs on each.  I want to sync everything -- should have close to 800 songs.  Tried to get support from Apple but would be charged for help. 

    I have a Windows 7 operating system my computer runs from.

  • Do I need to create new group for standby redo log files?

    I have 10 group of redo log files with 2 members for each group for my primary database , Do I need to create new group for standby redo log files for the standby database
    Group#     Members
    ==============
    1              2
    2              2
    3             2
    4             2
    5             2
    6             2
    7             2
    8             2
    9             2
    10           2
    If So, The following statment is correct? or nto
    ALTER DATABASE ADD STANDBY LOGFILE GROUP 1 ('D:\Databases\epprod\StandbyRedoLog\REDO01.LOG',D:\Databases\epprod\StandbyRedoLog\REDO01_1.LOG');
    please correct me if am doin mistake
    becuase when I issue the statment I getting error message sayin the group is already created.

    Thanks John
    I just find the answer
    Yes, it's recomeded to add new group , for instnace If I have 10 group from 1 to 10 then the standby shoudl be from 11 to 20
    Thanks I found the answer.

  • Do we need to format data and log files with 64k cluster size for sql server 2012?

    Do we need to format data and log files with 64k cluster size for sql server 2012?
    Does this best practice still applies to sql server 2012 & 2014?

    Yes.  The extent size of SQL Server data files, and the max log block size have not changed with the new versions, so the guidance should remain the same.
    Microsoft SQL Server Storage Engine PM

  • CREATE DATABASE with data file and log file in query pane

    Hi everyone, 
    After I ran the below code I got the following error message. Can someone help me fix this?
    Thanks
    CREATE DATABASE project
    ON
    (Name= 'project_dat',
    FILENAME ='C:\project.mdf',
    SIZE = 10,
    MAXSIZE = 100,
    FILEGROWTH = 5)
    LOG ON
    (NAME = project_log,
    FILENAME = 'C:\project.ldf',
    SIZE =40,
    MAXSIZE = 100,
    FILEGROWTH = 10);
    Msg 5123, Level 16, State 1, Line 1
    CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\project.mdf'.
    Msg 1802, Level 16, State 4, Line 1
    CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
    skilo

    Hello ,
    Please go through by support site :
    Use SQL Server Enterprise Manager
    Note The instance of SQL Server Enterprise Manager that is included with SQL Server 7.0 does not support setting the default data directory and the default log directory. However, you can register your instance of SQL Server 7.0 in the instance
    of SQL Server Enterprise Manager that is included with SQL Server 2000, and you can then follow these steps to set the default data directory and the default log directory for your instance of SQL Server 7.0.
    Click Start, point to   Programs, point to
    Microsoft SQL Server, and then click Enterprise Manager.
    In SQL Server Enterprise Manager, right-click your instance of SQL Server, and then click  
    Properties.
    In the SQL Server Properties (Configure) - <Instance Name> dialog box, click the
    Database Settings tab.
    In the New database default location section, type a valid folder path in the
    Default data directory box and in the Default log directory box.
    Click OK.
    Stop your instance of SQL Server, and then restart your instance of SQL Server.
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

  • Creating databases with dbca templates after upgrades and patches

    I have a 10.2.0.1 base release Oracle Home. Over time it has been upgraded to 10.2.0.3 and quarterly security patches have been applied. Now I want to create a new database using a dbca (database configuration assistant) template.
    During the 10.2.0.3 install did the templates also upgraded to include all the 10.2.0.3 stuff? Or are they still back at 10.2.0.1?
    What about the quarterly CPU patches? Do they need to be applied to the new db after it is created?
    Thanks,
    Rob

    I opened a Service Request. Here is the official answer from Oracle support.
    QUESTION
    =========
    After applying the latest CPU(JAN2008CPU) I have created a new database using DBCA's seed template (General). Do I need to run the catcpu
    .sql on the newly created database? Are the seed templates already updated with
    the CPU?
    ANSWER
    =======
    No, as these templates are not containing the Oracle binaries that is updated by the CPU.
    Please let me know if you need further assistance regarding this issue and I will be glad to assist you further.
    Otherwise please close this SR from MetaLink.
    Thanks!
    Greetings from Oracle,
    Oracle Support Services

  • Can't Create Database with SJISYEN character set

    I am trying to create a new database in Oracle 10g using the SJISYEN character set. The summary page display in the Database Configuration wizard shows the following
    Character Sets
    Database Character Set JA16SJISYEN
    National Character Set AL16UTF16
    The database gets created successfully with no errors, but when I query the V$NLS_PARAMETERS view, the NLS_CHARACTERSET is reported as US7ASCII
    Should I be able to create a database with the SJISYEN character set with Oracle 10g?

    Can you please run the following SQL statement and see what you get:
    SQL>
    1 select * from nls_database_parameters
    2* where parameter like '%CHARACTERSET'

  • How to Configure SQLServer2008R2 to let Windows Authenticated Users Create Database with MCV4 Code First App

    Trying to Learn MVC code first with Vs2013 web express on windows 7 os computer. When code runs to create database get: An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
    Additional information: CREATE DATABASE permission denied in database 'master'.
    Have this problem with the 'OdeToFood' plurasight course as well with the
    'developing ASP.NET MvC 4 Web Applications Jump Start' MVA course.
    Re-installed sql2008r2 using window
    admin user and ran the project and get same message as when i run the project with the none admin user. 
    What are steps to allow database creation for admin user and none windows admin user?
    Daniel Howard

    David, thanks for the reply.
    I believe the problem may be something else because after adding the 
    user to 'sysadmin' and I still get the message
    Additional information: CREATE DATABASE permission denied in database 'master'.
    Perhaps I need to go to ASP.NET forum to ask the question.
    I will mark you answer as answer.
    Thanks again
    Daniel
    Daniel Howard

  • Script to Create Database from an Existing One

    I believe there is way to generate a script for re-creating a database from an existing database. But I forgot how. Anyone can Help. Thanks.

    Hi,
    Run the dbca.bat which in the oracle installer,
    In the last option you will get two options
    1)to create database
    2)create the script
    Here generate the script and run it in sql,
    Before that create the oracleservice and connect to the instance
    and run the script.
    Regards,
    Nirmal

  • Use an external HD with Airport Extreme to access it for data storage from computers  connected to the WiFi network?

    Can I connect My Passport HD into my Airport Extreme's USB port to access it from my computers (27" iMac 2012 now using Yosemite) on that Wifi network for data storage and retrieval purposes?

    Yes, if the AirPort base station's hardware supports 802.11n. The drive needs to be formatted as Mac OS Extended (Journaled), FAT16, or FAT32, and may need to be connected through an USB hub with its own power supply.
    (117777)

Maybe you are looking for