.ig >>
<STYLE TYPE="text/css">
<!--
        A:link{text-decoration:none}
        A:visited{text-decoration:none}
        A:active{text-decoration:none}
        OL,UL,P,BODY,TD,TR,TH,FORM { font-family: arial,helvetica,sans-serif;; font-size:small; color: #333333; }

        H1 { font-size: x-large; font-family: arial,helvetica,sans-serif; }
        H2 { font-size: large; font-family: arial,helvetica,sans-serif; }
        H3 { font-size: medium; font-family: arial,helvetica,sans-serif; }
        H4 { font-size: small; font-family: arial,helvetica,sans-serif; }
-->
</STYLE>
<title>shsql: creating a shsql database</title>
<body bgcolor=99cc99 vlink=0000FF>
<br>
<br>
<center>
<table cellpadding=2 bgcolor=FFFFFF width=550 ><tr>
<td align=right><a href="shsql_home.html">
<img src="img/shsql.gif" border=0><br><small>SQL database system</a> &nbsp; </td></tr>
<td>
.>>

.TH Creating a SHSQL database TDH "28-APR-2004   TDH scg@jax.org" 


.SH Creating a SHSQL database
.IP \(bu
.ig >>
<a href="support.html">
.>>
\0Install the SHSQL software
.ig >>
</a>
.>>
if you haven't already.

.ig >>
<br><br>
.>>
.IP \(bu
There is no CREATE DATABASE command in SHSQL.  Instead, use the following procedure.

.ig >>
<br><br>
.>>

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

.ig >>
<br><br>
.>>

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

.ig >>
<br><br>
.>>

.IP
The result will be a project structure that will be used by \fBshsql\fR and/or \fBquisp\fR.
It will contain a \fCconfig\fR file that \fBshsql\fR programs will consult whenever they are invoked.
It will also create a small demo data file to play with, called \fCexamp_people\fR.

.ig >>
<br><br>
.>>

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

.ig >>
<br><br>
.>>

.IP \(bu
Repeat the above procedure for every SHSQL database you want to create.
Set \fCSHSQL_DB\fR to point to whichever database you want to access.

.ig >>
<br><br>
.>>

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



.ig >>
<br><br><br>
.>>

.ig >>
<a name=examples></a>
.>>
.SH Test drive
After running \fCnewproject.sh\fR make sure things are working by accessing some
demo material that is automatically installed by \fCnewproject.sh\fR:


.IP \(bu
Issue this command: \fCtabdef\fR  
.br
This should show you a list of existing tables (probably just \fCexamp_people\fR).

.ig >>
<br><br>
.>>

.IP \(bu
Issue this command: \fCtabdef examp_people\fR   
.br
This should list the table's fieldnames.

.ig >>
<br><br>
.>>

.IP \(bu
Issue an SQL select command, eg. 
.br
\fCshsql -n "select * from examp_people"\fR
.br
If this seems to work, you should be all set!

.ig >>
<br><br><br>
.>>

.SH Examples
An working example \fBshsql\fR database is included with the distribution,
in the directory \fCsqlexampledb\fR.  
A subdirectory there called \fCtestruns\fR contains several shell scripts
that contain various \fBshsql\fR commands.
See the README file there for more information.
.LP
For syntax examples, see the 
.ig >>
<a href="select.html">
.>>
\0select
.ig >>
</a>
.>>
and
.ig >>
<a href="iud.html">
.>>
\0insert/update/delete
.ig >>
</a>
.>>
pages.


.ig >>
<br>
<br>
</td></tr>
<td align=right>
<a href="shsql_home.html">
<img src="img/shsql.gif" border=0></a><br>
<a href="Copyright.html">Copyright Steve Grubb</a> &nbsp;
</td></tr>
</table>
.>>
