Merge pull request #2675 from lambdageek/dev/monoerror-mono_string_intern
[mono.git] / mcs / tools / sqlsharp / README
1 Mono SQL Query - Command Line Interface
2 =======================================
3
4 Running SQL Query on Mono:
5         mono sqlsharp.exe
6
7 Use this tool to test connection strings and enter SQL queries 
8 to different ADO.NET providers in Mono.
9
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
17
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
25
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.
28
29 CONNECTION AND PROVIDER COMMANDS
30 ================================
31
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=
44
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
52
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
62
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         
66
67 \Provider to set the Provider:
68
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 
88
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.
92
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
97
98         Example:
99                 SQL# \open
100
101 \Close to close the connection
102
103         Example:
104                 SQL# \close
105
106 \defaults to show default variables, such as, Provider and ConnectionString.
107
108         Example:
109                 SQL# \defaults
110
111 \Q to quit
112         Example:
113                 SQL# \q
114
115 SQL EXECUTION COMMANDS
116 ======================
117                 
118 \e to execute SQL query (SELECT)
119
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)
133
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.      
141
142 \exescalar to execute SQL to get a single row and single column.
143
144         Example: to execute a Maxium aggregate
145                 SQL# SELECT MAX(grade) FROM class
146                 SQL# \exescalar 
147
148 \exexml FILENAME to execute SQL and save output to XML file
149
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
161
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.
167
168 \o FILENAME to write result of commands executed to file.
169
170         Example:
171                 SQL# \o result.txt
172
173 \load FILENAME to load from file SQL commands into SQL buffer.
174
175         Example:
176                 SQL# \load commands.sql
177
178 \save FILENAME to save SQL commands from SQL buffer to file.
179
180         Example:
181                 SQL# \save commands.sql
182
183 GENERAL PURPOSE COMMANDS
184 ========================
185
186 \h to show help (all commands).
187
188         Example:
189                 SQL# \h
190
191 \s {TRUE, FALSE} to silent messages.
192
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.
200
201         Example:
202                 SQL# \r
203
204 \print - show what's in the SQL buffer now.
205
206         Example:
207                 SQL# \print
208
209 VARIABLES WHICH CAN BE USED AS PARAMETERS
210 =========================================
211
212 \set NAME VALUE to set an internal variable.
213
214         Example:
215                 SQL# \set sFirstName John
216
217 \unset NAME to remove an internal variable.
218
219         Example:
220                 SQL# \unset sFirstName
221
222 \variable NAME to display the value of an internal variable.
223
224         Example:
225                 SQL# \variable sFirstName
226
227 PROVIDER SUPPORT OPTIONS
228 ========================
229
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.
238
239         Example:
240                 SQL# \useparameter true
241                 
242         Default: false
243
244 \UseSimpleReader (TRUE,FALSE) to use simple reader when displaying results.
245
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                          
253