1sqlsharp(1) General Commands Manual sqlsharp(1)
2
3
4
6 sqlsharp - Mono SQL Query command-line tool
7
9 sqlsharp [-f filename] [-o filename] [-s]
10
12 sqlsharp is a Mono SQL tool used for entering SQL queries to a database
13 using Mono data providers.
14
16 The following options are supported:
17
18 -f filename
19 Output file to load SQL commands from.
20
21 -o filename
22 Output file to send results.
23
24 -s Silent mode.
25
27 The SQL tool accepts commands via its command line interface. Commands
28 begin with a backslash followed by the command name.
29
30 Example:
31 \open
32
33
34 Basically, there are five commands a user should know: \provider,
35 \connectionstring, \open, \quit, and \help
36
37 To connect to a database, you need to do the following:
38
39 1. set your data provider via \provider
40
41 Example:
42 SQL# \provider mysql
43
44
45 2. set your connection string via \connectionstring
46
47 Example:
48 SQL# \connectionstring Database=test
49
50
51 3. open a connection to the database via \open
52
53 Example:
54 SQL# \open
55
56
58 These commands are used to setup the provider, connection string, and
59 open/close the database connnection
60
61 ConnectionString
62 Sets the Connection String
63
64 Example:
65 SQL# \ConnectionString Database=testdb
66
67 For more examples, see section CONNECTION STRING EXAMPLES.
68
69
70 Provider
71 Sets the Provider of the Data Source. For list of Providers,
72 see section PROVIDERS.
73
74 Example: to set the provider for MySQL:
75 SQL# \provider mysql
76
77 Note: if you need to load an external provider in SQL#,
78 see the SQL# command \loadextprovider
79
80
81 LoadExtProvider
82 ASSEMBLY CLASS to load an external provider. Use the complete
83 name of its assembly and its Connection class.
84
85 Example: to load the MySQL provider Mono.Data.MySql
86 SQL# \loadextprovider Mono.Data.MySql Mono.Data.MySql.MySqlConnection
87
88
89 Open Opens a connection to the database
90
91 Example:
92 SQL# \open
93
94
95 Close Closes the connection to the database
96
97 Example:
98 SQL# \close
99
100
101 Default
102 show default variables, such as, Provider and ConnectionString.
103
104 Example:
105 SQL# \defaults
106
107
108 Q Quit
109
110 Example:
111 SQL# \q
112
113
115 Commands to execute SQL statements
116
117 e execute SQL query (SELECT)
118
119 Example: to execute a query
120
121 SQL# SELECT * FROM EMPLOYEE
122 SQL# \e
123
124 Note: to get \e to automatically work after entering a query, put a
125 semicolon ; at the end of the query.
126
127 Example: to enter and exectue query at the same time
128
129 SQL# SELECT * FROM EMPLOYEE;
130
131
132 exenonquery
133 execute a SQL non query (not a SELECT)
134
135 Example: to insert a row into a table:
136
137 SQL# INSERT INTO SOMETABLE (COL1, COL2) VALUES('ABC','DEF')
138 SQL# \exenonquery
139
140 Note: this can be used for those providers that are new and do not have
141 the ability to execute queries yet.
142
143
144 exescalar
145 execute SQL to get a single row and single column.
146
147 Example: to execute a Maxium aggregate
148 SQL# SELECT MAX(grade) FROM class
149 SQL# \exescalar
150
151
152 exexml FILENAME to execute SQL and save output to XML file
153
154 Example:
155 SQL# SELECT fname, lname, hire_date FROM employee
156 SQL# \exexml employee.xml
157
158 Note: this depends on DataAdapter, DataTable, and DataSet
159 to be working properly
160
161
162
163 FILE COMMANDS
164 Commands for importing commands from file to SQL# and vice versa
165
166 f FILENAME to read a batch of SQL# commands from file
167
168 Example:
169 SQL# \f batch.sql#
170
171 Note: the SQL# commands are interpreted as they are read. If there is
172 any SQL statements, the are executed.
173
174
175 o FILENAME to write result of commands executed to file.
176
177 Example:
178 SQL# \o result.txt
179
180
181 load FILENAME to load from file SQL commands into SQL buffer.
182
183 Example:
184 SQL# \load commands.sql
185
186
187 save FILENAME to save SQL commands from SQL buffer to file.
188
189 Example:
190 SQL# \save commands.sql
191
192
194 General commands to use.
195
196 h show help (all commands).
197
198 Example:
199 SQL# \h
200
201
202 s TRUE, FALSE to silent messages.
203
204 Example 1:
205 SQL# \s true
206
207 Example 2:
208 SQL# \s false
209
210
211 r reset or clear the query buffer.
212
213 Example:
214 SQL# \r
215
216
217 print show what's in the SQL buffer now.
218
219 Example:
220 SQL# \print
221
222 SH VARIABLES WHICH CAN BE USED AS PARAMETERS Commands to set
223 variables which can be used as Parameters in an SQL statement.
224 If the SQL contains any parameters, the parameter does not have
225 a variable set, the user will be prompted for the value for each
226 missing parameter.
227
228 set NAME VALUE to set an internal variable.
229
230 Example:
231 SQL# \set sFirstName John
232
233
234 unset NAME to remove an internal variable.
235
236 Example:
237 SQL# \unset sFirstName
238
239
240 variable
241 NAME to display the value of an internal variable.
242
243 Example:
244 SQL# \variable sFirstName
245
246
248 Enable or Disble support for a particular provider option
249
250 UseParameters
251 TRUE,FALSE to use parameters when executing SQL which use the
252 variables that were set.
253
254 If this option is true, the SQL contains parameters, and for each
255 parameter which does not have a SQL# variable set, the user will be
256 prompted to enter the value For that parameter.
257
258 Example:
259 SQL# \useparameter true
260
261
262 Default: false
263
264 UseSimpleReader
265 TRUE,FALSE to use simple reader when displaying results.
266
267 Example:
268 SQL# \usesimplereader true
269
270
271 Default: false. Mostly, this is dependent on the provider. If the
272 provider does not have enough of IDataReader implemented to have the
273 normal reader working, then the simple reader can be used. Providers
274 like SqlClient, MySQL, and PostgreSQL have this ption defaulting to
275 true.
276
278 PROVIDER NAME NAMESPACE ASSEMBLY
279
280 oracle Oracle 8i System.Data.OracleClient System.Data.OracleClient
281 postgresql NetPostgreSQL Npgsql Npgsql
282 bytefx ByteFX MySQL ByteFX.Data.MySqlClient ByteFX.Data
283 sqlclient MS SQL 7/2000 System.Data.SqlClient System.Data
284 odbc ODBC System.Data.Odbc System.Data
285 sqlite SQL Lite Mono.Data.SqliteClient Mono.Data.SqliteClient
286 sybase Sybase Mono.Data.SybaseClient Mono.Data.SybaseClient
287 olebb OLE DB System.Data.OleDb System.Data
288 tds TDS Generic Mono.Data.TdsClient Mono.Data.TdsClient
289 msodbc MS ODBC Microsoft.Data.Odbc Microsoft.Data.Odbc
290 firebird Firebird SQL FirebirdSql.Data.FirebirdSql FirebirdSql.Data.Firebird
291 mysql MySQL AB MySql.Data.MySqlClient MySql.Data
292
293 NOTES:
294
295 npgsql maps to postgresql above.
296 mysqlnet maps to mysql above.
297 odbc is treated as an external provider for .NET 1.1 and above.
298 msodbc is an external provider for compatibility with .NET 1.0
299
300 MySql.Data has replaced the mysql provider. If you still need to use ByteFX.Data, then
301 use bytefx.
302
303 MySql.Data is not included with Mono. You need to
304 download the MySQL Connector/Net from MySQL AB at
305 http://dev.mysql.com/downloads/connector/net/1.0.html
306
307
309 Example connection strings for various providers to be used via the
310 command \ConnectionString
311
312 Example of usage:
313 \connectionstring Database=testdb
314
315
316 Connection String examples:
317
318
319 Microsoft SQL Server via System.Data.SqlClient
320 or Mono.Data.TdsClient provider:
321
322 Server=DANPC;Database=pubs;User ID=saPassword=
323
324
325 ODBC via System.Data.Odbc provider using
326 a DSN named "MSSQLDSN" I set up
327 in the Windows control panel's ODBC Data Sources
328 which connects to Microsoft SQL Server 2000:
329
330 DSN=MSSQLDSN;UID=danmorg;PWD=freetds
331
332
333 SQL Lite via Mono.Data.SqliteClient
334 provider which connects to the
335 database file SqliteTest.db; if not found,
336 the file is created:
337
338 URI=file:SqliteTest.db
339
340
341 OLE DB via System.Data.OleDb provider
342 which connects to a PostgreSQL database:
343
344 Provider=PostgreSQL;Addr=127.0.0.1;Database=rodrigo
345
346
347 Oracle via System.Data.OracleClient
348
349 Data Source=testdb;User ID=scott;Password=tiger
350
351
352 Npgsql (.NET PostgreSQL) from
353 http://gborg.postgresql.org/project/npgsql/projdisplay.php
354
355 Server=localhost;Database=test;User ID=postgres;Password=fun2db
356
357
358 ByteFX (ByteFX MySQL) from
359
360 Server=localhost;Database=test;User ID=mysql;Password=
361
362
363 FirebirdSql via FirebirdSql.Data.Firebird (not included with Mono)
364
365 Database=C:\FIREBIRD\EXAMPLES\EMPLOYEE.FDB;User=SYSDBA;Password=masterkey;Dialect=3;Server=localhost
366
367
368 MySQL (MySQL AB) from http://www.mysql.com/
369
370 Server=localhost;Database=test;User ID=mysql;Password=mypass;Pooling=false
371
372
373
375 No support for tracing right now.
376
378 The Mono SQL Query Tool was written
379 by Daniel Morgan <danielmorgan@verizon.net>
380
382 The Mono SQL Query Tool is released under the terms of the GNU GPL.
383 Please read the accompanying `COPYING' file for details. Alternative
384 licenses are available from Novell or Daniel Morgan.
385
387 To report bugs in the compiler, you can use `bug-buddy', or you can
388 file bug reports in our bug tracking system:
389 http://bugzilla.ximian.com.
390
392 For details, visit:
393 http://lists.ximian.com/mailman/listinfo/mono-devel-list
394
396 For details, visit:
397 http://www.mono-project.com
398
400 mono(1), mint(1)
401
402
403
404
405 25 December 2005 sqlsharp(1)