README 7.1 KB

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