REQUEST COMPLIMENTARY SQLS*PLUS LICENCE
SQLShell: SQL tool for multiple databases with NoSQL potential
Preamble
SQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.
Why use it?
If you already only use one command-line tool such as psql for PostgreSQL or the MySQL command-line tool for MySQL and you don’t need it. If you find yourself jumping between several of these tools and want to use common functionality, or you’re a fan of many NoSQL technologies, it’s worth watching for.
JDBC Driver Support
SQLShell is built into Scala. Scala is a scalable programming language that compiles into Java byte code, can run on JVM, and can be used together with Java code. SQLShell can therefore interface with any database that has a JDBC (Java Database Connectivity), driver. Encase you do not know, there are many of them.
JDBC drivers are available
- DBMS Databases
- oracle
- MySQL
- PostgreSQL
- SQLite
There are several JDBC drivers for many NoSQL technologies, but none of them yet implements JDBC fully enough for SQLShell . - HBase
- MongoDB
- beehive
- CouchDB
- Redis
What should be noted in the recent release of Google BigQuery (part of Google Storage) is that, although they do not have a JDBC driver, they still use sqlcmd with BigQuery internally. Sqlcmd is also created by Brian M. Clapper on Clapper.org but he stopped development in favor of the new SQLShell.
However, Google likes Python and sqlcmd is written in Python.
SQLShell Installation
You can either download the pre-compiled JAR installation file for SQLShell or compile the binary yourself. It is recommended to download the JAR and I downloaded version 0.7.1.
curl -O http://cloud.github.com/downloads/bmc/sqlshell/sqlshell-0.7.1-install.jar
This installer can be started with the java command that launches the graphical installer. The graphical installer uses IzPack, which is a cross-platform installation environment. Therefore, although I am using Mac OS X, you should not have any problems installing it on Windows or Linux.
java -jar sqlshell-0.7.1-install.jar
The first thing you see if everything goes well is a tip from the language. After that you will see the welcome screen, then the entry and information page, and then the license page. Be sure to read the license carefully, especially the part about “you are firstborn”.
This is what you will see on the screen saver.
Initial SQLShell installer screen
When you reach the end, you will see the following message …
You have successfully installed SQLShell. For your convenience in
The “bin” directory in the “/Applications/clapper.org/sqlshell” directory has a shell script.
This tells you where sqlshell is installed. Under this directory is the bin directory which contains sqlshell . This is a command-line tool and since we will use it a lot I will add the path to this bin directory in my PATH.
echo 'export PATH=$PATH:/Applications/clapper.org/sqlshell/bin' >> ~/.profile
source ~/.profile
which sqlshell || echo "Not found in path" # This tests that it's found in your PATH
We can see what parameters he expects by running sqlshell with the -help argument.
sqlshell --help
SQLShell, version 0.7.1 (2010/11/10 17:27:55)
Usage: sqlshell [OPTIONS] db [@file]
OPTIONS
-?
-h
--help Show this usage message.
-V
--version Show version and exit.
-c config_file
--config config_file Specify configuration file. Defaults to:
/Users/phil/.sqlshell/config
-n
--no-ansi
--noansi Disable the use of ANSI terminal sequences. This option
just sets the initial value for this setting. The value
can be changed later from within SQLShell itself.
-r lib_name
--readline lib_name Specify readline libraries to use. Legal values:
editline, getline, gnu, jline, simple. (May be specified
multiple times.)
-s
-stack Show all exception stack traces.
-v
--verbose Enable various verbose messages. This option just sets
the initial verbosity value. The value can be changed
later from within SQLShell itself.
PARAMETERS
db Name of database to which to connect, or an on-the-fly database
The form:
driver,url,[user[,password]].
If the name of a database is specified, SQLShellwill look in the
configuration file for the corresponding connection. If a
database specification is used, the specification must be one argument. The
the driver can be a full driver class name, or a driver alias from the
configuration file. The user and password are optional, since some
databases (like SQLite) don't require them at all.
@file Path of file of commands to run
SQLShell with MySQL
Install the JDBC MySQL driver
Download the driver from MySQL
curl -O <a href="http://www.mysql.com/downloads/connector/j/">http://mysql.mirror.iweb.ca/Downloads/Connector-J/mysql-connector-java-5.1.14.tar.gz</a>.
tar xvzf mysql-connector-java-5.1.14.tar.gz
cd mysql-connector-java-5.1.14
cp mysql-connector-java-5.1.14-bin.jar /Applications/clapper.org/sqlshell/lib/
Above we copied MySQL connector-Java-5.1.14-bin.jar file SQLShell to Lib. SQLShell will download all JAR files found in this directory at startup and then reference them by package name and class. We will use the MySQL driver class name to configure the alias “mysql” in SQLShell configuration.
To configure the alias “mysql” we will edit the default configuration file ~ / .sqlshell / config which does not exist at the moment.
mkdir ~/.sqlshell
vim ~/.sqlshell/config # I use vim to edit files
Add the following configuration…
[drivers]
mysql = com.mysql.jdbc.Driver
Connect to MySQL with SQLShell
The format of the connection string for the MySQL JDBC driver should be
jdbc:mysql://[host][,failoverhost...][:port]/[database][?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
I’m just going to connect to a local mysql database and look at a pre-installed MySQL database called “test”. You should have the same database if you haven’t deleted it.
sqlshell mysql,jdbc:mysql://localhost/test?user=root
SQLShell, version 0.7.1 (2010/11/10 17:27:55)
Copyright (c) 2009-2010 Brian M. Clapper
Using JLine
Type "help" for help. Type ".about" for more information.
sqlshell>
Okay, we are connected to MySQL and can run multiple queries.
We can see the commands that we can run using help.
sqlshell> help
Help is for the following commands:
-------------------------------------------------------------------------------
.about .capture .desc .echo .run .set .show
alter begin commit create delete drop exit
help history insert r rollback select update
Let’s take a look at what databases we have …
sqlshell> show databases;
Execution time: 0.26 seconds
Retrieval time: 0.21 seconds
2 rows returned.
SCHEMA_NAME
------------------
information_schema
test
sqlshell>
We can create a new database.
sqlshell> create database sqlshell_test;
1 row affected.
Execution time: 0.5 seconds
SQLShell completely transfers SQL statements to the database, so you can use any commands that your database understands.
SQL vs NoSQL or MySQL vs MongoDB
Enteros
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of RDBMS, NoSQL, and machine learning database platforms.
MORE NEWS
PreambleNoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...
PreambleMongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...
5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...
The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...
PreambleMS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...
First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...
PreambleAtom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...
PreambleMongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...
FlexibilityOne of the most advertised features of MongoDB is its flexibility. Flexibility, however, is a double-edged sword. More flexibility means more...
PreambleWriting an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert...
PreambleOracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...
PreambleIBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...
What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....
PreambleIf you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...
PreambleStarting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...
PreambleWhen administering PostgreSQL database servers, one of the most common tasks you will probably perform is enumerating databases and their tables....