flush
[mcs.git] / tools / sqlsharp / README
blob7aa5352a1ca60603ad861b71e8574f61e92e4fc2
1 Mono SQL Query - Command Line Interface
2 =======================================
4 Running SQL Query on Mono:
5         mono sqlsharp.exe
7 Use this tool to test connection strings and enter SQL queries 
8 to different ADO.NET providers in Mono.
10 Basically, there are five commands a user should know:
11         \provider, \connectionstring, \open, \quit, and \help
12         
13 To connect to a database, you need to do the following:
14 1. set your data provider via \provider
15         Example:
16                 SQL# \provider mysql
18 2. set your connection string via \connectionstring
19         Example:
20                 SQL# \connectionstring Server=localhost;Database=test;User ID=someuser;Password=somepass
21                 
22 3. open a connection to the database via \open
23         Example:
24                 SQL# \open
26 Here are the SQL# Commands taken from the help command: \h
27 SQL# Commands are case insensitive, so \Q and \q work the same.
29 CONNECTION AND PROVIDER COMMANDS
30 ================================
32 \ConnectionString to set the ConnectionString
33         
34         Example connection strings for various providers:
35         
36         Microsoft SQL Server via System.Data.SqlClient or Mono.Data.TdsClient provider:
37                 SQL# \ConnectionString Server=DANPC;Database=pubs;User ID=danmorg;Password=freetds
38                 
39         PostgreSQL via Npgsql provider:
40                 SQL# \ConnectionString Server=localhost;Database=test;User ID=postgres;Password=fun2db
41                 
42         MySQL via ByteFX.Data.MySqlClient provider:
43                 SQL# \ConnectionString Server=localhost;Database=test;User ID=mysql;Password=
45         MySQL via MySql.Data provider:
46                 SQL# \ConnectionString Server=localhost;Database=test;User ID=mysql;Password=mypass;Pooling=false
47                 
48         ODBC via System.Data.Odbc provider using a DSN named "MSSQLDSN" I set up 
49         in the Windows control panel's ODBC Data Sources which connects 
50         to Microsoft SQL Server 2000:
51                 SQL# \ConnectionString DSN=MSSQLDSN;UID=danmorg;PWD=freetds
53         SQL Lite via Mono.Data.SqliteClient provider which connects to the
54         database file SqliteTest.db; if not found, the file is created:
55                 SQL# \ConnectionString URI=file:SqliteTest.db
56                 
57         OLE DB via System.Data.OleDb provider which connects to a PostgreSQL database:
58                 SQL# \ConnectionString Provider=PostgreSQL;Addr=127.0.0.1;Database=rodrigo
59                 
60         Oracle via System.Data.OracleClient
61                 SQL# \ConnectionString Data Source=testdb;User ID=scott;Password=tiger
63     FirebirdSql via FirebirdSql.Data.Firebird (not included with Mono)
64                 SQL# \ConnectionString Database=C:\FIREBIRD\EXAMPLES\EMPLOYEE.FDB;User=SYSDBA;Password=masterkey;Dialect=3;Server=localhost
65         
67 \Provider to set the Provider:
69     Provider    Name          Namespace                  Assembly
70     =========== ============= ========================== ==========================
71         OleDb       OLE DB        System.Data.OleDb          System.Data  
72         SqlClient   MS SQL 7/2000 System.Data.SqlClient      System.Data
73         Odbc        ODBC          System.Data.Odbc           System.Data
74         Sqlite      SQL Lite      Mono.Data.SqliteClient     Mono.Data.SqliteClient
75         Sybase      Sybase        Mono.Data.SybaseClient     Mono.Data.SybaseClient
76         Tds         TDS Generic   Mono.Data.TdsClient        Mono.Data.TdsClient
77         Oracle      Oracle 8i     System.Data.OracleClient   System.Data.OracleClient
78         PostgreSql  NET Postgres  Npgsql                     Npgsql
79         ByteFX      ByteFX MySQL  ByteFX.Data.MySqlClient    ByteFX.Data
80         Firebird    Firebird      FirebirdSql.Data.Firebird  FirebirdSql.Data.Firebird
81         MySql       MySQL AB      MySql.Data.MySqlClient     MySql.Data
82         
83         Example: to set the provider for MySQL:
84                 SQL# \provider mysql
85                 
86         Note: if you need to load an external provider in SQL#, 
87               see the SQL# command \loadextprovider 
89 \loadextprovider ASSEMBLY CLASS to load an external provider
90                                 use the complete name of its assembly and
91                                 its Connection class.  No spaces in the assembly name.
93         Example: to load the MySQL provider MySql.Data.dll from the GAC:
94                 SQL# \loadextprovider MySql.Data,Version=1.0.7.30073,Culture=neutral,PublicKeyToken=8e323390df8d9ed4 MySql.Data.MySqlCliet.MySqlConnection
95         
96 \Open to open the connection
98         Example:
99                 SQL# \open
101 \Close to close the connection
103         Example:
104                 SQL# \close
106 \defaults to show default variables, such as, Provider and ConnectionString.
108         Example:
109                 SQL# \defaults
111 \Q to quit
112         Example:
113                 SQL# \q
115 SQL EXECUTION COMMANDS
116 ======================
117                 
118 \e to execute SQL query (SELECT)
120         Example: to execute a query
121         
122                 SQL# SELECT * FROM EMPLOYEE
123                 SQL# \e
124                 
125         Note: to get \e to automatically work after entering a query, put a
126               semicolon ; at the end of the query.
127               
128         Example: to enter and exectue query at the same time
129         
130                 SQL# SELECT * FROM EMPLOYEE;
131                 
132 \exenonquery to execute an SQL non query (not a SELECT)
134         Example: to insert a row into a table:
135         
136                 SQL# INSERT INTO SOMETABLE (COL1, COL2) VALUES('ABC','DEF')
137                 SQL# \exenonquery
138                 
139         Note: this can be used for those providers that are new and do not have
140               the ability to execute queries yet.      
142 \exescalar to execute SQL to get a single row and single column.
144         Example: to execute a Maxium aggregate
145                 SQL# SELECT MAX(grade) FROM class
146                 SQL# \exescalar 
148 \exexml FILENAME to execute SQL and save output to XML file
150         Example: 
151                 SQL# SELECT fname, lname, hire_date FROM employee
152                 SQL# \exexml employee.xml
153                 
154         Note: this depends on DataAdapter, DataTable, and DataSet
155               to be working properly
156               
157 FILE COMMANDS
158 =============              
159               
160 \f FILENAME to read a batch of SQL# commands from file
162         Example:
163                 SQL# \f batch.sql#
164                 
165         Note: the SQL# commands are interpreted as they are read.  If there is
166               any SQL statements, they are executed.
168 \o FILENAME to write result of commands executed to file.
170         Example:
171                 SQL# \o result.txt
173 \load FILENAME to load from file SQL commands into SQL buffer.
175         Example:
176                 SQL# \load commands.sql
178 \save FILENAME to save SQL commands from SQL buffer to file.
180         Example:
181                 SQL# \save commands.sql
183 GENERAL PURPOSE COMMANDS
184 ========================
186 \h to show help (all commands).
188         Example:
189                 SQL# \h
191 \s {TRUE, FALSE} to silent messages.
193         Example 1:
194                 SQL# \s true
195                 
196         Example 2:
197                 SQL# \s false
198         
199 \r to reset or clear the query buffer.
201         Example:
202                 SQL# \r
204 \print - show what's in the SQL buffer now.
206         Example:
207                 SQL# \print
209 VARIABLES WHICH CAN BE USED AS PARAMETERS
210 =========================================
212 \set NAME VALUE to set an internal variable.
214         Example:
215                 SQL# \set sFirstName John
217 \unset NAME to remove an internal variable.
219         Example:
220                 SQL# \unset sFirstName
222 \variable NAME to display the value of an internal variable.
224         Example:
225                 SQL# \variable sFirstName
227 PROVIDER SUPPORT OPTIONS
228 ========================
230 \UseParameters (TRUE,FALSE) to use parameters when executing SQL which
231                             use the variables that were set.  
232                             
233                             If this option is true, the SQL
234                             contains parameters, and for each parameter
235                             which does not have a SQL# variable set, the
236                             user will be prompted to enter the value
237                             for that parameter.
239         Example:
240                 SQL# \useparameter true
241                 
242         Default: false
244 \UseSimpleReader (TRUE,FALSE) to use simple reader when displaying results.
246         Example:
247                 SQL# \usesimplereader true
248                 
249         Default: false.  Mostly, this is dependent on the provider.  If the provider
250                          does not have enough of IDataReader implemented to have
251                          the normal reader working, then the simple reader can be used.
252