.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: removing, renaming, or copying your indexes, fields, tables, or databases</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 removing, renaming, or copying your indexes, fields, tables, or databases TDH "28-APR-2004   TDH scg@jax.org" 

.SH Removing, renaming, or copying your indexes, fields, tables, or databases
.LP

One of SHSQL's advantages is that it is generally easy to move databases, clone databases,
and do other manipulations, since SHSQL databases are unix text files or directories of files.
Depending on the task, there may be an SQL-based method, a manual shell command line method, or both.

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

.SH Removing all indexes associated with a table
SQL method: \fCdrop index on \fItablename\fC *\fR
.LP
Manual method:
Go into the \fCindexes\fR directory and delete all files that begin 
with the table name.  For example, to remove all indexes
for table 'people': \fCrm people.*\fR

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

.SH Removing the index on a specific table and field
SQL method: \fCdrop index on \fItablename\fR \fIfieldname\fR
.LP
Manual method:
Go into the \fCindexes\fR directory.
Index files are named \fItablename\fC . \fIfieldname\fC . \fIilevel\fR.
Delete the index files that contain the table and field in the file name.
The \fItablename\fC.0 file requires no modification.

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

.SH Removing all indexes in a database
Manual method: Go into the \fCIndexes\fR directory and do: \fCrm *\fR

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


.SH Removing a table
SQL method: \fCdrop table \fItablename\fR
.LP
Manual method:
Go into the \fCdbtabledir\fR directory
and delete the desired table data file.
If any indexes are associated with the table, delete them also (see above).

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

.SH Removing a database
Manual method: To completely delete an entire database, do: \fCrm -rf\fR  on 
the project directory.  (Are you sure?)

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

.SH Moving or renaming a database
Manual method: rename the project directory,
then modify the project directory name in the 
.ig >>
<a href="config.html">
.>>
\0project config file,
.ig >>
</a>
.>>
and change \fCSHSQL_DB\fR if applicable.

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

.SH Changing the ownership of a database
Manual method: Use \fCchown -r\fR and/or \fCchgrp -r\fR on the project directory.

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

.SH Copying / cloning a database
Manual method:
For example, to copy the database located in \fC/home/steve/dbproj\fR, go to 
\fC/home/steve\fR and issue the command \fCcp -r -p dbproj dbproj2\fR.
Then go into \fCdbproj2\fR and modify the config file.
Set \fCSHSQL_DB\fR to reference whichever database copy you wish.

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

.SH Renaming a table
Manual method:
Go into \fCdbtabledir\fR directory and rename the table data file.
If any indexes are associated with the table, rename those files
in the \fCIndexes\fR directory.
Any code that references the table by name will also require attention.

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

.SH Copying a table
Manual method:
Go into \fCdbtabledir\fR directory and do a \fCcp -p\fR on the table data file.

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

.SH Renaming a field
.ig >>
<a href="tables.html#edit">
.>>
\0Edit the data file
.ig >>
</a>
.>>
and change the fieldname header.
If any indexes are associated with the fieldname, rename those files in the \fCIndexes\fR directory.
Any code that references the field by name will also require attention.

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

.SH Adding a new field to an existing table
SQL method: 
.ig >>
<a href="alter.html">
.>>
\0ALTER TABLE
.ig >>
</a>
.>>
command.
.LP
Manual method: processing with your favorite tools.

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

.SH Removing a field from a table
SQL method:
.ig >>
<a href="alter.html">
.>>
\0ALTER TABLE
.ig >>
</a>
.>>
command.
.LP
Manual method: processing with your favorite tools.

.SH Rearranging fields in a table
.LP
Process with your favorite tools.  No other file needs to be modified.

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