shsql: removing, renaming, or copying your indexes, fields, tables, or databases

SQL database system
| Manual page for removing,(renaming,)

## Removing, renaming, or copying your indexes, fields, tables, or databases

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

## Removing all indexes associated with a table

SQL method: `drop index on` tablename`*`

Manual method: Go into the `indexes` directory and delete all files that begin with the table name. For example, to remove all indexes for table 'people': `rm people.*`

## Removing the index on a specific table and field

SQL method: `drop index on` tablename fieldname

Manual method: Go into the `indexes` directory.`` Index files are named tablename`.` fieldname`.` ilevel.`` Delete the index files that contain the table and field in the file name.`` The tablename`.0 file requires no modification.``
`

## Removing all indexes in a database

Manual method: Go into the `Indexes` directory and do: `rm *`

## Removing a table

SQL method: `drop table` tablename

Manual method: Go into the `dbtabledir` directory and delete the desired table data file.`` If any indexes are associated with the table, delete them also (see above).``

## Removing a database

Manual method: To completely delete an entire database, do: `rm -rf` on the project directory. (Are you sure?)

## Moving or renaming a database

Manual method: rename the project directory, then modify the project directory name in the project config file, and change `SHSQL_DB` if applicable.``

## Changing the ownership of a database

Manual method: Use `chown -r` and/or `chgrp -r` on the project directory.``

## Copying / cloning a database

Manual method: For example, to copy the database located in `/home/steve/dbproj`, go to `/home/steve` and issue the command `cp -r -p dbproj dbproj2`.`` Then go into `dbproj2` and modify the config file.`` Set `SHSQL_DB` to reference whichever database copy you wish.``

## Renaming a table

Manual method: Go into `dbtabledir` directory and rename the table data file.`` If any indexes are associated with the table, rename those files in the `Indexes` directory.`` Any code that references the table by name will also require attention.``

## Copying a table

Manual method: Go into `dbtabledir` directory and do a `cp -p` on the table data file.``

## Renaming a field

Edit the data file and change the fieldname header.`` If any indexes are associated with the fieldname, rename those files in the `Indexes` directory.`` Any code that references the field by name will also require attention.``

## Adding a new field to an existing table

SQL method: ALTER TABLE command.``

Manual method: processing with your favorite tools.``

## Removing a field from a table

SQL method: ALTER TABLE command.``

Manual method: processing with your favorite tools.``

## Rearranging fields in a table

Process with your favorite tools. No other file needs to be modified.``
Copyright Steve Grubb

Markup created by unroff 1.0, `` `` April 28, 2004.