![]() ![]() SQL>CREATE DIRECTORY exp_schema AS ‘D:\Data Pump\Schema Export’ Mind here that create directory will not create any physical directory in your system. To create a directory object you can use CREATE DIRECTORY command. Create Directory Objectĭirectory object is a pointer pointing over a directory which you want your expdp utility to use when storing all exported files. Log on to database as sys userĬreating a directory object and granting privileges must be performed by DBA thus I would recommend you to log on to your database as sys user with sysdba privileges or ask your DBA to do this work for you.Ĭ:\> sqlplus / as sysdba 2.2. This directory will serve as the default location for storing all the exported files such as dump files and log files.įor this tutorial I’ll use a directory Schema Export and the location of this directory isĭ:\ Data Pump\ Schemas Export Step 2: Create Directory Object and grant it mandatory privilege. Make sure that the directory must be created on the server and not on the client system and Creation of directory must be performed by a DBA. They would need to be adopted to implement proper error handling etc.Create a directory anywhere in your system and name it whatever you want. Note: The supplied examples does not represent production quality scripts. To run this on a periodic basis please see the section " Using the Microsoft Task Scheduler" below.Edit the runReport.vbs and change the paths to pinpoint the runDbVis.vbs and sendMail.vbs.Edit the sendMail.vbs script to your needs.sqlfile ""C:\Users\ulf\test\folder with space\export.sql""" If the path contains spaces you may need to add some extra double-quotes. The path to the SQL file (-sqlfile parameter).For more information about the Run method see Microsoft Documentation Note the "0" at the end represents the intWindowStyle parameter and means that no window will be shown when running the script.Change the -sqlfile argument to specify the path to the export.sql file.Change part " -connection H2" to "-connection YourConnection" where "YourConnection" denotes the Database name defined in DbVisualizer of the database connection you want to connect to.Change the path pointing out dbviscmd.bat to the DbVisualizer installation on the computer you are running the scripts (I.e change the C:\Program Files\DbVisua.StrReturn = oShell.Run ("""C:\Program Files\DbVisualizer\dbviscmd.bat"" -connection H2 -sqlfile C:\Users\ulf\Desktop\vbs\export.sql", 0, true) Edit the file export.sql to export the data of your choice.To adopt the example scripts you would need to The script files referred to in this section are attached to this article. The CSV file is sent as an attachment in an email message. The following description assumes the scripts are located on the host/computer running the Microsoft Windows Task Scheduler. The following shows how to export data to a CSV file and then send that data to an e-mail address. You can of course create the script by hand, but a convenient way is to create a SQL script in the SQL Commander, and - when you are satisfied that it works as expected - generate the command line version for scripting it, including all connection details (see Generating a Command From SQL Commander for more info). For a Linux environment using shell script and scheduling through cron jobs.Īlthough the script examples can be used as a base for designing your own reports, the scripts lack proper error handling/logging and should be improved to handle this.For a Windows environment using VBScript and scheduling through the Microsoft Windows Task Scheduler.The following article shows you how to setup a DbVisualizer export to run at certain intervals and send the export result as an email attachment. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |