Command Line Interface

Similar documents
DbVisualizer 9.5 Users Guide. DbVisualizer 9.5 Users Guide

Yellowfin Custom Installer Guide

Subcontractors. bc math help for the shell. interactive or programatic can accept its commands from stdin can accept an entire bc program s worth

Copyright Yellowfin International pty ltd

Introduction to the Shell

Managing Your Database Using Oracle SQL Developer

SAP HANA database is. What is SAP HANA Appliance?

Oracle Big Data Cloud Service, Oracle Storage Cloud Service, Oracle Database Cloud Service

Package sjdbc. R topics documented: December 16, 2016

Configuring a JDBC Resource for MySQL in Metadata Manager

Lab Exercise: Install & Configure OHDSI Tech Stack

Deploy Oracle GoldenGate Veridata Version 3.0 for comparison between Oracle RDBMS databases replicated using OGG 11gR2

Lab 19: Event Handlers for User Entities

Portfolio Utility Installation & User Guide

Crate Shell. Release

Configuring a JDBC Resource for IBM DB2/ iseries in Metadata Manager HotFix 2

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Using DbVisualizer Variables

DBCrane User s Guide (Version 2.0.0)

Introduction: What is Unix?

Configuring a JDBC Resource for IBM DB2 for z/os in Metadata Manager

Chapter 9 SQL in a server environment

! An organized collection of data. ! Can easily be accessed, managed, and updated. ! Data are organized as a set of tables.

Tcl/Tk for XSPECT a Michael Flynn

... jdbcinfo v Project Documentation... IBM CDA LTD

HCP Data Migrator Release Notes Release 6.1

Using SQL Developer. Oracle University and Egabi Solutions use only

Chapter 4. Unix Tutorial. Unix Shell

Working with Databases

Database Explorer Quickstart

You can import data from a CSV file into an existing table or to a new table. The steps are almost identical:

Talend Open Studio for Data Quality. User Guide 5.5.2

Textbook. Topic 8: Files and Exceptions. Files. Types of Files

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

Unix Shells and Other Basic Concepts

Configuring Databases

COMP 4/6262: Programming UNIX

Rundeck. A smart software for lazy people. Claudio IMGT - IGH Montpellier BioInformatics Meeting

Overview. ❶ Short introduction to the company. ❶ Short history of database and DBMS. ❶ What is the next DBMS s generation? ❶ Introduction to Tamino

System Guide. Version 4.7

Alcatel-Lucent VitalQIP

Algolytics AdvancedMiner Installation

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell.

TIBCO MFT Internet Server Desktop Client. Software Release September 2014

Some Useful Options. Code Sample: MySQLMonitor/Demos/Create-DB.bat

Introduction to Linux. Fundamentals of Computer Science

Configuring a JDBC Resource for Sybase IQ in Metadata Manager

CompTIA Linux+ Guide to Linux Certification Fourth Edition. Chapter 2 Linux Installation and Usage

Scaffold Hunter: By Stefan Wetzel. 1. Installation of MySQL 5.x

TIBCO Slingshot User Guide. Software Release August 2015

Nimsoft Documentation

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

Hitachi Content Platform HCP Data Migrator 6.1 Release Notes HCP-DM Version June 27, 2014

Using the IMS Universal Drivers and QMF to Access Your IMS Data Hands-on Lab

IceWarp to IceWarp Migration Guide

Creating Domain Templates Using the Domain Template Builder 11g Release 1 (10.3.6)

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

Universal CMDB. Software Version: Content Pack (CP20) Discovery and Integrations Content Guide - Discovery Activities

Using the IMS Universal Drivers and QMF to Access Your IMS Data Hands-on Lab

PT-X Drive. Installation Guide

Aware IM Version 8.1 Installation Guide

CSCI2467: Systems Programming Concepts

CHAPTER 44. Java Stored Procedures

Ibis RMI User s Guide

Model Question Paper. Credits: 4 Marks: 140

Including Dynamic Images in Your Report

LAE Release Notes. Version 1.0

Installation of Actiheart Data Analysis Suite:

COWLEY COLLEGE & Area Vocational Technical School

Nimsoft Unified Monitoring Portal

Chapter 1 - Introduction. September 8, 2016

If Informatica Data Replication is not currently installed, complete a first-time installation. Otherwise, complete the upgrade procedure.

Managing Databases. Prerequisites. Information About the Database Administration Tools CHAPTER

Bedework Calendar Deployment Manual

SPECCHIO Administrators

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Operating Systems. Copyleft 2005, Binnur Kurt

ITCS Implementation. Jing Yang 2010 Fall. Class 14: Introduction to SQL Programming Techniques (Ch13) Outline

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

Who s Afraid of SQL Injection?! Mike Kölbl Sonja Klausburg Siegfried Goeschl

How To Guide Using and Developing Custom Phases in IKAN ALM

Datasource configuration with GlassFish 4.x

Third Party Software: How can I import data from MySQL to Hadoop with Apache Sqoop? How can I import data from MySQL to Hadoop with Apache Sqoop?

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

Processes and Shells

(C) Global Journal of Engineering Science and Research Management

Upgrade Guide. This document details the upgrade process for customers moving from the full version of OnApp Cloud v2.3.1 to v2.3.2.

TIBCO Spotfire Automation Services

Orgnazition of This Part

Linux & Shell Programming 2014

1Z Oracle. MySQL 5 Database Administrator Certified Professional Part I

Oracle Weblogic products are available at

Kaivos User Guide Getting a database account 2

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Getting Started With Data Sync

TIBCO Spotfire Automation Services 7.5. User s Manual

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Transcription:

Command Line Interface In addition to the DbVisualizer GUI tool, there is also a pure command line interface for running scripts. We recommend that you use this interface for tasks that you schedule via the operating system's scheduling tool, or when you need to include database tasks in a command script for a larger job. It is also the right tool for execution of large scripts, such as a script generated by the DbVisualizer Export Schema feature. Command Line Options Examples Executing single statements Executing scripts Controlling the output Combining OS scripts, the command line interface and DbVisualizer variables Setting up the connection properties on the command line On Windows and Linux/Unix, you find this command as a BAT file ( dbviscmd.bat) or a shell script ( dbviscmd.sh) in the DbVisualizer installation directory. For macos, the shell script is located in /Application/DbVisualizer-<Version>.app/Contents/Resources/app. Command Line Options The command line interface supports the following options: Usage: dbviscmd (-connection <name> -url -drivername -url -driverclass -driverpath)) [-userid <userid>] [-password <password>] -sql <statements> -sqlfile <filename> [-encoding <encoding>] [-catalog <catalog>] [-schema <schema>] [-maxrows <max>] [-maxchars <max>] [-stoponerror] [-stoponwarning] [-stripcomments true false] [-output all none log result] [-outputfile <filename>] [-listconnections] [-debug [-debugfile <filename>] [-prefsdir <directory>] [-masterpw <password>] [-help] [-version] Options: -connection <name> Database connection name (created with the GUI) -url <URL> Database URL -drivername <name> Database driver name (created with the GUI) -driverclass <name> Full name of the JDBC Driver class name -driverpath <p1:p2..> Paths to the jar files constituting the JDBC driver. Each path separated by a ":" -userid <userid> Userid to connect as -password <password> Password for userid -sql <statements> One or more delimited SQL statements -sqlfile <filename> SQL script file to execute -encoding <encoding> Encoding for the SQL script file -catalog <catalog> Catalog to use for unqualified identifiers -schema <schema> Schema to use for unqualified identifiers -maxrows <max> Maximum number of rows to display for a result set -maxchars <max> Maximum number of characters to display for a column -stoponerror Stop execution when getting an error

-stoponsqlwarning -stoponnorows affected rows -stripcomments is -output sets Stop execution when getting an SQL warning Stop execution when empty result set or no Strip comments before sending to database. Default the setting made in the GUI "all" (default), output both log msgs and result "none", suppress both log messages and result sets "log", output only log messages "result", output only result sets -outputfile <filename> Script execution output file. Default is stdout -listconnections Lists all database connections -debug Write debug messages -debugfile <filename> File for debug messages. Default is stderr -errordir <directory> Use an alternate location for error logs -prefsdir <directory> Use an alternate user preferences directory -masterpw <password> Master Password for encrypted database passwords -help Display this help -version Show version info There are two options to to specify which database to connect to Using a connection already defined by the GUI tool. This is done by using the -connection parameter. If you have forgot the connection name, use the -listconnections option to get a list of all connection names. Specifying the connection properties by using the parameter -url. The -url parameter specifies the JDBC URL for the database to connect to. For information about the JDBC url see Setting Up a Connection Manually. There are also some examples below showing how to specify connection properties using the -url parameter Examples Executing single statements You can use the command line interface to execute a single SQL statement:

> dbviscmd.bat -connection "Oracle" -sql "select * from hr.countries" 14:34:48 START Executing Command Line, Database Connection: Oracle 14:34:48 INFO Physical database connection acquired for: Oracle ZM Zambia 4 14:34:48 SUCCESS [SELECT - 25 rows, 0.007 secs] Result set fetched 14:34:48 END Execution 1 statement(s) executed, 25 row(s) affected, exec /fetch time: 0.007/0.005 secs [1 successful, 0 errors] If you like to execute just a few statements, you can pass in a list of statements:

> dbviscmd.bat -connection "Oracle" -sql " select * from hr.regions" 14:42:21 START Executing Command Line, Database Connection: Oracle 14:42:21 INFO Physical database connection acquired for: Oracle ZM Zambia 4 14:42:21 SUCCESS [SELECT - 25 rows, 0.004 secs] Result set fetched REGION_NAME --------- ---------------------- 5 Australia 6 South America 1 Europe 2 Americas 3 Asia 4 Middle East and Africa 14:42:21 SUCCESS [SELECT - 6 rows, 0.003 secs] Result set fetched select * from hr.regions; 14:42:21 END Execution 2 statement(s) executed, 31 row(s) affected, exec /fetch time: 0.007/0.002 secs [2 successful, 0 errors] Executing scripts If you frequently want to execute a number of statements, it's best to put them into a script file. Here's how to execute a script that contains the two statements from the example above:

> dbviscmd.bat -connection "Oracle" -sqlfile "myscript.sql" 14:45:11 START Executing Command Line, Database Connection: Oracle 14:45:11 INFO Physical database connection acquired for: Oracle ZM Zambia 4 14:45:11 SUCCESS [SELECT - 25 rows, 0.004 secs] Result set fetched REGION_NAME --------- ---------------------- 5 Australia 6 South America 1 Europe 2 Americas 3 Asia 4 Middle East and Africa 14:45:11 SUCCESS [SELECT - 6 rows, 0.003 secs] Result set fetched select * from hr.regions; 14:45:11 END Execution 2 statement(s) executed, 31 row(s) affected, exec /fetch time: 0.007/0.002 secs [2 successful, 0 errors] Controlling the output You can use options to control how much output to generate. If you only want to see the results, use the -output option with the result keyword:

> dbviscmd.bat -connection "Oracle" -sqlfile "myscript.sql" -output result ZM Zambia 4 REGION_NAME --------- ---------------------- 1 Europe 2 Americas 3 Asia 4 Middle East and Africa For other scripts, for instance a script containing INSERT statements, you may only want to see the log messages: > dbviscmd.bat -connection "Oracle" -sqlfile "myscript.sql" -output log 14:25:29 START Executing Command Line, Database Connection: Oracle 14:25:30 INFO Physical database connection acquired for: Oracle 14:25:30 SUCCESS [SELECT - 25 rows, 0.012 secs] Result set fetched 14:25:30 SUCCESS [SELECT - 4 rows, 0.009 secs] Result set fetched select * from hr.regions; 14:25:30 END Execution 2 statement(s) executed, 29 row(s) affected, exec /fetch time: 0.021/0.004 secs [2 successful, 0 errors] Combining OS scripts, the command line interface and DbVisualizer variables

