Creating a Global Temporary Table

Add a global temporary table to the database. A global temporary table definition is kept in the database permanently. (The data disappears when you close the connection.)

Prerequisites
Database Version Table Privileges
SAP Sybase IQ 15.3 and 15.4 Global temporary table to be owned by self – you must have RESOURCE authority with CREATE permission on the main store dbspace in which the table is created.

Global temporary table to be owned by any user – you must have DBA authority.

SAP Sybase IQ 16.0 Global temporary table to be owned by self – you must have the CREATE TABLE system privilege.
Global temporary table to be owned by any user – you must have one of:
  • CREATE ANY TABLE system privilege
  • CREATE ANY OBJECT system privilege
Task
Altering or creating global tables can interfere with other users of the database.

For large tables, modifying an existing table or creating a new table can be a time-consuming operation. The internal CREATE TABLE statement delays execution of other processes until the statement completes. Although you modify tables while other connections are active, you cannot execute them while any other connection uses the table to be altered. Modifying a table excludes other requests referencing the table being offered while the internal ALTER TABLE statement processes.

  1. In the Perspective Resources view, select the resource, and select Resource > Administration Console.
  2. In the left pane, expand IQ Servers > Schema Objects > Tables, and then select Global Temporary Tables.
  3. Click the arrow next to Global Temporary Tables and select New.
    The Create Global Temporary Table wizard appears.
  4. On the Welcome page, specify
    Option Description
    Select a resource for which the table will be created From the list, select the resource for which the table will be created.
    What do you want to name the table? Enter a unique name for the new table; maximum of 128 characters.
    Which user do you want to own the table? From the list, select the user to own the table.
  5. Click Next.
  6. On the Type page, specify the type of global temporary table to create. For transactional (default), specify whether the rows are deleted (default) or preserved when a commit occurs. Non-transactional global temporary tables are not affected by commit or rollback operations and can provide performance improvements in some circumstances since operations on the table do not cause entries to be made in the rollback log. Click Next.
  7. On the Columns page, each row in the Column Definitions table corresponds to a column. Click New to add column definitions for the table.
  8. Follow the Create Column wizard prompts.
    1. On the Column Name page, specify the name of the column and indicate whether the column is to be a primary key column. Click Next.
    2. On the Data Type page, specify:
      Option Description
      Built-in type (Default) Choose a predefined data type for the column. Integers, character strings, and dates are examples of predefined data types. For some of these types, you can specify size and scale.
      • Size — Length of string columns, or the total number of digits to the left and right of the decimal point in the result of any decimal arithmetic for numeric columns. For numeric columns, the size is also called the PRECISION value.
      • Scale — Minimum number of digits after the decimal point when an arithmetic result is truncated to the maximum PRECISION value.
      • Units — Unit corresponding to the data type's size. Possible units include: bits, bytes, characters, or digits. For CHAR and VARCHAR data types, you can specify the unit as bytes or characters.
      • Compress values — Not available for all built-in types) Select to compress column values. If a column is compressed, database server activities such as indexing, data comparisons, and statistics generation may be slightly slower if they involve the compressed column because the values must be compressed when written, and decompressed when read.
      • Maintain BLOB indexes for large values — (Available for character, binary, and bit types only) Maintain BLOB indexes for large values.
      Domain Choose a domain. A domain is a named combination of built-in data types, default value, check condition, and nullability.
    3. Click Next.
    4. On the Value page, specify:
      Field Description
      No default or computed value (Default) Select this option if the column is not a computed value and has no default value.
      Default value Select this option if the column has a default value. If the column is based on a domain, this setting inherits the domain's default value (if any), but you can override the value for the column. Choosing the Default value option enables the User-defined and System-defined options.
      • User-defined — Type a custom value (string, number, or other expression) for the default value. If you have based the column on a domain, you can retain the domain's default value (if any), or override it for the column.
        • Literal string — Specify whether the default value for the column should be treated as a literal string. By default, this option is selected for character columns and domains with a character base type. You do not need to enclose default text in single quotes, and escape embedded single quotes or backslashes in the string.
      • System-defined — Lets you select a predefined value (for example, current date) for the default value. Select a value. If you have based the column on a domain, you can retain the domain's default value (if any) or override it for the column.
        • Select Autoincrement or Global Autoincrement from the list.
        • If you select global autoincrement, the domain of values for that column is partitioned. Each partition contains the same number of values. For example, if you set the partition size for an integer column in a database to 1000, one partition extends from 1001 to 2000, the next from 2001 to 3000, and so on.
      Computed Value Define a computed value for the column. A computed column derives its values from calculations of values in other columns. Type an expression in the text box to describe the relationship between the other columns and the value that appears in the computed column.
    5. Click Next.
    6. On the Constraints page, specify:
      Field Description
      Values can be null (Default) Select this option if null values are allowed in the column. If the column is based on a domain, you can retain the domain's nullability or override it for the column.
      Values cannot be null Select this option to allow duplicate values, but not allow null values in this column.
      Values cannot be null and must be unique Select this option if values in the column cannot be null and must be unique.
    7. Click Next.
    8. (Optional) On the Comment page, add a descriptive comment for the column.
    9. Click Finish to create the column.
    10. Repeat these steps to add additional columns. When all columns are added, click Next.
  9. (Optional) On the Comment page, enter a descriptive comment about the global temporary table.
  10. Click Finish to create the column.
Related concepts
Table Columns
Table Permissions
Table Constraints
Table Indexes
Table Triggers
Table Partitions
Related tasks
Creating a Table with No Partitions in the IQ Main Store
Creating a Table with No Partitions in the IQ (Catalog) System Store
Creating a Table with a Hash Partition
Creating a Table with a Range Partition
Creating a Table with a Hash-Range Partition
Creating a Proxy Table
Viewing Table Data in the Execute SQL Window
Deleting a Table
Generating Table DDL Commands
Moving a Table to Another Dbspace
Validating a System Store Table
Setting the Primary Key
Setting a Clustered Index
Merging Table Data from RLV Store with IQ Main Store
Calculating the Number of Rows in a Table
Moving Table Objects to Another Dbspace
Enabling or Disabling Row-Level Versioning in a Table
Viewing or Modifying Base Table Properties
Viewing or Modifying Global Temporary Table Properties
Viewing and Modifying Proxy Table Properties
Authenticating a Login Account for a Managed Resource
Related reference
Table Privilege Summary