home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / compiler / 2253 < prev    next >
Encoding:
Text File  |  1993-01-25  |  5.1 KB  |  120 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!world!iecc!compilers-sender
  3. From: joshua@veritas.com (Joshua Levy)
  4. Subject: Re: SQL Interpreter
  5. Reply-To: joshua@veritas.com (Joshua Levy)
  6. Organization: VERITAS Software
  7. Date: Mon, 25 Jan 1993 18:09:03 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <93-01-183@comp.compilers>
  10. References: <93-01-153@comp.compilers>
  11. Keywords: SQL, interpreter
  12. Sender: compilers-sender@iecc.cambridge.ma.us
  13. Lines: 105
  14.  
  15. >[There are several free SQL parsers, but no free interpreters that I know of.
  16. >Perhaps an inexpensive PC database would do the trick.  Even once the SQL
  17. >is compiled, you need an index search and update engine to do the work.
  18. -John]
  19.  
  20. I know of a partial SQL interpreter which is either PD or freely
  21. redistributable.  It is called shql and is written in bourne shell script.
  22.  
  23. Below my sig is the README file from shql version 1.1:
  24.  
  25. Joshua Levy  (joshua@veritas.com)
  26.  
  27.  
  28.                               S H Q L  version 1.1
  29.  
  30. Shql is a program that reads SQL commands interactively and executes those
  31. commands by creating and manipulating Unix files.
  32.  
  33. This program requires a bourne shell that understands functions, as well
  34. as awk, grep, cut, sort, uniq, join, wc, and sed.
  35.  
  36. This script can be invoked with the command
  37.  
  38.         shql [-q] {database name}
  39.  
  40. A directory must be created for the database before you may use it.  This
  41. directory will house all data files for a single database.  All datafiles
  42. are created with mode 666 ('rw-rw-rw-'), so create the directory with 777
  43. ('rwxrwxrwx') if you want the database to be sharable, and 700
  44. ('rwx------') to be private.  Of course, multiple databases are possible.
  45. A database called 'mydb' may be created as a directory $HOME/mydb,
  46. $HOME/shql/mydb, ./mydb, or as $SHQL_ROOT/mydb, where $SHQL_ROOT is
  47. defined below.  The -q option turns off the display of headings so the
  48. output of shql can be used by other programs by caputuring all lines that
  49. begin the pipe symbol.
  50.  
  51. The program is patterned after Ingres' interactive sql terminal monitor
  52. program.  Terminal monitor commands begin with either a forward or
  53. back-slash.  Forward slashes may appear at the end of a commend line.
  54. Back-slashes are accepted for compatability.  The /g is the 'go' command,
  55. /p is print, and /q is quit.  Try 'help commands' for a full list.
  56. Because of this, if you need to put a slash as the second to last caracter
  57. on a line, you should add a space between the slash and the last
  58. character.
  59.  
  60. To get started, invoke shql with a database name.  Use the directory name
  61. you created above. Type
  62.  
  63.         shql mydb
  64.  
  65. if the directory you created was 'mydb'.  Once shql starts up, you should
  66. see the database name displayed, and then a '*'. At this point, the most
  67. valuable thing is to type help,
  68.  
  69.         * help
  70.         * /g
  71.  
  72. You may then go on.  The command 'help syntax' displays syntax for all SQL
  73. operations, and 'help commands' displays all shql workspace commands.  Try
  74. the demo.
  75.  
  76. Shql can execute only one operation at a time, but operations can be
  77. spread over several lines.
  78.  
  79. Shql operations are allow 'select' operations on multiple tables.  Table
  80. names are read from left to write in select's 'from' section, so the
  81. tables should be ordered with the most central tables first.  In two-table
  82. joins, it doesn't matter.  In three table joins, if you join table A-to-B
  83. and B-to-C, B must not be the last table in the from clause, because shql
  84. will not be able to join tables A-C.  If you get the message 'Join not
  85. found, try reordering tables', this is probably the problem.  Also
  86. qualified field names are not understood, like tablename.fieldname, so if
  87. you are joining my_id in table A with my_id in table B, just say 'my_id =
  88. my_id'.  Views can also be used to create multi-table selects.
  89.  
  90. Subselects are implemented, but must be the last operand of a 'where'
  91. clause, most useful with 'in'.
  92.  
  93. In most cases, commas are optional.  NULLs are not implemented.
  94. Aggregates like AVG() are implemented, but not with GROUP BY.
  95.  
  96. When INSERTing strings that contain the characters !,=,>,<,(, or ), spaces
  97. or backslashes may be added during the insert.  This is a side-effect of
  98. the string manipulation needed to properly parse the command parameters.
  99.  
  100. This SQL is type-less, so specify just the column width when creating
  101. tables.  This is used only for display purposes.  Shql is case-sensitive,
  102. and expects SQL key words to be in lower case.
  103.  
  104. Commands can be piped into shql, and the table data files are tab
  105. delimited, so awk scripts can be used to generate reports directly from
  106. the tables.  To operate on non-shql data files, create a dummy table with
  107. the proper fields, then copy your file into your shql data directory,
  108. replacing your delimiters with tabs, then run shql on the table, and
  109. convert the table back to its original format.  Grave accents (`) may be
  110. used to execute unix command from with shql.  Environment variables may
  111. also be used. See the demo for an example, i.e. "cat demo.shql | shql
  112. mydb".
  113.  
  114. If you have comments, suggestions, or bug reports contact:
  115.  
  116.     Bruce Momjian, root@candle.uucp (root%candle.uucp@bts.com)
  117. -- 
  118. Send compilers articles to compilers@iecc.cambridge.ma.us or
  119. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  120.