For more complex tasks, you can call the command line interface from a shell script, for instance a Bourne shell script on Unix or a BAT file on Windows. You can also use DbVisualizer variables to pass information between the shell script and the SQL script. In this example, we have a simple SQL script ( cmdtest.sql) that contains a SELECT statement with a variable in place for the table name: select * from ${table}$ cmdtest.sql A text file ( tables.txt) contains the table names we want to execute the SQL script with: hr.countries hr.regions tables.txt In a command shell (Bourne or Bash), we can then execute the script using the table names from the text file: for name in `cat tables.txt`; do./dbviscmd.sh -connection "oracle" -sql "@run cmdtest.sql \${table $name nobind}\$; "; done 15:01:19 START Executing Command Line, Database Connection: oracle 15:01:20 INFO Physical database connection acquired for: oracle 15:01:20 RUNNING [@run...ntries nobind}$ - - secs] @run cmdtest.sql ${table hr.countries nobind}$;

ZM Zambia 4 15:01:20 SUCCESS [SELECT - 25 rows, 0.016 secs] Result set fetched 15:01:20 SUCCESS [@run...ntries nobind}$ - 0.016 secs] Script processed @run cmdtest.sql ${table hr.countries nobind}$; 15:01:20 END Execution 1 statement(s) executed, 25 row(s) affected, exec /fetch time: 0.016/0.012 secs [1 successful, 0 errors] java -cp /Users/ulf/work/github/dbvis/trunk/pureit/apps/dbvis/classes: /Users/ulf/work/github/dbvis/trunk/pureit/apps/dbvis/resources:/Users/ulf /work/github/dbvis/trunk/pureit/apps/dbvis/external/* -Xmx512M -Djava.awt. headless=true -Ddbvis.home=/Users/ulf/work/github/dbvis/trunk/pureit/apps /dbvis com.onseven.dbvis.dbvisualizercmd -masterpw stairway -connection oracle -sql @run cmdtest.sql ${table hr.regions nobind}$; 15:01:23 START Executing Command Line, Database Connection: oracle 15:01:23 INFO Physical database connection acquired for: oracle 15:01:23 RUNNING [@run...egions nobind}$ - - secs] @run cmdtest.sql ${table hr.regions nobind}$; REGION_NAME --------- ---------------------- 5 Australia 6 South America 1 Europe 2 Americas 3 Asia 4 Middle East and Africa 15:01:23 SUCCESS [SELECT - 6 rows, 0.001 secs] Result set fetched select * from hr.regions; 15:01:23 SUCCESS [@run...egions nobind}$ - 0.001 secs] Script processed @run cmdtest.sql ${table hr.regions nobind}$; 15:01:23 END Execution 1 statement(s) executed, 6 row(s) affected, exec /fetch time: 0.001/0.000 secs [1 successful, 0 errors] The command line interface is called with the -sql option, specifying the client-side command @run. A DbVisualizer variable is passed to the @r un command with the value taken from the shell variable. This DbVisualizer variable value is then available to the script executed by the @run command. Note that you may need to escape certain characters that the shell would otherwise interpret, like the dollar signs that are part of the DbVisualizer variable delimiters. Setting up the connection properties on the command line As an alternative to using a connection already set-up through GUI tool you may use the -url parameter. In combination with the parameters - drivername, -driverclass and -driverpath this parameter enables you to get connected without prior specification using the GUI. Following are some examples. Executing SQL towards a MYSQL instance running on localhost port 3306. The parameter "-drivername MYSQL" specifies that we are using a drive specified in the GUI named MYSQL. For listing of the existing drivers use the GUI Driver Manager. See Installing a JDBC Driver.

Using -url and -drivername parameters./dbviscmd.sh -url jdbc:mysql://localhost:3306/ -drivername MYSQL -sql "select * from sakila.actor" -userid root An alternative to use the -drivername you may use the parameters -driverclass and -driverpath to specify the JDBC driver. Using -driverclass and -driverpath parameters./dbviscmd.sh -url jdbc:oracle:thin:@localhost:1521/orcl -driverclass oracle.jdbc.oracledriver -driverpath "/tmp/my_oracle_driver/ojdbc6.jar:/tmp /my_oracle_driver/orai18n.jar:/tmp/my_oracle_driver/xdb.jar:/tmp /my_oracle_driver/xmlparserv2.jar" -sql "select * from HR.COUNTRIES" - userid system -password oracle The above example connects to an ORACLE instance on localhost and port 1521. Note that the separator character ':' between the different jar files is platform dependant. On Windows-based desktop platforms, the value of this field is the semicolon (;).