Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / man / sqlsharp.1
1 .TH sqlsharp 1 "9 September 2008"
2 .SH NAME 
3 sqlsharp \- Mono SQL Query command-line tool
4 .SH SYNOPSIS
5 .B sqlsharp 
6 [\-f filename] [\-o filename] [\-s]
7 .SH DESCRIPTION
8 sqlsharp is a Mono SQL tool used for entering SQL queries
9 to a database using Mono data 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         or
73         SQL# \\cs Database=testdb
74
75 For more examples, see section CONNECTION STRING EXAMPLES.
76
77 .fi
78 .TP
79 .I "Provider"
80 Sets the Provider of the Data Source.  For list of Providers, see section PROVIDERS.
81 .nf
82         
83 Example: to set the provider for MySQL:
84         SQL# \\provider mysql
85            or
86         SQL# \\p mysql
87                 
88 Note: if you need to load an external provider in SQL#, 
89       see the SQL# command \\loadextprovider 
90       
91 .fi
92 .TP
93 .I "ListProviders"
94 List ADO.NET 2.0 Providers available
95 .nf
96
97 Example:
98         SQL# \\ListProviders 
99            or
100         SQL# \\listp
101
102 .fi
103 .TP
104 .I "BCS"
105 Prompts you for building each connection parameter and builds the connection string
106 and also allows you to enter a password wich does not echo.
107 .nf
108
109 Example:
110         SQL# \\bcs
111
112         ConnectionString Option: Data Source [] SQL# blazer
113
114         ConnectionString Option: Persist Security Info [False] SQL# 
115
116         ConnectionString Option: Integrated Security [False] SQL# 
117
118         ConnectionString Option: User ID [] SQL# scott
119
120         Password: *****
121
122         ConnectionString Option: Enlist [False] SQL# 
123
124         ConnectionString Option: Pooling [True] SQL# 
125
126         ConnectionString Option: Min Pool Size [0] SQL# 
127
128         ConnectionString Option: Max Pool Size [100] SQL# 
129
130         ConnectionString Option: Unicode [False] SQL# 
131
132         ConnectionString Option: Load Balance Timeout [0] SQL# 
133
134         ConnectionString Option: Omit Oracle Connection Name [False] SQL# 
135         ConnectionString is set.        
136
137 .fi
138 .TP
139 .I "LoadExtProvider"
140 ASSEMBLY CLASS to load an external provider.  Use the complete name 
141 of its assembly and its Connection class.
142 .nf
143
144 Example: to load the MySQL provider Mono.Data.MySql
145         SQL# \\loadextprovider Mono.Data.MySql Mono.Data.MySql.MySqlConnection
146
147 .fi
148 .TP
149 .I "Open"
150 Opens a connection to the database
151 .nf
152
153 Example:
154         SQL# \\open
155
156 .fi
157 .TP
158 .I "Close"
159 Closes the connection to the database
160 .nf
161
162 Example:
163         SQL# \\close
164
165 .fi
166 .TP
167 .I "Default"
168 show default variables, such as, Provider and ConnectionString.
169 .nf
170
171 Example:
172         SQL# \\defaults
173
174 .fi
175 .TP
176 .I "Q"
177 Quit
178 .nf
179
180 Example:
181         SQL# \\q
182
183 .fi
184 .SH SQL EXECUTION COMMANDS
185 Commands to execute SQL statements
186 .PP
187 .TR
188 .I "e"
189 execute SQL query (SELECT)
190 .nf
191
192 Example: to execute a query
193         
194         SQL# SELECT * FROM EMPLOYEE
195         SQL# \\e
196
197 Note: to get \\e to automatically work after entering a query, put a
198       semicolon ; at the end of the query.
199               
200 Example: to enter and exectue query at the same time
201
202         SQL# SELECT * FROM EMPLOYEE;
203
204 .fi
205 .TP
206 .I "exenonquery"
207 execute a SQL non query (not a SELECT)
208 .nf
209
210 Example: to insert a row into a table:
211         
212         SQL# INSERT INTO SOMETABLE (COL1, COL2) VALUES('ABC','DEF')
213         SQL# \\exenonquery
214                 
215 Note: this can be used for those providers that are new and do not have
216       the ability to execute queries yet.      
217
218 .fi
219 .TP
220 .I "exescalar" 
221 execute SQL to get a single row and single column.
222 .nf
223
224 Example: to execute a Maxium aggregate
225                 SQL# SELECT MAX(grade) FROM class
226                 SQL# \\exescalar        
227
228 .fi
229 .TP
230 .I "exexml"
231 FILENAME to execute SQL and save output to XML file
232 .nf
233
234 Example: 
235         SQL# SELECT fname, lname, hire_date FROM employee
236         SQL# \\exexml employee.xml
237                 
238 Note: this depends on DataAdapter, DataTable, and DataSet
239       to be working properly
240
241 .fi
242 .TP
243 .SH FILE COMMANDS
244 Commands for importing commands from file to SQL# and vice versa
245 .TP
246 .I "f"
247 FILENAME to read a batch of SQL# commands from file
248 .nf
249
250 Example:
251         SQL# \\f batch.sql#
252                 
253 Note: the SQL# commands are interpreted as they are read.  If there is
254       any SQL statements, the are executed.
255
256 .fi
257 .TP
258 .I "o"
259 FILENAME to write result of commands executed to file.
260 .nf
261
262 Example:
263         SQL# \\o result.txt
264
265 .fi
266 .TP
267 .I "load"
268 FILENAME to load from file SQL commands into SQL buffer.
269 .nf
270
271 Example:
272         SQL# \\load commands.sql
273
274 .fi
275 .TP
276 .I "save"
277 FILENAME to save SQL commands from SQL buffer to file.
278
279 .nf
280 Example:
281         SQL# \\save commands.sql
282
283 .fi
284 .SH GENERAL PURPOSE COMMANDS
285 General commands to use.
286 .TP
287 .I "h"
288 show help (all commands).
289 .nf
290
291 Example:
292         SQL# \\h
293
294 .fi
295 .TP
296 .I "s"
297 TRUE, FALSE to silent messages.
298 .nf
299
300 Example 1:
301         SQL# \\s true
302                 
303 Example 2:
304         SQL# \\s false
305
306 .fi
307 .TP
308 .I "r"
309 reset or clear the query buffer.
310 .nf
311
312 Example:
313         SQL# \\r
314
315 .fi
316 .TP
317 .I "print"
318 show what's in the SQL buffer now.
319 .nf
320
321 Example:
322         SQL# \\print
323
324 .fi
325 SH VARIABLES WHICH CAN BE USED AS PARAMETERS
326 Commands to set variables which can be used as Parameters in an SQL statement.  If the
327 SQL contains any parameters, the parameter does not have a variable set, the 
328 user will be prompted for the value for each missing parameter.
329 .TP
330 .I "set"
331 NAME VALUE to set an internal variable.
332 .nf
333
334 Example:
335         SQL# \\set sFirstName John
336
337 .fi
338 .TP
339 .I "unset"
340 NAME to remove an internal variable.
341 .nf
342
343 Example:
344         SQL# \\unset sFirstName
345
346 .fi
347 .TP
348 .I "variable"
349 NAME to display the value of an internal variable.
350 .nf
351
352 Example:
353         SQL# \\variable sFirstName
354
355 .fi
356 .SH PROVIDER SUPPORT OPTIONS
357 Enable or Disble support for a particular provider option
358 .TP
359 .I "UseParameters"
360 TRUE,FALSE to use parameters when executing SQL which
361 use the variables that were set.
362 .PP                 
363 If this option is true, the SQL
364 contains parameters, and for each parameter
365 which does not have a SQL# variable set, the
366 user will be prompted to enter the value
367 For that parameter.
368 .nf
369
370 Example:
371         SQL# \\useparameter true
372
373 .fi
374 .PP             
375 Default: false
376 .TP
377 .I "UseSimpleReader"
378 TRUE,FALSE to use simple reader when displaying results.
379 .nf
380
381 Example:
382         SQL# \\usesimplereader true
383
384 .fi
385 .PP             
386 Default: false.  Mostly, this is dependent on the provider.  If the provider
387 does not have enough of IDataReader implemented to have
388 the normal reader working, then the simple reader can be used.
389 Providers like SqlClient, MySQL, and PostgreSQL have this
390 ption defaulting to true.
391 .PP
392 .SH PROVIDERS
393 .nf
394
395 PROVIDER   NAME          NAMESPACE                  ASSEMBLY
396
397 oracle     Oracle 8i-11g System.Data.OracleClient   System.Data.OracleClient
398 postgresql NetPostgreSQL Npgsql                     Npgsql
399 bytefx     ByteFX MySQL  ByteFX.Data.MySqlClient    ByteFX.Data
400 sqlclient  MS SQL 7-2008 System.Data.SqlClient      System.Data
401 odbc       ODBC          System.Data.Odbc           System.Data
402 sqlite     SQL Lite      Mono.Data.SqliteClient     Mono.Data.SqliteClient
403 sybase     Sybase        Mono.Data.SybaseClient     Mono.Data.SybaseClient
404 firebird   Firebird SQL  FirebirdSql.Data.FirebirdSql FirebirdSql.Data.Firebird
405 mysql      MySQL AB      MySql.Data.MySqlClient     MySql.Data
406
407 NOTES:
408
409 Ngsql is the .Net Data Provider for PosgreSQL.  The
410 latest version can be downloaded from
411 http://npgsql.projects.postgresql.org/
412
413 MySql.Data is the MySQL Connector/Net for connecting to MySql databases.
414 For MySQL, it is strongly recommend to use MySql.Data instead of the old
415 ByteFX.Data provider.  Unfortunately, MySql.Data is not included with Mono.
416 You can download the latest MySQL Connector/Net from MySQL AB at
417 http://dev.mysql.com/downloads/
418
419 FirebirdSql.Data.Firebird can be downloaded from here:
420 http://www.firebirdsql.org/index.php?op=files&id=netprovider
421
422 .fi
423 .SH CONNECTION STRING SAMPLES
424 Example connection strings for various providers to be used via the
425 command \\ConnectionString
426 .nf
427
428 Example of usage:
429         \\connectionstring Database=testdb
430
431
432 Connection String examples:
433
434
435 Microsoft SQL Server via System.Data.SqlClient 
436
437         Server=DANPC;Database=pubs;User ID=saPassword=;
438
439         For Integrated Security, bear in mind that Mono is not
440         integrated with Windows, SQL Server client nor server, nor
441         Windows Server.  Therefore, you must provide the Windows Domain
442         name and domain user name and password for this user.
443
444         Server=DANPC;Database=pubs;User ID=DOMAIN\user;Password=pass;Integrated Security=SSPI
445
446         For a server locally, you can use localhost.
447         
448 ODBC via System.Data.Odbc provider using 
449 a DSN named "MSSQLDSN"  I set up 
450 in the Windows control panel's ODBC Data Sources 
451 which connects to Microsoft SQL Server 2000:
452
453         DSN=MSSQLDSN;UID=danmorg;PWD=freetds
454
455 To use ODBC ON Unix, consider unixODBC from http://www.unixodbc.org/
456 or use iODBC from http://www.iodbc.org/
457
458 SQL Lite via Mono.Data.SqliteClient 
459 provider which connects to the
460 database file SqliteTest.db; if not found, 
461 the file is created:
462
463         URI=file:SqliteTest.db
464
465 Oracle via System.Data.OracleClient
466
467         Data Source=testdb;User ID=scott;Password=tiger
468
469         If you prefer to not use a tnsnames.ora file, you can 
470         use a connection string which allows a
471         TNS network description that is parentheses delimited
472         like the following which has the host, port, and
473         service name.  For host, you can specify an IP address
474         instead of a hostname.
475
476 User ID=SCOTT;
477 Password=TIGER;
478 Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=TESTDB)))
479
480                 
481 Npgsql (.NET PostgreSQL) from 
482 http://gborg.postgresql.org/project/npgsql/projdisplay.php
483
484         Server=localhost;Database=test;User ID=postgres;Password=fun2db
485
486                 
487 ByteFX (ByteFX MySQL) from 
488
489         Please use MySql.Data instead.
490
491         Server=localhost;Database=test;User ID=mysql;Password=
492
493
494 FirebirdSql via FirebirdSql.Data.Firebird (download latest form FirebirdSql.org)
495
496         Database=C:\\FIREBIRD\\EXAMPLES\\EMPLOYEE.FDB;User=SYSDBA;Password=masterkey;Dialect=3;Server=localhost
497
498
499 MySQL via (MySql.Data) MySQL Connector/Net from http://www.mysql.com/
500
501         Server=localhost;Database=test;User ID=mysql;Password=mypass;Pooling=false
502
503
504 .fi
505 .SH TRACING SUPPORT
506 No support for tracing right now.
507 .SH AUTHORS
508 The Mono SQL Query Tool was written 
509 .nf
510 by Daniel Morgan <monodanmorg@yahoo.com>
511 .fi
512 .PP
513 .SH LICENSE
514 The Mono SQL Query Tool is released under the terms of the GNU GPL.
515 Please read the accompanying `COPYING' file for details.  Alternative
516 licenses are available from Novell or Daniel Morgan.
517 .SH BUGS
518 To report bugs in the compiler, you can use `bug-buddy', or you can
519 file bug reports in our bug tracking system:
520 .nf
521 http://bugzilla.xamarin.com.
522 .fi
523 .PP
524 .SH MAILING LISTS
525 For details, visit:
526 .nf
527 http://lists.ximian.com/mailman/listinfo/mono-devel-list
528 .fi
529 .SH WEB SITE
530 For details, visit: 
531 .nf
532 http://www.mono-project.com 
533 .fi
534 .PP
535 .SH SEE ALSO
536 mono(1)
537