Basic SQL statements

For a detailed explanation and examples refer to "SQL Reference Manual"

CREATE TABLE command

Abbreviated Syntax:

CREATE TABLE tablename
(columnname format [NULL|NOT NULL]...)
[WITH-Clause]

e.g. CREATE TABLE area
(town char(12) NOT NULL,
sales_area char(2));

NOTE: the default is NULL

CREATE INDEX command

Abbreviated Syntax:

CREATE [UNIQUE] INDEX indexname ON tablename
(columnname[ASC|DESC],
...);

MODIFY command

Abbreviated Syntax:

MODIFY Tablename TO STORAGE-STRUCTURE
[UNIQUE] [ON Columnname [ASC|DESC],{Columnname [ASC|DESC]} [WITH Clause]]

e.g. MODIFY Stock TO ISAM UNIQUE ON Product-Code, Branch-Code

COPY command

There is a facility to 'Bulk load ' and 'Bulk unload' from files as long as the datatype/format is equivalent (i.e. for use in back-up copies):

COPY TABLE tablename() FROM|INTO 'filename';

Note: empty brackets() are only permissable when the Tables and data are identical in structure.

Abbreviated Syntax (when copying/loading selected columns from Table to Table):

COPY TABLE tablename ( col1 = type [WITH NULL], ...) FROM 'filename'; NOTE: You must use the WITH NULL clause when you have allowed NULLS in your TABLE structure;

e.g. to load from the file 'areadump' into the TABLE Area:

COPY TABLE area (town = char(12), sales_area = char(2) WITH NULL ) FROM 'areadump';


This WWW material is copyright De Montfort University and may only be reproduced or used if this copyright notice is included.


This page is John Skelton (email: jas@dmu.ac.uk).
Your comments or suggestions for improving this material are welcome via email. Thanks for your help.