#set TITLE = "Creating a SHSQL database"
#include top


.SH Creating a SHSQL database
.IP \(bu
#set FILE = "support.html"
#set TAG = "Install the SHSQL software"
#include link
if you haven't already.

#include space2
.IP \(bu
There is no CREATE DATABASE command in SHSQL.  Instead, use the following procedure.

#include space2

.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.

#include space2

.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.

#include space2

.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.

#include space2

.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.

#include space2

.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.

#include space2

.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



#include space

.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).

#include space2

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

#include space2

.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!

#include space

.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 
#set FILE = "select.html"
#set TAG = "select"
#include link
and
#set FILE = "iud.html"
#set TAG = "insert/update/delete"
#include link
pages.


#include bottom
