Scheduled Database Scripting

I have an oracle 10g database and I want to setup a scheduled task on the Windows server that scripts the entire database (including schema, packages, data etc) to a text file. I do not want a database export and backup but a database script.
Can you please advise how to proceed with this?

DBMS_METADATA.GET_DDL
Something like
DECLARE
CURSOR csr IS
SELECT object_type
, object_name ,owner
FROM All_Objects
WHERE object_type IN ('SEQUENCE',
'PROCEDURE',
'DATABASE LINK',
'PACKAGE',
'PACKAGE BODY',
'MATERIALIZED VIEW',
'TABLE',
'INDEX',
'VIEW',
'FUNCTION')
AND owner = 'FASTADM';
out UTL_FILE.file_type;
BEGIN
FOR c IN csr LOOP
out := UTL_FILE.fopen('DATAPUMP_DIR',c.object_name||'_'||c.object_type||'.sql','W');
UTL_FILE.put_line(out, DBMS_METADATA.get_ddl(c.object_type, c.object_name,c.owner));
UTL_FILE.fclose(out);
END LOOP;
END;
Edited by: vlethakula on Mar 14, 2013 5:09 AM

Similar Messages

  • Bouncing Apache service through schedule batch script

    Hi
    We are using Oracle11i(11.5.10.2) with Database version 10.2.0.3 on windows 2000 server.
    We are getting login page error frequently for temporary solution we are bouncing apache service frequently.
    Now i want to restart Apache service through schedule batch script ,is it possible?
    Thanks
    With Regards
    Umair

    Hi Husseinr,
    Use Windows Task Scheduler to accomplish this.
    there is no diect option to schedule the service to restart and Actually i don't have batch script to schedule through Task Scheduler.
    Why don't you try to fix the issue instead of bouncing Apache? Did you log a SR?
    We raised SR and We are Following SR also it is has been running for long time,so until SR Solution i want to bounce the Apache servie through Scheduled Batch Script.
    Thanks
    Umair

  • Unable to move my database to a new environment using database script

    I have generated a database script from my dev machine by ; right click on DB >> tasks >> generate scripts. Then on my staging environment I open the script file inside sql server management studio , and I execute the script.
    But the script raised the following errors:-
    Msg 5133, Level 16, State 1, Line 2
    Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TMS.mdf" failed with the operating system error 2 (failed to retrieve text for this error. Reason: 15105).
    Msg 1802, Level 16, State 1, Line 2
    CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
    Msg 5011, Level 14, State 5, Line 1
    User does not have permission to alter database 'TMS', the database does not exist, or the database is not in a state that allows access checks.
    Msg 5069, Level 16, State 1, Line 1
    ALTER DATABASE statement failed.
    Msg 911, Level 16, State 4, Line 3
    Database 'TMS' does not exist. Make sure that the name is entered correctly
    can anyone adivce what is the problem ?

    refer this article to find default data & log location.
    http://technet.microsoft.com/en-us/library/dd206993.aspx
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    Praveen Dsa | MCITP - Database Administrator 2008 |
    My Blog | My Page

  • MySql database scripts

    Are there MySql database scripts for all the tables?

    Julie,
    I may be out of place here but I don't think MySQL will make a good
    adatabase for Portal Server. Native MySQL is designed for
    non-transactional work. Yes MySQL now have transactions, but with the
    JDBC Isolation Levels, I have heard of people having problems with this
    functionality.
    I Suggest if you stay with open source Databases that Postgresql may be
    a better fit, as it's structure is more like Oracles except for
    translations fr varchar2 and Number formats.
    -- Well There is my 2 cents worth.
    Tony McClay
    Java Architect
    "Mr BigMAN"
    Julie wrote:
    Are there MySql database scripts for all the tables?

  • Repository database script

    Hi. Someone help me.
    I'm working with BOXIR2 SP5, I'm going to install this version, but by policy I have to provide the repository database script to the dba, in order to dba makes the repository database in a db2 database. And only then I'll install the BOXIR2.
    The question is: Where I get the repository database script for this version?
    Thanks in advanced for your help.

    Hello Manuel,
    I recommend to post this query to the [BusinessObjects Enterprise Administration|BI Platform; forum.
    This forum is dedicated to topics related to administration and configuration of BusinessObjects Enterprise, BusinessObjects Edge, and Crystal Reports Server.
    It is monitored by qualified technicians and you will get a faster response there.
    Also, all BOE Administration queries remain in one place and thus can be easily searched in one place.
    Best regards,
    Falk

  • CCB ETPM Linux Database Scripts?

    I've been recently working with CCB and ETPM over Linux platforms, and the only linux script I've found is the cdxdba.plx used to create the database. I was wondering if there are Linux version of the Windows database scripts to upgrade/export/etc tasks.

    The answer perhaps is "No".
    You'll need a Windows machine/desktop with Oracle client to connect to the database installed on the *NIX platform. Database tools, to generate security and database upgrade require Windows.                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Scheduling a script performing database backup

    I wrote a script performing a backup of all databases located on a SQL Server's instance using the Backup-SqlDatabase command. As a script from the Windows Powershell ISE it works fine. I am working on a Windows Server 2012
    The next step is to schedule this from the Windows Task Scheduler. The Action program is PowerShell and the arguments is -command "& 'C:\folder\myscript.ps1'" and it doesn't work, the script appears to fire off but it doesn't
    perform the backup. The error looks strange it looks like it can't connect to the SQL Instance, I tried a whole bunch of options I found googling around but none worked. What am I missing ?

    1) Using -File instead of -Command didn't work, it didn't even fire the script
    2) I have got 'Run with the highest privileges' selected
    3) The error
    4) The script
    # backup_AllDb.ps1
    # Full backup for database for specified SQL instance
    # Change log:
    # July 3, 2012: Thomas LaRock, http://thomaslarock.com
    # Initial Version
    # Get the SQL Server instance name from the command line
    # leaving $dest null will result in default backup path being used
    param(
    [string]$inst=$null,
    [string]$dest=$null
    # Load SMO assembly, and if we're running SQL 2008 DLLs load the SMOExtended and SQLWMIManagement libraries
    $v = [System.Reflection.Assembly]::LoadWithPartialName( 'Microsoft.SqlServer.SMO')
    if ((($v.FullName.Split(','))[1].Split('='))[1].Split('.')[0] -ne '9') {
    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMOExtended') | out-null
    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SQLWMIManagement') | out-null
    # Handle any errors that occur
    Function Error_Handler {
    Write-Host "Error Category: " + $error[0].CategoryInfo.Category
    Write-Host " Error Object: " + $error[0].TargetObject
    Write-Host " Error Message: " + $error[0].Exception.Message
    Write-Host " Error Message: " + $error[0].FullyQualifiedErrorId
    Trap {
    # Handle the error
    Error_Handler;
    # End the script.
    break
    If ($inst -eq "")
    { $inst = "MYSERVERNAME\MYINSTANCE" };
    $srv = new-object ('Microsoft.SqlServer.Management.Smo.Server') $inst
    # If missing set default backup directory.
    If ($dest -eq "")
    { $dest = "C:\SQLBackups" };
    Write-Output ("Started at: " + (Get-Date -format yyyy-MM-dd-HH:mm:ss));
    cd SQLSERVER:\SQL\$inst\Databases
    #start full backups
    foreach($database in (Get-ChildItem -Force)) {
    $dbName = $database.Name
    if ($dbName -ne "tempdb") {
    $timestamp = Get-Date -Format MMddyyHHmm
    $bakFile = $dest + "\" + $dbName + "_full_" + $timestamp + ".bak"
    Backup-SqlDatabase -Database $dbName -Initialize -BackupFile $bakFile
    Write-Output ("Finished at: " + (Get-Date -format yyyy-MM-dd-HH:mm:ss));

  • Schedule rman script in Windows 2003

    Oracle 10.2. I wrote a rman script and tried to schedule auto run in Windows 2003 server. I got this errors:
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00554: initialization of internal recovery manager package failed
    RMAN-04005: error from target database:
    ORA-12560: TNS:protocol adapter error
    The batch file name: rman_backup.bat
    content: rman target / cmdfile rman_backup.rcv log rman_backup.log
    Here is how I set it up:
    go to Control Panel>Scheduled Tasks>Add Scheduled Task, find rman_backup.bat, choose the run time and finish it. When asking for user name and password, I supply the user which is in oracle dba group.
    But when it run, it just produced the above error and won't run.
    Please advise
    S.
    in SQLnet.log
    fatal NI connect error 12560, connecting to:
    (DESCRIPTION=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGV0=oracleORCL)(ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))'))(CONNECT_DATA=(SID=ORCL)(CID=(PROGRAM=D:\oracle\product\10.2.0\db_1\bin\rman.exe)(HOST=W3TY5Z203)(USER=WELC))))
    VERSION INFORMATION:
         TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
         Oracle Bequeath NT Protocol Adapter for 32-bit Windows: Version 10.2.0.4.0 - Production
    Time: 30-MAR-2010 11:27:00
    Tracing not turned on.
    Tns error struct:
    ns main err code: 12560
    TNS-12560: TNS:protocol adapter error
    ns secondary err code: 0
    nt main err code: 530
    TNS-00530: Protocol adapter error
    nt secondary err code: 2
    nt OS err code: 0

    here is example of script we are using to backup database from windows scheduler:
    set oracle_home=d:\oracle\ora920
    set path=d:\perl\bin;d:\oracle\ora920\bin;c:\winnt;c:\WINDOWS\system32;
    set PERL5LIB=''
    set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
    set TNS_ADMIN=d:\oracle\ora920\network\admin
    d:
    cd \scripts
    set oracle_sid=car
    rman target sys/car_$z3br4 catalog rman/oemrp_pwd@oemrp @rman_level0_car.rman > rman_level0_car.log
    perl email_log.pl "RMAN Level 0 Log" d:\scripts\rman_level0_car.log CARthis script backing up 9i database. 10g and 11g database we backing up via EM grid control.
    You can change this script to backup 10g or 11g databses as well.

  • Schedule backup script ICM

    Hello,
    I'm trying to backup script (*.ICMS) with schedule task, do you now if it's possible?
    I find the manual export in script editor but do it one by one ...
    I need your help
    Thanks a lot

    You cannot "back up" an individual .icms file.
    If you back up the logger (xxxx_sideA) database, that will include all the Scripts (along with all your other configuration).
    iow - the Scripts are part of the ICM database, not a separate entity.

  • Scheduling RMAN script on windows

    I want to schedule the following full database backup script to run every night at 10pm. Can anyone guide me how I can schedule it on windows OS but please don't suggest OEM as currently I have it scheduled thought OEM only.
    run
    allocate channel ch1 type disk format 'f:\backup\full_db_%D_%T.bak';
    backup database;
    }

    You can try to use DBMS_SCHEDULER. Following messages should help.
    Re: need backup script
    Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files

  • Dbms scheduler shell script security

    We are trying to setup database accounts to run external jobs using dbms_scheduler. With each user only having access to certain directories through mapped database directories.
    Example:
    DB User1 -> /home/user1/...
    DB User2 -> /home/user2/..
    The problem is, the User1 seems to be able create jobs that run scripts under user2 directories and visa versa. Worst yet, both db users can create jobs that run scripts in the Oracle home directory. Huge security hole. Is there a way to lock this down? I believe all scheduled jobs run as Oracle.
    Thanks.

    Hi,
    In 10g there is no way to do this using dbms_scheduler. In 10g all users running external jobs (who must have the CREATE EXTERNAL JOB privilege) have their jobs run as the same OS user (what user the jobs run as is configurable). The only exception is jobs in the SYS schema which always run as the oracle user.
    In 11g, you can use credential objects to have different database users run jobs as different OS users.
    For more information see this post
    Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files
    Hope this helps,
    Ravi.

  • Need a help in scheduling shell script

    I am using following script to check db status.
    check_stat=`ps -ef|grep ${ORACLE_SID}|grep pmon|wc -l`;
    oracle_num=`expr $check_stat`
    if [ $oracle_num -lt 1 ]
    then
    exit 0
    fi
    # Test to see if Oracle is accepting connections
    $ORACLE_HOME/bin/sqlplus -s "/as sysdba" > /tmp/check_$ORACLE_SID.ora <<ENDSCRIPT
    select name from v\$database;
    exit
    ENDSCRIPT
    # If not, exit and e-mail . . .
    check_stat=`cat /tmp/check_$ORACLE_SID.ora|grep -i error|wc -l`;
    oracle_num=`expr $check_stat`
    if [ $oracle_num -ne 0 ]
    then
    mailx -s "$ORACLE_SID is down!" [email protected] < /tmp/check_$ORACLE_SID.ora
    #else
    #mailx -s "$ORACLE_SID is up and running" [email protected] < /tmp/check_$ORACLE_SID.ora
    exit 16
    fi
    while executing at command prompt, it is working fine. I need to know what lines i need to add to schedule this in a crontab?
    thanks in advance

    Pavan - a DBA wrote:
    i am trying to schedule it so that it will run for every 15 min
    0,15,30,45 * * * * myscriptI don't have access to a *nix at the moment, so I may be off on the number of asterisks, but you get the idea on minutes and hours                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to insert the new field to standard scheduling agreement script form.

    Hi Gurus,
    how to insert the new fields to standad sheduling agreement script form. its a need for me, i want to display the AEDAT field in scheduling agreement form ,
    The below one is my requirement,
    ex:-   Itu2019s requested the change of Scheduling Agreement printout. Itu2019s requested for this type of   document, the insertion, into the field u201CData Emissionu201D into the print, of the document last modify date instead of the document creation date. (This change will be done only for position change into the Scheduling Agreement). No change into the PO.
    Change SAPSCRIPT printout. Introduction, into the Scheduling Agreement, of last modified  
          document date (field EKPO-AEDAT).
    Thanks & Regards
    chinnu

    open TNAPR table and give the output type you need to modify.... get the print program name and check if some structure already have the date you wanted... if you have it already... then open the form in SE71 tr. and provide the strcuture name - feild in the position you want to have the date...
    se71--->
    &<str. name>-AEDAT&

  • How can I use firefox to access Oracle's 10g Express Edition Database script editor?

    I have installed Oracle's 10g Express Edition (xe) Database in my computer, which is running Ubuntu 10.04 64-bit. I can access the database through the command line and by using the web interface on Firefox. However, the script editor doesn't work with Firefox. The scripts are not shown and I'm unable to edit them.

    I have installed Oracle's 10g Express Edition (xe) Database in my computer, which is running Ubuntu 10.04 64-bit. I can access the database through the command line and by using the web interface on Firefox. However, the script editor doesn't work with Firefox. The scripts are not shown and I'm unable to edit them.

  • System.Drawing.Bitmap in a scheduled powershell script

    I've written a powershell script to date stamp multipage tiffs, but I check to make sure the file name follows the correct format before doing so. The file name must contain the date, sequence number, and number of pages. The script works fine when run manually,
    but when run from task scheduler it fails to query the number of pages in the TIFF. Any ideas why the .NET features wouldn't work from a powershell script run as a scheduled task?
    I am putting the page number in the variable "count" by doing the following:
     $i=[System.Drawing.Bitmap]::FromFile($file.Fullname);$i.GetFrameCount($i.FrameDimensionsList[0]) 
     $count=$i.GetFrameCount([System.Drawing.Imaging.FrameDimension]::Page)
    FULL SCRIPT FOLLOWS
    #Define the input and output folders and date format
    $Original_TIFFs="C:\scans"
    $Modified_TIFFs=";\\test\Shared\SDS\"
    $date = get-date -Format d
    $datename=Get-Date -format yyyyMMdd
    Set-Location $Original_TIFFs
    #Configure email settings
    $emailFrom = "removed"
    $emailTo = "removed"
    $smtpServer = "removed"
    $body = "Rename scanned claims file to the correct format. This email was sent from: ", $env:computername
    #Define the location of the TIFF command line executable and its parameters
    $200DLL='C:\TiffDLL200Commandline\Cmd200.exe '
    $arg1='"FILE='
    #Modify arg2 to put the output directory in front of the ; if don't want to overwrite current file
    #$arg2=';|OW=Yes|BITS=2|TEXT=2;Received Date: '
    $arg2=$modified_TIFFs
    $arg3=';|BITS=2|TEXT=2;Received Date: '
    $arg4='|TEXTOPS=-5;;10;14;"'
    $files=Get-ChildItem $Original_TIFFs -Filter *.tif
    if ($files -eq $null)
      $subject = "No files to process today, directory empty."
      $smtp = new-object Net.Mail.SmtpClient($smtpServer)
      $body = "No files were processed today. This email was sent from: ", $env:computername
      $smtp.Send($emailFrom, $emailTo, $subject, $body)
    else
    foreach ($file in $files)                                                                  
       #Begin loop to check each file and process
     #Loads subsystems for opening TIFFs and second line puts the number of images into variable
     $i=[System.Drawing.Bitmap]::FromFile($file.Fullname);$i.GetFrameCount($i.FrameDimensionsList[0]) 
     $count=$i.GetFrameCount([System.Drawing.Imaging.FrameDimension]::Page)
     #If statement checks if filename format is correct
     if ($file -match '^\d{8}\d{3}_H_S_\d+_\d{8}[.tif]{4}$')
      $file.name -match '^(?<date1>\d{8})\d{3}_H_S_(?<page_count>\d+)_(?<date2>\d{8})[.tif]{4}$'   #Regex to put tests in $matches to check against
      if (($matches.date1 -eq $datename) -and ($matches.date2 -eq $datename))                      #Check if filename contains correct date
      if ($count -eq $matches.page_count)                                                          #Check if filename
    contains the correct page count
       #insert TIFF modification
        $allargs=$200Dll+$arg1+$file+$arg2+$file+$arg3+$date+$arg4
        cmd /c $allargs
        #cmd /c xcopy $file \\test\shared\SDS                                                   #Deprecated because now having
    TIFF200DLL create a new file rather than overwrite
        $i.Dispose()                                                                  
                #Close file stream so file can be deleted: http://support.microsoft.com/kb/814675
        Remove-Item $file.Name
        #Next section is for a different output directory; Setup a seperate batch file to delete original TIFFs in the middle of the night
        <#
        $allargs="cmd200 "+$arg1+$file+";"+$Modified_TIFFs+";"+$arg2+$date+$arg3
        cmd /c $allargs
        #>
        else                                                                    
                     #else statement to send out error message if the number of pages differs from name
        $subject = "The number of pages in the file ", $file.FullName, "differs from the actual count of ", $count, ". File will not be sent, please correct before tomorrow for processing."
        $smtp = new-object Net.Mail.SmtpClient($smtpServer)
        $smtp.Send($emailFrom, $emailTo, $subject, $body)
      }  #Close IF/THEN for correct date is in filename
     else
        $subject = "Date portion of filename is incorrect, please fix. File will not be sent to SDS", $file.FullName," ."
        $smtp = new-object Net.Mail.SmtpClient($smtpServer)
        $smtp.Send($emailFrom, $emailTo, $subject, $body)
     }                                                    #Close IF/THEN for initial filename check
     else
        $subject = "File does not meet proper naming convention and will not be stamped nor sent to SDS", $file.FullName, " ."
        $smtp = new-object Net.Mail.SmtpClient($smtpServer)
        $smtp.Send($emailFrom, $emailTo, $subject, $body)
    }                                                     #Close FOR loop
    }                                                     #Close Else for check if FILES=NULL

    You are buikding thisin the ISE?
    You need too add:
    add-type -AssemblyName System.Drawing
    ¯\_(ツ)_/¯

