home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.compilers
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!world!iecc!compilers-sender
- From: joshua@veritas.com (Joshua Levy)
- Subject: Re: SQL Interpreter
- Reply-To: joshua@veritas.com (Joshua Levy)
- Organization: VERITAS Software
- Date: Mon, 25 Jan 1993 18:09:03 GMT
- Approved: compilers@iecc.cambridge.ma.us
- Message-ID: <93-01-183@comp.compilers>
- References: <93-01-153@comp.compilers>
- Keywords: SQL, interpreter
- Sender: compilers-sender@iecc.cambridge.ma.us
- Lines: 105
-
- >[There are several free SQL parsers, but no free interpreters that I know of.
- >Perhaps an inexpensive PC database would do the trick. Even once the SQL
- >is compiled, you need an index search and update engine to do the work.
- -John]
-
- I know of a partial SQL interpreter which is either PD or freely
- redistributable. It is called shql and is written in bourne shell script.
-
- Below my sig is the README file from shql version 1.1:
-
- Joshua Levy (joshua@veritas.com)
-
-
- S H Q L version 1.1
-
- Shql is a program that reads SQL commands interactively and executes those
- commands by creating and manipulating Unix files.
-
- This program requires a bourne shell that understands functions, as well
- as awk, grep, cut, sort, uniq, join, wc, and sed.
-
- This script can be invoked with the command
-
- shql [-q] {database name}
-
- A directory must be created for the database before you may use it. This
- directory will house all data files for a single database. All datafiles
- are created with mode 666 ('rw-rw-rw-'), so create the directory with 777
- ('rwxrwxrwx') if you want the database to be sharable, and 700
- ('rwx------') to be private. Of course, multiple databases are possible.
- A database called 'mydb' may be created as a directory $HOME/mydb,
- $HOME/shql/mydb, ./mydb, or as $SHQL_ROOT/mydb, where $SHQL_ROOT is
- defined below. The -q option turns off the display of headings so the
- output of shql can be used by other programs by caputuring all lines that
- begin the pipe symbol.
-
- The program is patterned after Ingres' interactive sql terminal monitor
- program. Terminal monitor commands begin with either a forward or
- back-slash. Forward slashes may appear at the end of a commend line.
- Back-slashes are accepted for compatability. The /g is the 'go' command,
- /p is print, and /q is quit. Try 'help commands' for a full list.
- Because of this, if you need to put a slash as the second to last caracter
- on a line, you should add a space between the slash and the last
- character.
-
- To get started, invoke shql with a database name. Use the directory name
- you created above. Type
-
- shql mydb
-
- if the directory you created was 'mydb'. Once shql starts up, you should
- see the database name displayed, and then a '*'. At this point, the most
- valuable thing is to type help,
-
- * help
- * /g
-
- You may then go on. The command 'help syntax' displays syntax for all SQL
- operations, and 'help commands' displays all shql workspace commands. Try
- the demo.
-
- Shql can execute only one operation at a time, but operations can be
- spread over several lines.
-
- Shql operations are allow 'select' operations on multiple tables. Table
- names are read from left to write in select's 'from' section, so the
- tables should be ordered with the most central tables first. In two-table
- joins, it doesn't matter. In three table joins, if you join table A-to-B
- and B-to-C, B must not be the last table in the from clause, because shql
- will not be able to join tables A-C. If you get the message 'Join not
- found, try reordering tables', this is probably the problem. Also
- qualified field names are not understood, like tablename.fieldname, so if
- you are joining my_id in table A with my_id in table B, just say 'my_id =
- my_id'. Views can also be used to create multi-table selects.
-
- Subselects are implemented, but must be the last operand of a 'where'
- clause, most useful with 'in'.
-
- In most cases, commas are optional. NULLs are not implemented.
- Aggregates like AVG() are implemented, but not with GROUP BY.
-
- When INSERTing strings that contain the characters !,=,>,<,(, or ), spaces
- or backslashes may be added during the insert. This is a side-effect of
- the string manipulation needed to properly parse the command parameters.
-
- This SQL is type-less, so specify just the column width when creating
- tables. This is used only for display purposes. Shql is case-sensitive,
- and expects SQL key words to be in lower case.
-
- Commands can be piped into shql, and the table data files are tab
- delimited, so awk scripts can be used to generate reports directly from
- the tables. To operate on non-shql data files, create a dummy table with
- the proper fields, then copy your file into your shql data directory,
- replacing your delimiters with tabs, then run shql on the table, and
- convert the table back to its original format. Grave accents (`) may be
- used to execute unix command from with shql. Environment variables may
- also be used. See the demo for an example, i.e. "cat demo.shql | shql
- mydb".
-
- If you have comments, suggestions, or bug reports contact:
-
- Bruce Momjian, root@candle.uucp (root%candle.uucp@bts.com)
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-