home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 604b.lha / sqldb_v020392 / doc / sqldb_sqlrefman.doc < prev    next >
Encoding:
Text File  |  1992-02-04  |  6.8 KB  |  298 lines

  1. 0.0
  2. SQLdb SQL reference manual.  Everything in this manual applies only to SQLdb 
  3. and any resemblence to other SQL dialects is purely coincidental.
  4.  
  5. 1.0
  6. -----------------
  7. |SIMPLE ELEMENTS|
  8. -----------------
  9.  
  10. 1.1
  11. table:        SQL identifier
  12.  
  13. column:        SQL identifier
  14.  
  15. alias:        SQL identifier
  16.  
  17. cursor:        SQL identifier
  18.  
  19. An SQL identifier is composed of a letter followed by zero or more characters
  20. from the set of numbers, letters, '_', '#'.  Thus, A#_o1ne is a legal 
  21. indentifier, while _a#45 is not.
  22.  
  23. An SQL identifier cannot be a valid SQL keyword.
  24.  
  25. 1.2
  26. literal:    number or string enclosed in quotes
  27.  
  28.     1234        integer literal
  29.     0.345        float literal
  30.     'hello'        string literal
  31.     '12/21/70'    date literal
  32.     '14:45:37'    time literal
  33.  
  34. 1.3
  35. data-type:    FLOAT | SMALLINT | INTEGER | DATE | TIME | CHAR ( integer )
  36.  
  37.     FLOAT        floating point, range IEEE float
  38.     SMALLINT    small integer, range signed short
  39.     INTEGER        large integer, range signed int
  40.     DATE        date mo/da/yr
  41.     TIME        time hr:mn:sc
  42.     CHAR        fixed length character string
  43.  
  44. 2.0
  45. -----------------
  46. |DATA DEFINITION|
  47. -----------------
  48.  
  49. 2.1
  50. CREATE TABLE table ( table-def-item-list )
  51.  
  52. This statement will create the specified table.  If a table already exists,
  53. it will be overwritten.  You must OPEN TABLE or LOAD TABLE after it has been
  54. created in order to use it.
  55.  
  56. 3.0
  57. ----------
  58. |DATA I/O|
  59. ----------
  60.  
  61. 3.1
  62. LOAD TABLE table
  63.  
  64. This statement will open the specified table and load the rows into RAM.  You
  65. must CREATE TABLE before you can LOAD TABLE.
  66.  
  67. 3.2
  68. OPEN TABLE table
  69.  
  70. This statement will open the specified table.  You must CREATE TABLE before you
  71. can OPEN TABLE.
  72.  
  73. 3.3
  74. CLOSE TABLE table
  75.  
  76. This statement will close the specified table.  It write any changes to the
  77. table to disk.  All user tables must be closed before you may exit SQLdb.
  78.  
  79. 4.0
  80. -------------------------
  81. |BASIC DATA MANIPULATION|
  82. -------------------------
  83.  
  84. 4.1
  85. query-spec:    SELECT { select-item-list | * }
  86.             FROM table-ref-list
  87.             [ WHERE search-condition ]
  88.             [ GROUP BY group-ref-list [ HAVING search-condition ] ]
  89.             [ ORDER BY order-ref-list ]
  90.             [ OUTPUT TO file-name ]
  91.  
  92. This statement is used to retrieve information from the database.  It is
  93. made up of several clauses, which are explained in the following sections.
  94.  
  95. 4.1.1 FROM clause
  96.  
  97. This clause specifies which tables SQLdb is supposed to gather information
  98. from.
  99.  
  100. 4.1.2 WHERE clause
  101.  
  102. This clause is used by several other statements, and is used to restrict
  103. the set of rows to be operated on.  A WHERE clause succeeds if the 
  104. search-condition evaluate to true.
  105.  
  106. 4.1.3 GROUP BY clause
  107. 4.1.3.1
  108.  
  109. 4.1.3.2 HAVING clause
  110.  
  111. 4.1.4 ORDER BY clause
  112.  
  113. 4.1.5 OUTPUT TO clause
  114.  
  115. 4.2
  116. subquery:    \[ query-spec \]
  117.  
  118. 4.3
  119. INSERT INTO table [ ( column-list ) ]
  120.     VALUES ( insert-item-list )
  121.  
  122. This statement is used to place information in the database.  The column
  123. list is optional.  If it is supplied, each value is placed in the corresponding
  124. column in the column-list.  Otherwise, the column-list default to all columns
  125. in the table.  Any missing values are treated as AMARKs.
  126.  
  127. 4.4
  128. DELETE FROM table [ WHERE search-condition ]
  129.  
  130. This statement is used to delete rows that satisfy the optional WHERE clause.
  131. If the WHERE clause is omitted, all rows in the table are deleted.
  132.  
  133. 4.5
  134. UPDATE table SET assignment-list [ WHERE search-condition ]
  135.  
  136. This statement is used to modify existing rows that satisfy the optional WHERE
  137. clause.  If the WHERE clause is omitted, all rows in the table are modified.
  138.  
  139. 5.0
  140. -------------------------
  141. |CURSOR BASED STATEMENTS|
  142. -------------------------
  143.  
  144. The following statements can be type interactively, but they are intended to 
  145. be used through an ARexx port.
  146.  
  147. 5.1
  148. DECLARE cursor CURSOR FOR query-expr
  149.  
  150. This statement will create and define a cursor.
  151.  
  152. 5.2
  153. OPEN cursor
  154.  
  155. This statement will execute a previously DECLAREd cursor's query-expr. 
  156.  
  157. 5.3
  158. CLOSE cursor
  159.  
  160. This statement will close and remove an existing cursor.  A cursor that has
  161. been CLOSEd must be re-DECLAREd and OPENed.
  162.  
  163. 5.4
  164.  
  165. FETCH { COLUMNS | FIRST | LAST | PREVIOUS | NEXT |
  166.     ABSOLUTE integer | RELATIVE integer } OF cursor-name
  167.  
  168. This statement will retrieve the specified row or column list, of the table 
  169. created by the cursor's query-expr.
  170.  
  171. 6.0
  172. -------------------
  173. |SEARCH CONDITIONS|
  174. -------------------
  175.  
  176. 6.1
  177. search-condition:    search-item | search-item { AND | OR } search-item
  178.  
  179. Each search-item evaluates to a true, false, AMARK, or IMARK.  This is a
  180. four value logic system.
  181.  
  182. AND| F  A  I  T        OR| F  A  I  T
  183. ---------------        --------------
  184.  F | F  F  F  F        F | F  A  F  T
  185.  A | F  A  I  A        A | A  A  A  T
  186.  I | F  I  I  I        I | F  A  I  T
  187.  T | F  A  I  T        T | T  T  T  T
  188.  
  189. 6.2
  190. search-item:        { search-test | { NOT | MAYBE_A | MAYBE_I | MAYBE } ( search-condition ) }
  191.  
  192. The logical operators NOT, MAYBE_A, MAYBE_I, MAYBE are defined below:
  193.  
  194.     P |NOT P   P | MAYBE_I P   P | MAYBE_A P   P | MAYBE P
  195.     --------   -------------   -------------   -----------
  196.     t | f       t | f       t | f       t | f
  197.     a | a      a | f           a | t       a | t
  198.     i | i      i | t        i | f       i | t
  199.       f | t      f | f        f | f       f | f
  200.  
  201. 6.3
  202. search-test:        comparison-test | like-test | set-test |
  203.             quantified-test | existence-test
  204.  
  205. 6.4
  206. comparison-test:    expr { = | <> | < | <= | > | >= } { expr | subquery }
  207.  
  208. 6.5
  209. like-test:        column-ref [ NOT ] LIKE string-pattern
  210.  
  211. A string pattern is a string literal.  The '%' is a wildcard to match
  212. 0 or more characters, and the '_' is a wildcard to match one character.
  213.  
  214. 6.6
  215. set-test:        expr [ NOT ] IN { \( literal-list \) | subquery }
  216.  
  217. 6.7
  218. quantified-test:    expr { = | <> | < | <= | > | >= } { ALL | ANY | SOME } subquery
  219.  
  220. 6.8
  221. existence-test:        [ NOT ] EXISTS subquery
  222.  
  223. This evaluates to true if table resulting from subquery has at least one row
  224. in it.
  225.  
  226. 7.0
  227. -------------
  228. |EXPRESSIONS|
  229. -------------
  230.  
  231. 7.1
  232. expr:        function | expr2
  233.  
  234. This definition means that you cannot nest functions, and functions must
  235. appear by themselves.  Thus, AVG(4*(7-5)) is a valid expr, but MIN(col1)*3 is 
  236. not.
  237.  
  238. 7.2
  239. expr2:        expr-item | expr-item { + | - | * | / } expr-item
  240.  
  241. 7.3
  242. expr-item:    value | column-ref | ( expr2 )
  243.  
  244. 7.4
  245. value:        literal | AMARK | IMARK | NULL
  246.  
  247. 7.5
  248. function:    { AVG | MAX | MIN | SUM | COUNT } ( expr2 )
  249.  
  250. Functions can only be applied to numeric (FLOAT, SMALLINT, INTEGER) columns.
  251.  
  252.     AVG        average of all values in an expression
  253.     MAX        maximum value in an expression
  254.     MIN        minimum value in an expression
  255.     SUM        total of values in an expression
  256.     COUNT        number of values (rows)
  257.  
  258. 8.0
  259. --------------------
  260. |STATEMENT ELEMENTS|
  261. --------------------
  262.  
  263. assignment:    column = expr
  264.  
  265. insert-item:    value
  266.  
  267. select-item:    expr
  268.  
  269. table-ref:    table [ alias ]
  270.  
  271. column-ref:    [ { table | alias } . ] column
  272.  
  273. group-ref:    column-ref | number
  274.  
  275. order-ref:    group-ref [ { ASC | DESC } ]
  276.  
  277. table-def-item:    column-def
  278.  
  279. column-def:    column data-type
  280.  
  281.  
  282. 9.0
  283. ------
  284. |MISC|
  285. ------
  286.  
  287. 9.1
  288. DISPLAY TABLE table;
  289.  
  290. This statement will display information about specified table.  The table
  291. must have been OPENed or LOADed.
  292.  
  293. 9.2
  294. DISPLAY DATABASE;
  295.  
  296. This statement will display the names of all OPENed or LOADed tables.
  297.  
  298.