SQL database system
 
Manual page for Creating(a)

Creating a SHSQL database

  • Install the SHSQL software if you haven't already.

  • There is no CREATE DATABASE command in SHSQL. Instead, use the following procedure.

  • Think of a directory name where your project will reside (eg. /home/steve/proj1), and decide on a unix userid that will own the project.

  • Log in as the project owner userid, and run the shell script newproject.sh (it's located in the ./bin). It will prompt you for full pathname of the project directory you are creating.

  • The result will be a project structure that will be used by shsql and/or quisp. It will contain a config file that shsql programs will consult whenever they are invoked. It will also create a small demo data file to play with, called examp_people.

  • Set a shell environment variable called SHSQL_DB and be sure that it is exportable. It should contain the full pathname of your project directory.
    Eg. for /bin/ksh do: export SHSQL_DB=/home/steve/proj1
    For future, add this to your .profile or .cshrc file.

  • Repeat the above procedure for every SHSQL database you want to create. Set SHSQL_DB to point to whichever database you want to access.

  • Because temporary files will accumulate in the project tmp directory, a good practice is to put a find(1) command into the project owner's crontab to run daily or weekly, like this:
      /usr/bin/find /yourprojpath/tmp  ! -type d  -mtime +2 -exec rm -f {} \;
    



Test drive

After running newproject.sh make sure things are working by accessing some demo material that is automatically installed by newproject.sh:
  • Issue this command: tabdef
    This should show you a list of existing tables (probably just examp_people).

  • Issue this command: tabdef examp_people
    This should list the table's fieldnames.

  • Issue an SQL select command, eg.
    shsql -n "select * from examp_people"
    If this seems to work, you should be all set!


Examples

An working example shsql database is included with the distribution, in the directory sqlexampledb. A subdirectory there called testruns contains several shell scripts that contain various shsql commands. See the README file there for more information.

For syntax examples, see the select and insert/update/delete pages.


Copyright Steve Grubb  


Markup created by unroff 1.0,    April 28, 2004.