DB2 Server for VSE & VM: Database Services Utility


SCHEMA

A schema file specifies an authorization ID and a list of table, view, and privilege definitions using the syntax of the CREATE TABLE, CREATE VIEW, and GRANT statements. The SCHEMA command reads and processes the statements from a schema file.

SCHEMA Format


Table 7. SCHEMA Command Syntax
Format:
    (1)
>>--------SCHEMA INFILE--(--ddname----| option-c |--)----------->
 
>-----+---------------------+----------------------------------><
      '-IN--(dbspace_name)--'
 

Notes:

  1. Option C is valid in DB2 Server for VSE only.

 
option-c
 
|--+---------------------------+---+----------------------------------+->
   |           .-2000--.       |   |                 .-REWIND---.     |
   '-BLKSZ--(--+-size--+---)---'   |       .-(TAPE)--+-NOREWIND-+--.  |
                                   '-PDEV--+-(DASD)----------------+--'
 
>---------------------------------------------------------------|
 
 
Example:

SCHEMA INFILE(IN1 BLKSZ(800))

Authorization:

You must be connected as the AUTHORIZATION ID specified in the CREATE SCHEMA statement.

INFILE (ddname)
identifies the sequential input file containing the schema.

ddname
in DB2 Server for VSE: this is the TLBL or DLBL job control statement file name for the sequential input file. The file must have a record format of fixed-length blocked and a record length of 80.

Alternatively, SCHEMA can read its input from SYSIPT by using a READ MEMBER. You use the READ MEMBER NOCONT option to properly close the SYSIPT file. An example of using READ MEMBER with NOCONT is:

SCHEMA INFILE(SYSIPT)
READ MEMBER schema-member (NOCONT

If you do not specify the NOCONT option, the database manager reads in the SYSIPT records following the READ MEMBER statement as part of the SCHEMA file; then SYSIPT can provide additional input after the READ MEMBER statement.

in DB2 Server for VM: this is the name of the sequential input file. It must have records with a fixed length of 80 characters. The file characteristics specified in the FILEDEF command or the default FILEDEF options are the source of the input record definition information for the Database Services Utility. Do not specify SYSIN or SYSPRINT as the ddname.

dbspace-name
specifies the name of the dbspace where the table is to be placed if no dbspace-name is given in the CREATE TABLE statement. If the CREATE TABLE statement in the SCHEMA input file specifies a dbspace-name then this overrides the name of the dbspace given in the SCHEMA command.

BLKSZ (size) (DB2 Server for VSE Only)
is a parameter that specifies the block size of the sequential input file. The default block size is 2 000 bytes per block.

PDEV (TAPE or DASD) (DB2 Server for VSE Only)
is an optional parameter that specifies the device type (DASD or TAPE) of the sequential (SAM) input file. If PDEV(DASD) is specified, the file resides on any device supported by the VSE DTFSD macro. VSAM-managed SAM does not support spanned records. If PDEV(TAPE) is specified, the file resides on any device supported by the VSE DTFMT macro. The default is PDEV(TAPE).

NOREWIND or REWIND
controls tape file rewind processing performed during OPEN processing. This parameter is valid only if you specify TAPE for PDEV. The default processing is REWIND.

NOREWIND
specifies that the tape file is not to be rewound by OPEN processing. If NOREWIND is specified for input tape files referenced by a series of SCHEMA commands, you must ensure that the tape files being referenced are in ascending sequence. For example, if NOREWIND is specified in a sequence of two SCHEMA commands and the first command reads tape file 2, then the second command must reference tape file 3 or a higher number. If it references tape file 1, an OPEN error occurs.

REWIND
specifies OPEN processing to rewind the tape file.


Table 8. Contents of the Schema (in a Sequential Input File)
Format:
                                                  .-;-.
>>-CREATE SCHEMA AUTHORIZATION--authorization_id--+---+--------->
 
      .--------------------------------.
      V                                |
>--------+--------------------------+--+-----------------------><
         |                  .-;-.   |
         '-schema_statement-+---+---'
 
Example:
-- create table TAB1 and give Jones SELECT privilege
CREATE SCHEMA AUTHORIZATION SMITH
CREATE TABLE SMITH.TAB1 (COL1 CHAR(4))
GRANT SELECT ON TAB1 TO JONES

The first line of the above example is a comment line. To insert comments within the schema file:

The sequential input file must contain only one CREATE SCHEMA statement, which must be the first statement in the file (unless the preceding lines are comments); otherwise, the Database Services Utility issues an error message and stops processing the SCHEMA command.

AUTHORIZATION authorization id
You must be connected as the authorization id in the AUTHORIZATION clause. If a schema statement does not specify an owner, the statement is processed for the authorization ID. For example, in Table 8 the SELECT privilege in the GRANT statement is granted on SMITH.TAB1.

schema-statement
refers to every statement following the CREATE SCHEMA statement. Valid schema statements are:

The schema statements must be entered in uppercase. See the DB2 Server for VSE & VM SQL Reference for the correct syntax of valid schema statements. Successful statements are committed if the Database Services Utility AUTOCOMMIT indicator is ON.

The Database Services Utility issues an error message if any invalid statement is in the schema, and might or might not continue processing on the next statement, depending on the setting of ERRORMODE.

You can change the setting of the ERRORMODE and AUTOCOMMIT indicators before the SCHEMA command by issuing the Database Services Utility SET ERRORMODE and SET AUTOCOMMIT commands. If ERRORMODE is set to CONTINUE, processing continues on the next statement following a minor error on any sequential input file statement other than the CREATE SCHEMA statement. If AUTOCOMMIT is ON, the work is committed after each successful statement. For a complete description of these commands, see SET ERRORMODE and SET AUTOCOMMIT.

Using File Definitions with the DB2 Server for VM SCHEMA Command

The schema file must have a fixed length of 80 characters. This format is used if you do not specify any FILEDEF options when you define a schema file. For example, you can create a FILEDEF such as this:

FILEDEF DBSFILE DISK DBSFILE SCHEMIN A

where DBSFILE is the name of the schema file as you refer to it in the SCHEMA command.

For a procedure to construct a FILEDEF command, see Using File Definitions. For more information about FILEDEF parameters and options, see Appendix B, FILEDEF Command Syntax and Notes.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]