JDB SQL Reference |
This chapter describes JDB-specific elements, for example, the database and database column naming conventions and data types that are supported in a JDB database. The information about your JDB database and tables, such as its primary and foreign key specification, are stored in system tables which are automatically created.
Also discussed are:
Naming Conventions |
Each database is stored as an operating system file. Therefore, the name for the database must follow operating system naming conventions. If the database name contains characters that are not alphanumeric, the name specified in the CREATE DATABASE
statement must be enclosed in single quotation marks.
You can create databases when you are connected to @system
or when you are connected to another database. For more information on the CREATE DATABASE
statement, refer to page 6-9.
Identifiers, such as table names and column names, must start with a letter, but they can contain letters, numbers, and underscores in any combination. They cannot contain dollar signs or periods. The maximum length of an identifier is 31 characters. If more than 31 characters are entered, the value is truncated.
Table names must be unique within the database. Each column name in a database table must be unique within that table.
Since column names can be duplicated in different tables, therefore, some statements might require that you uniquely identify a column name by including its database table name. For example, in the sample database, the last_name
column appears in more than one table. To specify the last_name
column in the actors table, use the following syntax:actors.last_name
You cannot use any of the JDB keywords as an identifier. For a list of the keywords, refer to page C-1.
JDB is case insensitive and stores the identifiers in lower case regardless of which case is used to enter them. If you enter address1
, ADDRESS1
, or Address1
, JDB stores the column as address1.
Data Types |
Table 4-1 lists the data types available in JDB:
For more information on data types, refer to page 6-15.
System Tables |
When you create a new database, five system tables are automatically created that contain information (such as column names and primary/foreign key specifications) about the database itself. You can query for information stored in these tables just like any other database table; however, you can not edit these tables.
The systabs system table contains information about each database table.
Column Name | Description |
---|---|
tname |
Table name |
ttype |
Table type |
ncols |
Number of columns |
seek |
Column for internal use |
The syscols system table contains information about the columns in each database table.
The syskeys system table specifies the primary and foreign keys.
The syskeycols system table contains information about each primary and foreign key column.
The sysrkeycols
system table contains information about the columns listed in the REFERENCES
clause of a CREATE TABLE
statement.
Journal Files |
JDB automatically creates journal files in your database directory. These files record your actions on the current database. The current journal file is named j1databaseName
. When you start a JDB session, the current journal file is copied to a file named j0databaseName
. If the file j0databaseName
already exists, its contents are replaced. Journal files can be reinstated using the utility jdbroll
.
Configuration |
The environment variables SMEDITOR
or EDITOR
determine which text editor is available in JISQL
or in isql
. When using JISQL
, the specified editor can be used to make changes to the SQL text window. When using isql, entering the edit command displays the last statement in the specified text editor.
The error messages for JDB are stored in the Panther message file. If the program has trouble locating the error messages, check the setting of the variable SMVARS
.
If you place your JDB database in the application directory or in one of the directories listed in SMPATH
, you do not need to specify the path in the DBMS DECLARE CONNECTION
statement.