Example:
\open
Basically, there are five commands a user should know: \provider, \connectionstring, \open, \quit, and \help
To connect to a database, you need to do the following:
1. set your data provider via \provider
Example:
SQL# \provider mysql
2. set your connection string via \connectionstring
Example:
SQL# \connectionstring Database=test
3. open a connection to the database via \open
Example:
SQL# \open
Example:
SQL# \ConnectionString Database=testdb
For more examples, see section CONNECTION STRING EXAMPLES.
Example: to set the provider for MySQL:
SQL# \provider mysql
Note: if you need to load an external provider in SQL#,
see the SQL# command \loadextprovider
Example: to load the MySQL provider Mono.Data.MySql
SQL# \loadextprovider Mono.Data.MySql Mono.Data.MySql.MySqlConnection
Example:
SQL# \open
Example:
SQL# \close
Example:
SQL# \defaults
Example:
SQL# \qe execute SQL query (SELECT)
Example: to execute a query
SQL# SELECT * FROM EMPLOYEE
SQL# \e
Note: to get \e to automatically work after entering a query, put a
semicolon ; at the end of the query.
Example: to enter and exectue query at the same time
SQL# SELECT * FROM EMPLOYEE;
Example: to insert a row into a table:
SQL# INSERT INTO SOMETABLE (COL1, COL2) VALUES('ABC','DEF')
SQL# \exenonquery
Note: this can be used for those providers that are new and do not have
the ability to execute queries yet.
Example: to execute a Maxium aggregate
SQL# SELECT MAX(grade) FROM class
SQL# \exescalar
Example:
SQL# SELECT fname, lname, hire_date FROM employee
SQL# \exexml employee.xml
Note: this depends on DataAdapter, DataTable, and DataSet
to be working properlyExample:
SQL# \f batch.sql#
Note: the SQL# commands are interpreted as they are read. If there is
any SQL statements, the are executed.
Example:
SQL# \o result.txt
Example:
SQL# \load commands.sql
Example:
SQL# \save commands.sqlExample:
SQL# \h
Example 1:
SQL# \s true
Example 2:
SQL# \s false
Example:
SQL# \r
Example:
SQL# \print
SH VARIABLES WHICH CAN BE USED AS PARAMETERS Commands to set
variables which can be used as Parameters in an SQL statement. If
the SQL contains any parameters, the parameter does not have a
variable set, the user will be prompted for the value for each
missing parameter.
Example:
SQL# \set sFirstName John
Example:
SQL# \unset sFirstName
Example:
SQL# \variable sFirstNameIf this option is true, the SQL contains parameters, and for each parameter which does not have a SQL# variable set, the user will be prompted to enter the value For that parameter.
Example:
SQL# \useparameter true
Default: false
Example:
SQL# \usesimplereader trueDefault: false. Mostly, this is dependent on the provider. If the provider does not have enough of IDataReader implemented to have the normal reader working, then the simple reader can be used. Providers like SqlClient, MySQL, and PostgreSQL have this ption defaulting to true.
PROVIDER NAME NAMESPACE ASSEMBLY Internal -------- OleDb OLE DB System.Data.OleDb System.Data SqlClient MS SQL 7/2000 System.Data.SqlClient System.Data Odbc ODBC System.Data.Odbc System.Data External to System.Data ----------------------- MySql MySQL Mono.Data.MySql Mono.Data.MySql Sqlite SQL Lite Mono.Data.SqliteClient Mono.Data.SqliteClient Sybase Sybase Mono.Data.SybaseClient Mono.Data.SybaseClient Tds TDS Generic Mono.Data.TdsClient Mono.Data.TdsClient PostgreSql M PostgreSQL Mono.Data.PostgreSqlClient Mono.Data.PostgreSqlClient DB2 IBM DB2 Mono.Data.DB2Client Mono.Data.DB2Client Oracle Oracle 8i System.Data.OracleClient System.Data.OracleClient External to Mono ---------------- Npgsql NetPostgreSQL Npgsql Npgsql MySQLNet ByteFX MySQL ByteFX.Data.MySQL ByteFX.Data
Example of usage:
\connectionstring Database=testdb
Connection String examples:
Microsoft SQL Server via System.Data.SqlClient
or Mono.Data.TdsClient provider:
Server=DANPC;Database=pubs;User ID=saPassword=
PostgreSQL via Mono.Data.PostgreSqlClient provider:
host=localhost;dbname=test;user=postgres;password=fun2db
or
Server=localhost;Database=test;User ID=postgres;Password=fun2db
MySQL via Mono.Data.MySql provider:
Server=localhost;Database=test;User ID=mysql;Password=
ODBC via System.Data.Odbc provider using
a DSN named "MSSQLDSN" I set up
in the Windows control panel's ODBC Data Sources
which connects to Microsoft SQL Server 2000:
DSN=MSSQLDSN;UID=danmorg;PWD=freetds
SQL Lite via Mono.Data.SqliteClient
provider which connects to the
database file SqliteTest.db; if not found,
the file is created:
URI=file:SqliteTest.db
OLE DB via System.Data.OleDb provider
which connects to a PostgreSQL database:
Provider=PostgreSQL;Addr=127.0.0.1;Database=rodrigo
Oracle via System.Data.OracleClient
Data Source=testdb;User ID=scott;Password=tiger
IBM DB2 Universal Database via Mono.Data.DB2Client
DSN=sample;User ID=db2admin;Password=mysecret
Npgsql (.NET PostgreSQL) from
http://gborg.postgresql.org/project/npgsql/projdisplay.php
Server=localhost;Database=test;User ID=postgres;Password=fun2db
MySQLNet (ByteFX MySQL) from
http://sourceforge.net/projects/mysqlnet/
Server=localhost;Database=test;User ID=mysql;Password=
by Daniel Morgan <
LICENSE
The Mono SQL# Tool is released under the terms of the GNU GPL. Please read the accompanying `COPYING' file for details. Alternative licenses are available from Ximian or Daniel Morgan.BUGS
To report bugs in the compiler, you can use `bug-buddy', or you can file bug reports in our bug tracking system:
MAILING LISTS
For details, visit:WEB SITE
For details, visit:
SEE ALSO
mono(1), mint(1)