This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / man / sqlsharp.1
1 .TH sqlsharp 1 "10 December 2002"
2 .SH NAME 
3 sqlsharp \- Mono SQL# command-line SQL Query tool
4 .SH SYNOPSIS
5 .B sqlsharp 
6 [\-f filename] [\-o filename] [\-s]
7 .SH DESCRIPTION
8 sqlsharp is the Mono SQL# tool used for entering SQL queries
9 to a database using Mono ADO.NET providers.
10 .PP
11 .SH OPTIONS
12 The following options are supported:
13 .TP
14 .I "-f filename"
15 Output file to load SQL# commands from.
16 .TP
17 .I "-o filename"
18 Output file to send results.
19 .TP
20 .I "-s"
21 Silent mode.
22 .PP
23 .SH HOW TO USE
24 The SQL# tool accepts commands via its command line interface.  Commands
25 begin with a backslash followed by the command name.
26 .PP
27 Example:
28 .nf
29         \\open
30
31 .fi
32 .PP
33 Basically, there are five commands a user should know:
34         \\provider, \\connectionstring, \\open, \\quit, and \\help
35 .PP     
36 To connect to a database, you need to do the following:
37 .PP
38 1. set your data provider via \\provider
39 .PP
40 .nf
41         Example:
42                 SQL# \\provider mysql
43                 
44 .fi
45 .PP
46 2. set your connection string via \\connectionstring
47 .PP
48 .nf
49         Example:
50                 SQL# \\connectionstring Database=test
51                 
52 .fi
53 .PP             
54 3. open a connection to the database via \\open
55 .PP
56 .nf
57         Example:
58                 SQL# \\open
59                 
60 .fi
61 .PP
62 .SH CONNECTION AND PROVIDER COMMANDS
63 These commands are used to setup the provider, 
64 connection string, and open/close the database connnection
65 .TP
66 .I "ConnectionString"
67 Sets the Connection String
68 .nf
69
70 Example:
71         SQL# \\ConnectionString Database=testdb
72
73 For more examples, see section CONNECTION STRING EXAMPLES.
74
75 .fi
76 .TP
77 .I "Provider"
78 Sets the Provider of the Data Source.  For list of Providers, see section PROVIDERS.
79 .nf
80         
81 Example: to set the provider for MySQL:
82         SQL# \\provider mysql
83                 
84 Note: if you need to load an external provider in SQL#, 
85       see the SQL# command \\loadextprovider 
86       
87 .fi
88 .TP
89 .I "LoadExtProvider"
90 ASSEMBLY CLASS to load an external provider.  Use the complete name 
91 of its assembly and its Connection class.
92 .nf
93
94 Example: to load the MySQL provider Mono.Data.MySql
95         SQL# \\loadextprovider Mono.Data.MySql Mono.Data.MySql.MySqlConnection
96
97 .fi
98 .TP
99 .I "Open"
100 Opens a connection to the database
101 .nf
102
103 Example:
104         SQL# \\open
105
106 .fi
107 .TP
108 .I "Close"
109 Closes the connection to the database
110 .nf
111
112 Example:
113         SQL# \\close
114
115 .fi
116 .TP
117 .I "Default"
118 show default variables, such as, Provider and ConnectionString.
119 .nf
120
121 Example:
122         SQL# \\defaults
123
124 .fi
125 .TP
126 .I "Q"
127 Quit
128 .nf
129
130 Example:
131         SQL# \\q
132
133 .fi
134 .SH SQL EXECUTION COMMANDS
135 Commands to execute SQL statements
136 .PP
137 .TR
138 .I "e"
139 execute SQL query (SELECT)
140 .nf
141
142 Example: to execute a query
143         
144         SQL# SELECT * FROM EMPLOYEE
145         SQL# \\e
146
147 Note: to get \\e to automatically work after entering a query, put a
148       semicolon ; at the end of the query.
149               
150 Example: to enter and exectue query at the same time
151
152         SQL# SELECT * FROM EMPLOYEE;
153
154 .fi
155 .TP
156 .I "exenonquery"
157 execute a SQL non query (not a SELECT)
158 .nf
159
160 Example: to insert a row into a table:
161         
162         SQL# INSERT INTO SOMETABLE (COL1, COL2) VALUES('ABC','DEF')
163         SQL# \\exenonquery
164                 
165 Note: this can be used for those providers that are new and do not have
166       the ability to execute queries yet.      
167
168 .fi
169 .TP
170 .I "exescalar" 
171 execute SQL to get a single row and single column.
172 .nf
173
174 Example: to execute a Maxium aggregate
175                 SQL# SELECT MAX(grade) FROM class
176                 SQL# \\exescalar        
177
178 .fi
179 .TP
180 .I "exexml"
181 FILENAME to execute SQL and save output to XML file
182 .nf
183
184 Example: 
185         SQL# SELECT fname, lname, hire_date FROM employee
186         SQL# \\exexml employee.xml
187                 
188 Note: this depends on DataAdapter, DataTable, and DataSet
189       to be working properly
190
191 .fi
192 .TP
193 .SH FILE COMMANDS
194 Commands for importing commands from file to SQL# and vice versa
195 .TP
196 .I "f"
197 FILENAME to read a batch of SQL# commands from file
198 .nf
199
200 Example:
201         SQL# \\f batch.sql#
202                 
203 Note: the SQL# commands are interpreted as they are read.  If there is
204       any SQL statements, the are executed.
205
206 .fi
207 .TP
208 .I "o"
209 FILENAME to write result of commands executed to file.
210 .nf
211
212 Example:
213         SQL# \\o result.txt
214
215 .fi
216 .TP
217 .I "load"
218 FILENAME to load from file SQL commands into SQL buffer.
219 .nf
220
221 Example:
222         SQL# \\load commands.sql
223
224 .fi
225 .TP
226 .I "save"
227 FILENAME to save SQL commands from SQL buffer to file.
228
229 .nf
230 Example:
231         SQL# \\save commands.sql
232
233 .fi
234 .SH GENERAL PURPOSE COMMANDS
235 General commands to use.
236 .TP
237 .I "h"
238 show help (all commands).
239 .nf
240
241 Example:
242         SQL# \\h
243
244 .fi
245 .TP
246 .I "s"
247 TRUE, FALSE to silent messages.
248 .nf
249
250 Example 1:
251         SQL# \\s true
252                 
253 Example 2:
254         SQL# \\s false
255
256 .fi
257 .TP
258 .I "r"
259 reset or clear the query buffer.
260 .nf
261
262 Example:
263         SQL# \\r
264
265 .fi
266 .TP
267 .I "print"
268 show what's in the SQL buffer now.
269 .nf
270
271 Example:
272         SQL# \\print
273
274 .fi
275 SH VARIABLES WHICH CAN BE USED AS PARAMETERS
276 Commands to set variables which can be used as Parameters in an SQL statement.  If the
277 SQL contains any parameters, the parameter does not have a variable set, the 
278 user will be prompted for the value for each missing parameter.
279 .TP
280 .I "set"
281 NAME VALUE to set an internal variable.
282 .nf
283
284 Example:
285         SQL# \\set sFirstName John
286
287 .fi
288 .TP
289 .I "unset"
290 NAME to remove an internal variable.
291 .nf
292
293 Example:
294         SQL# \\unset sFirstName
295
296 .fi
297 .TP
298 .I "variable"
299 NAME to display the value of an internal variable.
300 .nf
301
302 Example:
303         SQL# \\variable sFirstName
304
305 .fi
306 .SH PROVIDER SUPPORT OPTIONS
307 Enable or Disble support for a particular provider option
308 .TP
309 .I "UseParameters"
310 TRUE,FALSE to use parameters when executing SQL which
311 use the variables that were set.
312 .PP                 
313 If this option is true, the SQL
314 contains parameters, and for each parameter
315 which does not have a SQL# variable set, the
316 user will be prompted to enter the value
317 For that parameter.
318 .nf
319
320 Example:
321         SQL# \\useparameter true
322
323 .fi
324 .PP             
325 Default: false
326 .TP
327 .I "UseSimpleReader"
328 TRUE,FALSE to use simple reader when displaying results.
329 .nf
330
331 Example:
332         SQL# \\usesimplereader true
333
334 .fi
335 .PP             
336 Default: false.  Mostly, this is dependent on the provider.  If the provider
337 does not have enough of IDataReader implemented to have
338 the normal reader working, then the simple reader can be used.
339 Providers like SqlClient, MySQL, and PostgreSQL have this
340 ption defaulting to true.
341 .PP
342 .SH PROVIDERS
343 .nf
344
345 PROVIDER   NAME          NAMESPACE                  ASSEMBLY
346
347 Internal
348 --------
349
350 OleDb      OLE DB        System.Data.OleDb          System.Data 
351 SqlClient  MS SQL 7/2000 System.Data.SqlClient      System.Data
352 Odbc       ODBC          System.Data.Odbc           System.Data
353
354 External to System.Data
355 -----------------------
356 MySql      MySQL         Mono.Data.MySql            Mono.Data.MySql
357 Sqlite     SQL Lite      Mono.Data.SqliteClient     Mono.Data.SqliteClient
358 Sybase     Sybase        Mono.Data.SybaseClient     Mono.Data.SybaseClient
359 Tds        TDS Generic   Mono.Data.TdsClient        Mono.Data.TdsClient
360 PostgreSql M PostgreSQL  Mono.Data.PostgreSqlClient Mono.Data.PostgreSqlClient
361 DB2        IBM DB2       Mono.Data.DB2Client        Mono.Data.DB2Client
362 Oracle     Oracle 8i     System.Data.OracleClient   System.Data.OracleClient
363
364 External to Mono
365 ----------------
366
367 Npgsql     NetPostgreSQL Npgsql                     Npgsql
368 MySQLNet   ByteFX MySQL  ByteFX.Data.MySQL          ByteFX.Data
369
370 .fi
371 .SH CONNECTION STRING SAMPLES
372 Example connection strings for various providers to be used via the
373 command \\ConnectionString
374 .nf
375
376 Example of usage:
377         \\connectionstring Database=testdb
378
379
380 Connection String examples:
381
382
383 Microsoft SQL Server via System.Data.SqlClient 
384 or Mono.Data.TdsClient provider:
385
386         Server=DANPC;Database=pubs;User ID=saPassword=
387
388                 
389 PostgreSQL via Mono.Data.PostgreSqlClient provider:
390
391         host=localhost;dbname=test;user=postgres;password=fun2db
392
393                           or
394
395         Server=localhost;Database=test;User ID=postgres;Password=fun2db
396
397                 
398 MySQL via Mono.Data.MySql provider:
399
400         Server=localhost;Database=test;User ID=mysql;Password=
401
402         
403 ODBC via System.Data.Odbc provider using 
404 a DSN named "MSSQLDSN"  I set up 
405 in the Windows control panel's ODBC Data Sources 
406 which connects to Microsoft SQL Server 2000:
407
408         DSN=MSSQLDSN;UID=danmorg;PWD=freetds
409
410
411 SQL Lite via Mono.Data.SqliteClient 
412 provider which connects to the
413 database file SqliteTest.db; if not found, 
414 the file is created:
415
416         URI=file:SqliteTest.db
417
418
419 OLE DB via System.Data.OleDb provider 
420 which connects to a PostgreSQL database:
421
422         Provider=PostgreSQL;Addr=127.0.0.1;Database=rodrigo
423
424                 
425 Oracle via System.Data.OracleClient
426
427         Data Source=testdb;User ID=scott;Password=tiger
428
429                 
430 IBM DB2 Universal Database via Mono.Data.DB2Client
431
432         DSN=sample;User ID=db2admin;Password=mysecret   
433
434                 
435 Npgsql (.NET PostgreSQL) from 
436 http://gborg.postgresql.org/project/npgsql/projdisplay.php
437
438         Server=localhost;Database=test;User ID=postgres;Password=fun2db
439
440                 
441 MySQLNet (ByteFX MySQL) from 
442 http://sourceforge.net/projects/mysqlnet/
443
444         Server=localhost;Database=test;User ID=mysql;Password=
445
446
447 .fi
448 .SH TRACING SUPPORT
449 No support for tracing right now.
450 .SH AUTHORS
451 The Mono SQL# Tool was written 
452 .nf
453 by Daniel Morgan <danmorg@sc.rr.com>
454 .fi
455 .PP
456 .SH LICENSE
457 The Mono SQL# Tool is released under the terms of the GNU GPL.
458 Please read the accompanying `COPYING' file for details.  Alternative
459 licenses are available from Ximian or Daniel Morgan.
460 .SH BUGS
461 To report bugs in the compiler, you can use `bug-buddy', or you can
462 file bug reports in our bug tracking system:
463 .nf
464 http://bugzilla.ximian.com.
465 .fi
466 .PP
467 .SH MAILING LISTS
468 For details, visit:
469 .nf
470 http://mail.ximian.com/mailman/mono-list 
471 .fi
472 .SH WEB SITE
473 For details, visit: 
474 .nf
475 http://www.go-mono.com 
476 .fi
477 .PP
478 .SH SEE ALSO
479 mono(1), mint(1)
480