2
0

README 7.4 KB

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