User-created temporary databases are typically created by the database administrator. These databases are usually created to minimize resource contention (such as system catalog and log contention) in the system tempdb. User-created temporary databases are very similar to the system tempdb in that they are:
Used primarily to create temporary objects
Re-created, rather than recovered, during a system-recovery process
All objects in a temporary database before a shut down or crash are lost during recovery because temporary databases are overwritten with the model database. Those restrictions that apply to the system tempdb also apply to the user-created temporary databases.
During login, sessions get assigned to a temporary database based on the existing bindings in effect:
If the binding is to a specific temporary database that is online and available, the session gets assigned to it.
If the binding is to the default group, a temporary database from that group is selected using a round-robin selection policy.
If no binding is specified, a temporary database is selected from the default group.
The temporary database chosen for a session remains in effect for the duration of that session and never gets changed, regardless of any changes to the bindings.
Once a session is assigned a temporary database, all temporary objects created during that session are created in that temporary database. These objects are implicitly dropped when the session or server shuts down. Shareable temporary tables are implicitly dropped when the server shuts down.
Temporary tables may be dropped explicitly by the session.
Adding a temporary database
In the list view in Sybase Central, select Databases | Temporary Databases | List View.
Select Add Temporary Database.
You see the Specify the Name window. Enter the name of the temporary database you want to create, and click Next.
The Device Information window appears. If you do not want to specify a device, select Next. To specify a device:
Select Add.
The Device Size screen appears. Select Data or Transaction Log to indicate what the device will store.
From the list of devices, select the device you want to use.
After you select the device, specify the size, in megabytes, of your temporary database.
Click OK.
The Device Size window disappears, and you return to the Device Information screen. You can add more devices by repeating this procedure. When you are finished, click Next.
The Database Type Information screen appears. Select:
With Override – forces Adaptive Server to accept your device specifications, even if they mix data and transaction logs on the same device, thereby endangering up-to-the-minute recoverability of your database.
For Load – creates a temporary database that can only be used for loading a database dump.
Select Next.
The Temporary Database Group screen appears. Select:
None – if you do not want to associate the tempdb with a group
Default – if you want to associate the tempdb with the default temporary database group. This is the only group that is available.
Select Next.
The Summary screen appears. Review the summary of your database configuration. Click Back to change any of the options; click Finish to return to the main Sybase Central window.
Your newly created temporary database appears.
For more information about multiple temporary databases, see:
Chapter 12, “tempdb Performance Issues” in Performance and Tuning: Optimizer and Abstract Plans
The create database command in Reference Manual: Commands
The sp_tempdb stored procedure in Reference Manual: Stored Procedures