Maybe you are looking for

  • OIM to OID direct provisioning to a particular OU

    Hello - Can some one suggest if provisioning to a partciluar ou in OID directory is possible from OIM using configuration as oppose to coding? let say, my DIT looks like this: dc=abc,dc=com o=Org-A -     ou=unit1A -     ou=unit2A -     ou=unit10A o=O

  • Is my DVD/CD drive dead?

    I just burned a DVD-R and usually I can see the disc show up on my desktop and in Finder after it's done burning. This time I don't see it anywhere. I can pop the disc into my MacBookPro and it reads fine. Is there a way to test the drive in my MacPr

  • Changing Resolution

    I am using Aperture v. 2.1.4. I have stills that are 2896 x 1944. How can change the resolution to something smaller?

  • "SAP Crystal Reports, developer version for Microsoft Visual Studio" (CRforVS_13_0_9.exe) has error during Installation.

    Hello, I just tried to install the new file CRforVS_13_0_9.exe on a Windows 7 Ultimate machine. I have Visual Studio 2013 and wanted Crystal Reports to be fully integrated with it. By the way, I had already uninstalled CRforVS_13_0_8.exe before I att

  • Blog entry: macs can't see, pc's can?

    I am unable to view the text or main photo of my blog entry. It looks fine in iWeb, and all PC users can view - just not those on a mac? I can't see the text or main photo on my mac at work either. I have tried re-publishing several times, but for so