Sybase Adaptive Server IQ 12.4.2 Administration And Performance Manual

Table of Contents

Advertisement

Quick Links

Administration and Performance Guide
Adaptive Server® IQ
12.4.2

Advertisement

Table of Contents
loading

Summary of Contents for Sybase Adaptive Server IQ 12.4.2

  • Page 1 Administration and Performance Guide Adaptive Server® IQ 12.4.2...
  • Page 2 Copyright © 1989-2000 by Sybase, Inc. All rights reserved. This publication pertains to Sybase database management software and to any subsequent release until otherwise indicated in new editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished under a license agreement, and it may be used or copied only in accordance with the terms of that agreement.
  • Page 3: Table Of Contents

    Contents About This Book ........................xvii CHAPTER 1 Overview of Adaptive Server IQ System Administration .... 1 Introduction to Adaptive Server IQ ........... 1 System administration tasks............. 2 Security overview ................3 Types of users ................4 Granting permissions ..............4 Tools for system administration............
  • Page 4 Who can stop the server? ............45 Shutting down operating system sessions ......45 Starting and stopping databases............ 46 Starting the asiqdemo database ............ 47 Starting and stopping Sybase Central..........48 Connecting a plug-in ............... 49 Stopping Sybase Central............50 Introduction to connections ............50 How connections are established..........
  • Page 5 Contents Steps in establishing a connection .......... 77 Locating the interface library ........... 78 Assembling a list of connection parameters......79 Locating a server..............81 Locating the database ............. 83 Server name caching for faster connections ......84 Interactive SQL connections ........... 85 Connecting from other databases ..........
  • Page 6 Multiple table joins and performance........156 Steps in creating a join index ..........157 Synchronizing join indexes............ 158 Defining join relationships between tables ......159 Issuing the CREATE JOIN INDEX statement ....... 162 Creating a join index in Sybase Central ........ 164...
  • Page 7 Contents Types of join hierarchies ............164 Modifying tables included in a join index ....... 167 Inserting or deleting from tables in a join index ..... 168 Table versioning controls access to join indexes ....169 Estimating the size of a join index..........169 CHAPTER 5 Moving Data In and Out of Databases........
  • Page 8 Contents Handling conversion errors on data import ......220 Tuning bulk loading of data ............221 Improving load performance during database definition ..221 Setting server startup options..........222 Adjusting your environment at load time ....... 222 Reducing Main IQ Store space use in incremental loads..223 Changing data using UPDATE.............
  • Page 9 Using IQ UNIQUE constraint on columns ......278 Using CHECK conditions on columns ........278 Column CHECK conditions from user-defined data types ..279 Working with column constraints in Sybase Central ..... 280 Using CHECK conditions on tables........280 Modifying and deleting CHECK conditions......280 Declaring entity and referential integrity........
  • Page 10 Contents Referential integrity is unenforced......... 284 Integrity rules in the system tables ..........285 CHAPTER 8 Transactions and Versioning ............. 287 Overview of transactions and versioning ........287 Introduction to transactions ........... 287 Introduction to concurrency ........... 290 Introduction to versioning ............291 Versioning prevents inconsistencies ..........
  • Page 11 Starting a database server using character set translation ... 348 Using ODBC code page translation ........348 Character set translation for Sybase Central and DBISQL ... 349 Creating a custom collation ........... 349 Creating a database with a custom collation ......351 Compatibility issues ..............
  • Page 12 Backup Examples..............388 Recovery from errors during backup ........389 After you complete a backup..........390 Performing backups with non-Sybase products ....390 Performing system-level backups ..........391 Shutting down the database..........391 Backing up the right files ............392 Restoring from a system-level backup ........
  • Page 13 Locating the backup log ............410 Content of the backup log ............. 411 Maintaining the backup log............ 412 Viewing the backup log in Sybase Central ......412 Recording dbspace names............ 412 Determining your data backup and recovery strategy....413 Scheduling routine backups ..........414 Designating Backup and Restore Responsibilities....
  • Page 14 Contents Working space for inserting, deleting, and synchronizing ..447 Options for tuning resource use ........... 448 Restricting concurrent queries..........448 Limiting a query’s memory use..........449 Limiting queries by rows returned ......... 449 Forcing cursors to be non-scrolling ........449 Limiting the number of cursors ..........
  • Page 15 Client/server interfaces to Adaptive Server IQ ......481 Configuring IQ Servers with DSEDIT ........483 Sybase applications and Adaptive Server IQ ......488 Open Client applications and Adaptive Server IQ ....488 Setting up Adaptive Server IQ as an Open Server ...... 489 System requirements ............
  • Page 17: About This Book

    About This Book This book, Adaptive Server IQ Administration and Performance Guide, presents administrative concepts and procedures and performance tuning recommendations for Sybase Adaptive Server IQ, a high-performance decision support server designed specifically for data warehouses and data marts. Audience...
  • Page 18: Related Documents

    Performance” Related documents Documentation for Adaptive Server IQ: • Introduction to Adaptive Server IQ Read and try the hands-on exercises if you are unfamiliar with Adaptive Server IQ, with the Sybase Central database management tool, or with Interactive SQL. xviii...
  • Page 19 About This Book • Adaptive Server IQ Reference Manual Read for a full description of the SQL language, utilities, stored procedures, data types, and system tables supported by Adaptive Server • Adaptive Server IQ Troubleshooting and Error Messages Guide Read to solve problems, perform system recovery and database repair, and understand error messages, which are referenced by by SQLCode, SQLState and message text.
  • Page 20 Related documents...
  • Page 21: Chapter 1 Overview Of Adaptive Server Iq System Administration

    Adaptive Server often used for mobile and occasionally connected computing. Sybase database Sybase database architecture provides a common code base for Adaptive architecture Server IQ and Adaptive Server Anywhere, with workload optimized data stores. You use the IQ Store for data warehousing. You can also use Adaptive Server Anywhere for transaction processing.
  • Page 22: System Administration Tasks

    Adaptive Server family, as well as non- Sybase databases and flat files. You can import this data into your IQ database, so that you can take advantage of IQ's rapid access capabilities. You can also query other databases directly, using Adaptive Server IQ's remote data access capabilities.
  • Page 23: Security Overview

    CHAPTER 1 Overview of Adaptive Server IQ System Administration Table 1-1: Administrative tasks If you want to know how to... Look in... Install and configure Adaptive Server Adaptive Server IQ Installation and IQ for your platform Configuration Guide Start and stop the database server, and Chapter 2, “Running Adaptive Server set up user connections IQ”...
  • Page 24: Types Of Users

    Tools for system administration Types of users Adaptive Server IQ recognizes three categories of users for each IQ database: • The database administrator, or DBA, has complete authority to perform all operations on that database. This guide is addressed primarily to the DBA, who typically carries out most administrative tasks.
  • Page 25: The Database Server

    SQL statements interactively and send them to a database. DBISQL has a window-like user interface on all platforms. The Introduction to Adaptive Server IQ explains how to use Sybase Central and DBISQL to perform simple administrative tasks. If you are not already familiar with these tools, you should read about them in the Introduction to Adaptive Server IQ and use the tutorials provided there.
  • Page 26: The Iq Store

    Catalogs and IQ • The Catalog Store When you create an IQ database, all three stores are created automatically. You create IQ databases using the procedures described in Chapter 3, “Working with Database Objects”. The IQ Store The IQ Store is the set of Adaptive Server IQ tables. You can have one or more permanent IQ Stores, each in a separate database.
  • Page 27: Concurrent Operations

    CHAPTER 1 Overview of Adaptive Server IQ System Administration Anywhere tables have a different format than IQ tables. While the commands you use to create objects in an Anywhere database are the same as those for an IQ Store, there are some differences in the features you can specify in those commands.
  • Page 28: Adaptive Server Iq Stored Procedures

    Stored procedures You can also create your own stored procedures. See Chapter 6, “Using Procedures and Batches” for details. Statements shown in examples generally use the database, a Note asiqdemo sample database installed as part of Adaptive Server IQ. For a diagram of this database’s structure, see Introduction to Adaptive Server IQ.
  • Page 29: Adaptive Server Enterprise System And Catalog Procedures

    CHAPTER 1 Overview of Adaptive Server IQ System Administration Table 1-2: Stored Procedures for the IQ Store Procedure name Purpose Checks the validity of the current sp_iqcheckdb database and repairs indexes Gives statistics on execution of sp_iqcommandstats various commands Gives the size of the current database sp_iqdbsize sp_iqdbstatistics Reports results of the most recent...
  • Page 30 Stored procedures System procedures are built-in stored procedures used for getting reports from and updating system tables. Catalog stored procedures retrieve information from the system tables in tabular form. While these procedures perform the same functions as they do in Note Adaptive Server Enterprise and pre-Version 12 Adaptive Server IQ, they are not identical.
  • Page 31: Catalog Stored Procedures

    CHAPTER 1 Overview of Adaptive Server IQ System Administration System procedure Description Displays the text of a system procedure or sp_helptext view Adds or changes a password for a user ID sp_password Adaptive Server Enterprise catalog procedures Adaptive Server IQ implements all the Adaptive Server Enterprise catalog procedures with the exception of the procedure.
  • Page 32: System Tables And Views

    System tables and views Procedure name Purpose Display information about a remote sp_servercaps server’s capabilities System tables and views Adaptive Server IQ system tables contain all of the information the database server needs to manage your IQ system. The system tables reside in the Catalog Store, and are sometimes called catalog tables.
  • Page 33 CHAPTER 1 Overview of Adaptive Server IQ System Administration System table Description SYSDOMAIN Lists the number, name, ODBC type, and precision of each predefined data type SYSFILE Lists operating system files and dbspace names for the database SYSFKCOL Associates each foreign key column with a primary key column SYSFOREIGNKEY Contains general information about...
  • Page 34 System tables and views System table Description SYSLOGIN Lists User Profile names that can connect to the database with an integrated login SYSOPTION Lists current SET OPTION settings for all users including the PUBLIC user SYSPROCEDURE Describes each procedure in the database SYSPROCPARM Describes each parameter to every...
  • Page 35 CHAPTER 1 Overview of Adaptive Server IQ System Administration System view Description SYSCATALOG Lists all tables and views from SYSTABLE SYSCOLAUTH Presents column update permission information from SYSCOLPERM SYSCOLUMNS Presents a readable version of the table SYSCOLUMN SYSFOREIGNKEYS Presents foreign key information from SYSFOREIGNKEY and SYSFKCOL SYSGROUPS Presents group information from...
  • Page 36: Commands And Functions

    Commands and Functions Commands and Functions All Adaptive Server IQ commands are SQL statements. SQL stands for Structured Query Language, a language commonly used in database applications. Adaptive Server IQ SQL uses the same syntax as Adaptive Server Anywhere SQL; the only differences are for certain product capabilities that are supported only for IQ or for Anywhere.
  • Page 37: Message Logging

    2000-03-07 17:20:50 0000 DB: Frmt#: 23F/2T/1P (FF: 03/18/1999) 2000-03-07 17:20:50 0000 DB: Versn: 12.4.2/(32bit mode)/MS Windows NT 4.0/EBF 0000/Mar 02 2000, 02:17:37 2000-03-07 17:20:50 0000 DB: Name: C:\Program Files\Sybase\ASIQ12\scripts\asiqdemo.db The fourth line of the file contains version information: Figure 1-1: Version string in message log...
  • Page 38: The Utility Database

    The utility database The date and time of the software build appears in the version string in ISO datetime format: where YYYY-MM-DD hh:mm:ss YYYY 4-digit year 2-digit month number (0-12) 2-digit day of month number (0-31) 2-digit numbmer of complete hours that have passed since midnight (00-23) 2-digit number of complete minutes that have passed since the start of the hour (00-59)
  • Page 39: Compatibility With Earlier Versions

    CHAPTER 1 Overview of Adaptive Server IQ System Administration For more information on the database, see Chapter 3, “Configuring utility Client/Server Communications” in your Adaptive Server IQ Installation and Configuration Guide. Compatibility with earlier versions Version 12 of Adaptive Server IQ differs markedly from earlier versions of IQ. It offers many important new features, including the ability to update the database concurrently with query use, Transact-SQL and Java support, additional query and view support, and better front end support.
  • Page 40 Compatibility with earlier versions...
  • Page 41: Chapter 2 Running Adaptive Server Iq

    Start the server from the Windows NT Start menu. See “Starting the server from the NT Start menu” on page 26. • Start the server with the Sybase-provided utility, , that runs start_asiq the server as a UNIX background process. See “Starting the server on...
  • Page 42: Server Command Lines

    Server command lines • Start the server and the sample database with a Sybase-provided configuration file. See “Starting the asiqdemo database” on page 47. • Place a server startup command in a shortcut or desktop icon. • Include a server startline in an ODBC data source. See “Creating and editing ODBC data sources”...
  • Page 43: Starting The Server On Unix

    CHAPTER 2 Running Adaptive Server IQ You can choose from many command-line options or switches to specify such features as permissions required to start a database or stop the server, and the network protocols to use. The command-line switches are one means of tuning Adaptive Server IQ behavior and performance.
  • Page 44: Using The Startup Utility

    Using the startup utility For most situations, the easiest way to start a database server on UNIX is by using the startup script that Sybase provides. Using this script ensures that all required parameters are set correctly, except in special situations described later in this chapter.
  • Page 45: Typing The Server Startup Command

    CHAPTER 2 Running Adaptive Server IQ For an explanation of commonly used startup parameters, see “Using command-line switches” on page 28. Typing the server startup command You can also start the database server by entering the following command at the UNIX prompt: asiqsrv12 [ server-switches ] [ database-file [ database-switches ]] This command starts the specified database:...
  • Page 46: Starting The Server On Windows Nt

    Click Start on the Task bar, and select Programs Sybase Adaptive Server IQ 12. From here, you can start the sample database, Sybase Central, Interactive SQL, and the ODBC Administrator. You can also place databases of your own in the Program group. Typing the server startup command...
  • Page 47: Running The Server Outside The Current Session

    CHAPTER 2 Running Adaptive Server IQ See “Using command-line switches” on page 28 for a description of commonly used startup parameters. To start the server without starting any database, you omit the database Note file from the command and specify a servername. See “Naming the asiqsrv12 server and databases”...
  • Page 48: Using Command-Line Switches

    Using command-line switches Running the UNIX database server as a daemon To run the UNIX database server in the background, and enable it to run independently of the current session, you run it as a daemon. Do not use ’&’ to run the database server in the background. It will not Note work.
  • Page 49 CHAPTER 2 Running Adaptive Server IQ For this switch See this section “Setting a maximum Catalog page size” “Recovery time” “Controlling permissions from the command line” -iqgovern “Concurrent queries” “Buffer caches and physical memory” -iqmc -iqtc “Buffer caches and physical memory” -iqsmem “Unwired memory”...
  • Page 50 Using command-line switches For example, the following configuration file starts the database , on mydb.db the database server named Elora, with a Catalog cache size of 16MB, TCP/IP as a network protocol and a specified port number, user connections limited to 10, and a Catalog page size of 4096 bytes.
  • Page 51: Naming The Server And Databases

    CHAPTER 2 Running Adaptive Server IQ Configuration file for The asiqdemo.cfg file, which you use to start the sample database, sets startup the sample database parameters to the recommended defaults. You can also use this file as a template for your own configuration files. Chapter 3, “Running and Connecting to Servers”, Introduction to Adaptive Server IQ gives an example of the sample database configuration file.
  • Page 52 Using command-line switches asiqsrv12 mydb.db sample.db Naming databases You can name databases by supplying a switch following the database file. For example, the following command line starts a database and names it: asiqsrv12 mydb.db -n MyDB Naming a database lets you use a nickname in place of a file name that may be difficult to remember.
  • Page 53: Controlling Performance From The Command Line

    CHAPTER 2 Running Adaptive Server IQ You should adopt a set of naming conventions for your servers and databases, as well as for all other database objects, that includes a case specification. Enforcing naming conventions can prevent problems for users. Controlling performance from the command line Several command-line options can affect database server performance.
  • Page 54 Using command-line switches To override these settings for the current server session, specify the server startup options (main cache size) and (temp cache size) to open the -iqmc -iqtc database and reset the defaults. The default sizes are 8MB for the main cache and 4MB for the temporary cache, which are too low for any active database use.
  • Page 55 CHAPTER 2 Running Adaptive Server IQ Unwired memory switch creates a memory pool to increase total available memory. -iqsmem This switch is available on all UNIX platforms, but is required in some cases: • On HP systems use if you want to use more than 2GB of memory. -iqsmem The value should be between 500 and 1400MB.
  • Page 56: Controlling Permissions From The Command Line

    —Any user can start and stop databases. • —No one can start or stop a database on a running server. NONE Sybase recommends that only the DBA be allowed to start and stop production databases. Note If you do not set...
  • Page 57: Setting A Maximum Catalog Page Size

    CHAPTER 2 Running Adaptive Server IQ • —Only those users who can connect to the database UTILITY_DB utility_db can create and drop databases. See “The utility database” on page 18 for information. Stopping the server option limits the users who can shut down a server to those with a certain level of permission in the database.
  • Page 58: Setting Up A Client/Server Environment

    Using command-line switches Setting up a client/server environment Three switches can help you set up your client/server environment. • specifies communication protocol options. • sets the network connection timeout. • sets the client connection timeout. See the sections that follow for details. Selecting communications protocols Any communications between a client application and a database server require a communications protocol.
  • Page 59 CHAPTER 2 Running Adaptive Server IQ Additional parameters can be added to tune the behavior of the server for each protocol. For example, the following command line instructs the server to use two network cards, one with a specified port number. This command must be entered all on one line, even though it appears on multiple lines here.
  • Page 60: Starting A Server In Forced Recovery Mode

    Using command-line switches Setting the default Adaptive Server IQ disconnects client connections that have not submitted a client timeout request for the number of minutes you specify with the switch. By disconnecting inactive connections, this option frees any locks those connections hold.
  • Page 61: Starting Multiple Servers Or Clients On The Same Machine

    CHAPTER 2 Running Adaptive Server IQ Starting multiple servers or clients on the same machine In a production environment, it would be unusual to have more than one server running on the same system. In a development environment, however, this situation can occur.
  • Page 62 Monitoring server activity demo.001.srvlog demo.002.srvlog janedemo.001.srvlog For information about your most recent session, choose the log with the largest number for the desired server. Issue a command to view the log contents. tail –f For example: % tail -f demo.002.srvlog When you run , specify the option to enhance the log file with...
  • Page 63: Stopping The Database Server

    CHAPTER 2 Running Adaptive Server IQ Stopping the database server The preferred ways to stop the database server are: • In UNIX, use the utility. For details, see “Example — Stop a stop_asiq server with stop_asiq”. Note that when is used, the following message appears: stop_asiq "Please note that ’stop_asiq’...
  • Page 64 Stopping the database server Example — Stop a The following example uses the utility on UNIX systems to shut stop_asiq server with stop_asiq down an Adaptive Server IQ server and close all user connections to it. When you issue the command, Adaptive Server IQ lists all the stop_asiq servers owned by other users, followed by the server(s) you own.
  • Page 65: Who Can Stop The Server

    . In a NONE STOP ENGINE production environment, Sybase strongly recommends that only the DBA be allowed to stop the database server. Interactively, of course, anyone at the machine where the server was started can click Shutdown (NT only) or type on the server window.
  • Page 66: Starting And Stopping Databases

    For a description, see the chapter “SQL DATABASE Statements” in the Adaptive Server IQ Reference Manual. • To start and connect to a database from DBISQL or Sybase Central, use a data source that specifies the database file. See “Working with ODBC data sources”. •...
  • Page 67: Starting The Asiqdemo Database

    CHAPTER 2 Running Adaptive Server IQ Permission limitations server command-line option determines the permission level required to start databases. By default, this option is set to , so that only users with database administrator privileges can start IQ databases. However, you can also set this option to means that all users can start a NONE...
  • Page 68: Starting And Stopping Sybase Central

    Starting and stopping Sybase Central If your system supports a graphical user interface, you will use Sybase Central to perform many administrative tasks. This guide gives summary instructions for using Sybase Central. For more information, see the Introduction to Adaptive Server IQ, or use the online help available within Sybase Central.
  • Page 69: Connecting A Plug-In

    The right panel displays the contents of the container that has been selected in the left panel. Connecting a plug-in If you do not see the plug-in for Adaptive Server IQ in the main Sybase Central window, you can connect to it manually. Connecting to a plug-in Select Tools Adaptive Server IQ 12.
  • Page 70: Stopping Sybase Central

    If Adaptive Server IQ (ASIQ) is listed, select Register. If not, select Load. Use the Browse button to find and select the file ASIQPlugin.jar. Click Stopping Sybase Central To stop Sybase Central, select File Exit. Introduction to connections The remainder of this chapter describes how client applications connect to databases.
  • Page 71: How Connections Are Established

    Embedded SQL — Embedded SQL connections are discussed in this chapter. • Sybase Open Client — Open Client connections are not discussed in this chapter. For information on connecting to IQ from Open Client applications, see Chapter 14, “Adaptive Server IQ as a Data Server”...
  • Page 72: Connection Parameters Specify Connections

    Introduction to connections If you want ... Consider reading ... A conceptual overview “Connection parameters specify connections” To create data sources “Working with ODBC data sources” To see an in-depth description of how “Working with ODBC data sources” connections are established To add users and grant them permissions “How Adaptive Server IQ makes connections”...
  • Page 73: Connection Parameters Are Passed As Connection Strings

    CHAPTER 2 Running Adaptive Server IQ You must enter a connection string on a single line, with the parameter settings separated by semicolons. Connection parameters are passed as connection strings Connection parameters are passed to the interface library as a connection string.
  • Page 74: Connecting To A Database From Dbisql

    Simple connection examples For steps in connecting to a database using Sybase Central, see the Introduction to Adaptive Server IQ. For more detailed information on available connection parameters and their use, see “Connection parameters” on page 73. Connecting to a database from DBISQL Many examples and exercises throughout the documentation start by connecting to the sample database from Interactive SQL, also called DBISQL.
  • Page 75 If you prefer, use this alternate form of the links clause, which has the same result: links=tcpip(host=SERV2:1234)" To connect from a Windows NT system Select Start Sybase Adaptive Server IQ 12 Interactive SQL, or at the NT command prompt enter dbisql...
  • Page 76: Connecting To Other Databases From Dbisql

    Simple connection examples You can include the parameter to specify connection parameters in the command, as described in the procedure above for connecting to dbisql UNIX. If you omit these parameters, the DBISQL logon window appears. Enter the user ID and the password This is the default user ID and password for Adaptive Server IQ databases when they are created.
  • Page 77: Connecting To An Embedded Database

    CHAPTER 2 Running Adaptive Server IQ To connect to a database from DBISQL on UNIX: Start the server and the database by typing at a system command prompt: start_asiq dbname Start DBISQL by typing at a system command prompt: dbisql -c "uid=userID;pwd=password;eng= dbname ;links=tcpip"...
  • Page 78 To connect to an embedded database from DBSQL in Windows NT: Start DBISQL with no databases running. You can use either of the following ways: • From the Windows NT Start menu, choose Sybase Adaptive Server Anywhere Interactive SQL. •...
  • Page 79: Connecting Using A Data Source

    Start DBISQL with no databases running. • On UNIX, type at a system command prompt. dbisql • On Windows NT, from the Start menu choose Programs Sybase Adaptive Server IQ 12.0 Interactive SQL. Enter as the user ID and as the password.
  • Page 80: Connecting To A Server On A Network

    Simple connection examples Connecting to a server on a network To connect to a database running on a network server somewhere on a local or wide area network, the client software must be able to locate the database server. Adaptive Server IQ provides a network library (a DLL or shared library) that handles this task.
  • Page 81: Using Default Connection Parameters

    CHAPTER 2 Running Adaptive Server IQ The network library searches for a server by broadcasting over the network, which can be a time-consuming process. Once the network library locates a server, the client library stores its name and network address in a file. Users should never need to use this file directly.
  • Page 82: Connecting From Adaptive Server Iq Utilities

    Simple connection examples pwd= password Note Do not use these parameters if more than one local server is running, or you may connect to the wrong server. Default database If more than one server is running, you need to specify which one you wish to connect to.
  • Page 83: Working With Odbc Data Sources

    CHAPTER 2 Running Adaptive Server IQ Using the SQLCONNECT environment variable settings if any command line values are missing. Adaptive Server IQ database utilities do not set this variable automatically. For a description of the SQLCONNECT environment variable, see Chapter 1, “Environment Variables and Registry Entries,”...
  • Page 84: Dsns And Filedsns

    Working with ODBC data sources DSNs and FILEDSNs You specify a data source either as a DSN (data source name) or as a FileDSN (file data source name). You can reference a data source in the Windows NT registry using the DSN connection parameter: DSN= my data source You can reference a data source held in a file using the FileDSN connection...
  • Page 85: Creating And Editing Odbc Data Sources

    DSNs you can edit the .odbc.ini file directly. For File DSNs, create a file with the name you choose, using the file extension .dsn. Sybase recommends that, to avoid ambiguity, you be as specific as Note possible in creating ODBC and other data sources, whether you create them using the ODBC Administrator, or by editing odbc.ini, .odbc.ini, or .dsn files...
  • Page 86 To create an ODBC User Data Source: Select Settings Control Panel ODBC or Select Programs Sybase Adaptive Server IQ ODBC Administrator In the ODBC Data Source Administrator, click Add on the User DSN tab. Select the Adaptive Server IQ 12 from the list of drivers and click Finish.
  • Page 87: Configuring Odbc Data Sources

    CHAPTER 2 Running Adaptive Server IQ Click Configure. On the ODBC Configuration dialog box, click Test Connection. If you cannot access the Data Source, check that you have filled out the various tabs with correct file and pathnames. To edit a data source, select one from the list in the ODBC administrator window and click Configure.
  • Page 88 Creating and editing ODBC data sources Check this box if you Microsoft applications (keys in SQL Statistics) wish foreign keys to be returned by SQL statistics. The ODBC specifications states that primary and foreign keys should not be returned by SQL statistics, however, some Microsoft applications (such as Visual Basic and Access) assume that primary and foreign keys are returned by SQL statistics.
  • Page 89: Login Tab

    Start line Enter the server that should be started. Only provide a Start Line parameter if a database server is being connected to that is not currently running. For example: C:\Program Files\Sybase\ASIQ12\win32\asiqsrv12.exe -gm 10 -gp 4096 -c 8M dbf=path\asiqdemo.db uid=DBA pwd=SQL...
  • Page 90 Creating and editing ODBC data sources For more information on the parameters in the Database tab, see the EngineName, StartLine, DatabaseName, DatabaseFile, and AutoStop connection parameters in the chapter “Connection and Communication Parameters” in the Adaptive Server IQ Reference Manual. Network tab Select the network protocol and specify any protocol specific options The TCP/IP, IPX, and NetBIOS check boxes specifies...
  • Page 91: Creating A File Data Source

    CHAPTER 2 Running Adaptive Server IQ The name of the file in Display debugging information in a log file which the debugging information is to be saved. Enter any additional switches here. Additional connection parameters Parameters set throughout the remainder of this dialog take precedence over parameters typed here.
  • Page 92: Using Odbc Data Sources On Unix

    For example, on a Sun Solaris system, if you are using an ODBC application that uses libodbc.so (libodbc.so.1) or libodbcinst.so (libodbcinst.so.1), simply create symbolic links for these that point to $SYBASE/asiq12/lib/dbodbc6.so.1. If you are creating a custom ODBC application, you can link directly to dbodbc6.so.
  • Page 93: Connection Parameters

    CHAPTER 2 Running Adaptive Server IQ Connection parameters Adaptive Server IQ connection parameters are listed in the following table. For a full description of each of these connection parameters, see Chapter 3, “Connection and Communication Parameters” in the Adaptive Server IQ Reference Manual.
  • Page 94 Connection parameters Short Parameter form Argument Description String Provide database- DatabaseSwitches specific switches when starting a database. String Tell the ODBC driver DataSourceName ** manager where to look in odbc.ini to find ODBC data source information. Boolean Provide diagnostic Debug information on communications links on startup.
  • Page 95 CHAPTER 2 Running Adaptive Server IQ Short Parameter form Argument Description String Send client error Logfile messages and debugging messages to a file. String Provide a password for Password ** the connection String Specify server to ServerName connect to StartLine Start String Start a database server...
  • Page 96: Connection Parameter Priorities

    Connection parameters • The entries in a connection string are read left to right. If the same parameter is specified more than once, the last one in the string applies. • If a string contains a DSN or FILEDSN entry, the profile is read from the configuration file, and the entries from the file are used if they are not already set.
  • Page 97: How Adaptive Server Iq Makes Connections

    Any ODBC application using the function, which is the SQLDriverConnect common method of connection for ODBC applications. Many application development systems, such as Sybase PowerBuilder and Power++, belong to this class of application. • Any client application using Embedded SQL and using the recommended...
  • Page 98: Locating The Interface Library

    How Adaptive Server IQ makes connections Locate a server. Using the connection parameters, the ODBC driver or Embedded SQL interface library must locate a database server on your machine or over a network. Locate the database. Once it locates the server, the ODBC driver or Embedded SQL interface library must locate the database you are connecting to.
  • Page 99: Assembling A List Of Connection Parameters

    CHAPTER 2 Running Adaptive Server IQ Assembling a list of connection parameters The following figure illustrates how the interface libraries assemble the list of connection parameters they will use to establish a connection. Notes Key points from the figure are as follows: •...
  • Page 100 How Adaptive Server IQ makes connections • Ignored if another connection has already set this CommBufferSpace parameter. • Unconditional Ignored if the database is already loaded or if the server is already running. The interface library uses the completed list of connection parameters to attempt to connect.
  • Page 101: Locating A Server

    CHAPTER 2 Running Adaptive Server IQ Locating a server The next step in establishing a connection is to attempt to locate a server. If the connection parameter list includes a server name (ENG parameter), the interface library carries out a search first for a database server of that name, followed by a search over a network.
  • Page 102 How Adaptive Server IQ makes connections • The network search involves a search over one or more of the protocols that Adaptive Server IQ supports. For each protocol, the network library starts a single port. All connections over that protocol at any one time use a single port.
  • Page 103: Locating The Database

    CHAPTER 2 Running Adaptive Server IQ Locating the database If the interfaces library successfully locate a server, it then tries to locate the database. For example: Notes • If you rely on the DBF parameter, the DBF path must either be an absolute path, or relative to where the server was started, in order for Adaptive Server IQ to find the database it specifies.
  • Page 104: Server Name Caching For Faster Connections

    How Adaptive Server IQ makes connections Server name caching for faster connections The network library looks for a database server on a network by broadcasting over the network using the connection parameter. CommLinks Tuning the broadcast parameter takes as argument a string that lists the protocols to CommLinks use and, optionally for each protocol, a variety of network communication parameters that tune the broadcast.
  • Page 105: Interactive Sql Connections

    CHAPTER 2 Running Adaptive Server IQ Interactive SQL connections The Interactive SQL (DBISQL) utility has a different behavior from the default Embedded SQL behavior when a CONNECT statement is issued while already connected to a database. If no database or server is specified in the CONNECT statement, Interactive SQL connects to the current database, rather than to the default database.
  • Page 106: Using An Integrated Login

    Using an integrated login Using an integrated login The integrated login feature allows you to maintain a single user ID and password for both database connections and operating system and/or network logins. This section describes the integrated login feature. Operating systems Integrated login capabilities are available for the Windows NT server only.
  • Page 107: Using Integrated Logins

    CHAPTER 2 Running Adaptive Server IQ Using integrated logins Several steps must be implemented in order to connect successfully via an integrated login. To use an integrated login: Enable the integrated login feature in a database by setting the value of the LOGIN_MODE database option to either (the option Mixed...
  • Page 108 Only users with DBA authority are able to create or remove an integrated login mapping. An integrated login mapping is made either using a wizard in Sybase Central or a SQL statement. To map an integrated login from Sybase Central: Connect to a database as a user with DBA authority.
  • Page 109 CHAPTER 2 Running Adaptive Server IQ Connecting from a client application A client application can connect to a database using an integrated login in one of the following ways: • Set the INTEGRATED parameter in the list of connection parameters to •...
  • Page 110: Security Concerns: Unrestricted Database Access

    Using an integrated login Setting the attribute ’Integrated=yes’ in an ODBC data source causes database connection attempts using that DSN to attempt an integrated login. If the LOGIN_MODE database option is set to , the ODBC driver prompts Standard the user for a database user ID and password. Security concerns: unrestricted database access The integrated login features works by using the login control system of Windows NT in place of the system Adaptive Server IQ uses to control access...
  • Page 111: Setting Temporary Public Options For Added Security

    CHAPTER 2 Running Adaptive Server IQ • An integrated login mapping exists between the user and the dsmith database user ID . When the user connects to the server with dsmith her correct login ID and password, she connects to the database as user with full administrative rights.
  • Page 112: Network Aspects Of Integrated Logins

    Using an integrated login For more information on using the statement see Chapter 9, “SQL SET OPTION Statements” in Adaptive Server IQ Reference Manual. Network aspects of integrated logins If the database is located on a network server, then one of two conditions must be met for integrated logins to be used: •...
  • Page 113: Troubleshooting Startup, Shutdown, And Connections

    CHAPTER 2 Running Adaptive Server IQ Troubleshooting startup, shutdown, and connections See the sections that follow for help in resolving problems with your database server, connections, and DBISQL. For other troubleshooting hints, see the Adaptive Server IQ Troubleshooting and Error Messages Guide. What to do if you can’t start Adaptive Server IQ This section describes some common problems when starting the database server.
  • Page 114 Troubleshooting startup, shutdown, and connections Ensure that network communication software is running Appropriate network communication software must be installed and running before you run the database server. If you are running reliable network software with just one network installed, this should be straightforward. If you experience problems, if you are running non-standard software, or if you are running multiple networks, read the discussion of network communication issues in the Adaptive Server IQ Installation and Configuration Guide.
  • Page 115: What To Do If You Can't Connect To A Database

    CHAPTER 2 Running Adaptive Server IQ What to do if you can’t connect to a database If you are unable to connect to an Adaptive Server IQ database, check the items described below. • Check that you have entered your data source name correctly, or that you have selected the correct server name for a JDBC connection.
  • Page 116: Stopping A Database Server In An Emergency (Unix)

    Troubleshooting startup, shutdown, and connections • Check that all of the files exist for the database you have requested. At a minimum, there must be an IQ Store (dbname.iq), a Catalog Store (dbname.db), an IQ Temporary Store (dbname.iqtmp), a transaction log (dbname.log This may be missing if the database is newly created and has not been modified.), and a message file (dbname.iqmsg).
  • Page 117 CHAPTER 2 Running Adaptive Server IQ For help in improving the appearance of DBISQL windows, or if you are unable to use function keys in DBISQL, see the Chapter 6, “Getting Started with DBISQL” in Introduction to Adaptive Server IQ.
  • Page 118 Troubleshooting startup, shutdown, and connections...
  • Page 119: Chapter 3 Working With Database Objects

    Working with Database Objects C H A P T E R About this chapter This chapter describes the mechanics of creating, altering, and deleting database objects such as tables, views, and indexes. The SQL statements for carrying out these tasks are called the Data Definition Language (DDL).
  • Page 120: Tools For Working With Database Objects

    Tools for working with database objects Adaptive Server IQ includes two utilities for working with database objects: Sybase Central and DBISQL. In addition, Warehouse Architect can be used for designing and creating whole data warehouses. Using Sybase Central to work with database objects Sybase Central is the primary tool for working with database objects on windowing systems.
  • Page 121: A Step-By-Step Overview Of Database Setup

    This chapter is concerned with the SQL statements for working with database objects. If you are using Sybase Central, these SQL statements are generated for you. The primary source of information about Sybase Central is the Sybase Central online Help. This chapter gives only brief pointers for tasks that you can carry out using Sybase Central.
  • Page 122 To create a join index, use the statement, or the CREATE JOIN INDEX Sybase Central Add JoinIndex Wizard. See Chapter 4, “Adaptive Server IQ Indexes.” Scheduling data definition tasks Once the database exists and other users have access to it, follow these guidelines when you need to perform additional data definition operations, such as adding or modifying tables or indexes.
  • Page 123: Extending Data Definition Privileges

    CHAPTER 3 Working with Database Objects You will probably want to schedule data definition operations for times when database usage is low. All other users are blocked from reading or writing to a table while you are creating or altering that table, although for a brief time only. If the table is part of a join index, users cannot read or write to any of the tables in the join index until the data definition operation is complete.
  • Page 124: Selecting A Device Type

    Building Your Adaptive Server IQ Databases The DBA and object owners can grant authority to individual users and to groups of users. For complete information, see Chapter 10, “Managing User IDs and Permissions” You can also use the command-line option to set the permission level required to create or delete a database.
  • Page 125 CHAPTER 3 Working with Database Objects Space requirements The amount of data, and the number and types of indexes you create, determine for IQ Stores how much space you need in your IQ database. If you run out of space when loading or inserting into a database, Adaptive Server IQ prompts you to create another dbspace, and then continues the operation after you add the dbspace.
  • Page 126: Working With Databases

    SQL statements to add features to the database if they are not supported by the design tool. For more advanced use, database design tools such as Sybase Warehouse Architect provide a more thorough and reliable approach to developing well-...
  • Page 127: Creating A Database

    • Start the database server • Start either Sybase Central or DBISQL To create a database in DBISQL, you need to connect to an existing database, or else start the utility database, a phantom database with no database files and no data.
  • Page 128 Adaptive Server IQ 12.0; likewise, old servers cannot manage new databases. Using Sybase Central To create an IQ database in Sybase Central, click the Utilities folder in the left to create an IQ panel, then double-click Create Database in the right panel to start the Create database Database Wizard.
  • Page 129 You can create a database using a relative or fully qualified pathname for each pathnames of the files for the database. Sybase recommends that you create databases with relative pathnames. If your database is on UNIX, you can define a symbolic link for each pathname,...
  • Page 130 Working with databases If you omit the directory path, Adaptive Server IQ locates the files as follows: • The Catalog Store is created relative to the working directory of the server. • The IQ Store is created relative to the working directory of the server. •...
  • Page 131 2, IQ PAGE SIZE from 65536 to 524288 bytes. The IQ page size is the same for all dbspaces in the IQ Store. To obtain the best performance, Sybase recommends the following minimum IQ page sizes: • 64 KB (...
  • Page 132 Working with databases Adaptive Server IQ stores data on disk in compressed form. It uncompresses the data and moves data pages into memory for processing. The IQ page size determines the amount of disk compression and the default I/O transfer block size for the IQ Store.
  • Page 133 CHAPTER 3 Working with Database Objects Choosing a block size for your database Example The following statement creates a large database on a UNIX raw partition with a Catalog of 4KB, and an of 128KB. By default, the PAGE SIZE IQ PAGE SIZE IQ Store size is 8MB and the Temporary Store is 4MB.
  • Page 134: Adding Dbspaces

    In the large databases typical of a data warehouse, you will need to add dbspaces to any database. You create a new database file—a dbspace—using statement, or the Sybase Central Add Dbspace Wizard. CREATE DBSPACE A new dbspace can be on the same or a different disk drive as the existing dbspaces.
  • Page 135 CREATE DBSPACE library AS ’library.iq’ Creating a dbspace in Sybase Central To create a dbspace in Sybase Central: Connect to the database. Click the Dbspaces folder for that database. Double-click Add Dbspace in the right panel. Enter the dbspace name.
  • Page 136: Dropping Dbspaces

    You also cannot empty a dbspace by truncating the tables in it, as even an empty table takes some space. The only way to completely remove a table and its data is with a statement (or by dropping the table in Sybase DROP TABLE Central).
  • Page 137 CHAPTER 3 Working with Database Objects Name Value ======================================================= Adaptive Server IQ (TM) Copyright (c) 1992-2000 by Sybase, Inc. All rights reserved. Version: 12.4.2/(32bit mode)/Sun_svr4/OS 5.6/EBF 0000 Time Now: 2000-03-14 12:05:54.288 Build Time: Sat Mar 11, 2000 21:39:55 EST File Format:...
  • Page 138: Dropping A Database

    Creating tables Creating tables in Sybase Central provides a tool called the table editor. In the table editor, you Sybase Central can create a table definition by filling out a spreadsheet-like form.
  • Page 139 CHAPTER 3 Working with Database Objects Click the Tables folder for that database. Double-click Add Table in the right panel. Enter a Name for the table. To create an IQ table, skip this step. To create a table in the Catalog Store, double-click the Advanced Table Properties icon, and select SYSTEM from the DB space dropdown list.
  • Page 140 You create a global temporary table, using the option GLOBAL TEMPORARY , or by specifying in the Sybase Central table editor that this CREATE TABLE is a temporary table. When you create a global temporary table, it exists in the database until it is explicitly removed by a statement.
  • Page 141 Drop Join Index. You cannot create, modify, or delete Join Virtual Tables, but you may see error messages related to them if you try to use or modify them. Sybase suggests that you ignore all Join Virtual Tables.
  • Page 142 Working with tables If you use the command to add a column to an existing ALTER TABLE UNIQUE table, or to designate an existing column as , an index is created UNIQUE automatically. For complete information on IQ indexing, see Chapter 4, “Adaptive Server IQ Indexes”...
  • Page 143: Altering Tables

    CHAPTER 3 Working with Database Objects By contrast, when you specify , each value can occur UNIQUE PRIMARY KEY only once in that column. For example, in the table, each value of employee , the employee’s social security number, can occur just once ss_number throughout that column.
  • Page 144: Dropping Tables

    The property sheets for tables and columns display all the table or column Sybase Central attributes. You can alter a table definition in Sybase Central by displaying the property sheet for the table or column you wish to change, altering the property, and clicking OK to commit the change.
  • Page 145: Creating Primary And Foreign Keys

    Creating a primary key in Sybase Central To create a primary key in Sybase Central: Connect to the database. Click the Tables folder for that database. Right-click the table you wish to modify, and select Properties from the pop-up menu to display its property sheet.
  • Page 146 Working with tables For more information, see the Sybase Central online Help. Note Multi-column primary keys are not enforced, and require the keyword . Primary key column order is based on the order of the columns UNENFORCED during table creation. It is not based on the order of the columns as specified in the primary key declaration.
  • Page 147: Table Information In The System Tables

    For more information, see “System Tables” in Adaptive Server IQ Reference Manual. You can use Sybase Central or DBISQL to browse the information in these tables. Type the following command in the DBISQL command window to see all the columns in the SYS.SYSTABLE table:...
  • Page 148: Creating Views

    Working with views Similarities between Views are similar to the permanent tables of the database (a permanent table is views and base tables also called a base table) in many ways: • You can assign access permissions to views just as to base tables. •...
  • Page 149: Using Views

    From the File menu select Execute Script and from the File menu select Close. For more information, see the Sybase Central online Help. Using views When you use views, you need to be aware of certain restrictions, both on the...
  • Page 150: Modifying Views

    Working with views CREATE VIEW viewname AS Inserting and deleting , and statements are allowed on some views, but not UPDATE INSERT DELETE on views on others, depending on their associated statement. SELECT You cannot update, insert into or delete from views in the following cases: •...
  • Page 151: Deleting Views

    DepartmentSize view: DROP VIEW DepartmentSize Dropping a view in To drop a view in Sybase Central, right-click the view you wish to delete and Sybase Central select Delete from the pop-up menu. For more information, see the Sybase Central online Help.
  • Page 152: Working With Indexes

    Working with indexes You can use DBISQL to browse the information in these tables. Type the following statement in the DBISQL command window to see all the columns in the SYS.SYSVIEWS view: SELECT * FROM SYS.SYSVIEWS To extract a text file containing the definition of a specific view, use a statement such as the following: SELECT viewtext FROM SYS.SYSVIEWS WHERE viewname = ’DepartmentSize’;...
  • Page 153: Creating Indexes

    Creating indexes You can create column indexes in three ways: • With the command CREATE INDEX • With the Add Index option in Sybase Central • With the column constraint of UNIQUE PRIMARY KEY CREATE TABLE which creates a unique index automatically.
  • Page 154: Removing Indexes

    If a column index or join index is no longer required, you can remove it from the database using the statement. You can also drop indexes in Sybase DROP Central by clicking the table name, right-clicking to display options, and clicking the Delete option.
  • Page 155: Adaptive Server Iq Indexes

    Adaptive Server IQ Indexes C H A P T E R About this chapter This chapter describes the Adaptive Server IQ index types. It explains how you create an index, and provides information to help you decide what index types are best suited for the way you use the data in your database.
  • Page 156 Overview of indexes The default column storage structure that Adaptive Server IQ creates for each column is actually an index optimized for storing and projecting data. Depending on the size of your database, the disk space available to you, and the type of queries your users submit, you will almost certainly want to supplement this default index with one or more of the Adaptive Server IQ bitwise index types.
  • Page 157: Benefits Over Traditional Indexes

    . The only way to remove the default index is to use DROP INDEX (or the Sybase Central Table Editor) to drop the column, or to ALTER TABLE drop the table. The only way to remove an automatically created...
  • Page 158: Creating Adaptive Server Iq Indexes

    Creating Adaptive Server IQ indexes You can create a column index explicitly using either the CREATE INDEX statement or Sybase Central. These two methods are discussed in the sections that follow. The CREATE INDEX statement To create an Adaptive Server IQ column index, use this syntax: CREATE [ UNIQUE ] [ index-type ] INDEX index-name ...
  • Page 159: Creating An Index With Sybase Central

    CREATE INDEX with Adaptive Server Anywhere. Creating an index with Sybase Central To create a column index using Sybase Central, follow these steps. To create an index with Sybase Central: Connect to the database. Select the table in which the column appears.
  • Page 160: Choosing An Index Type

    Choosing an index type • Each statement can create only one index. CREATE INDEX • Each connection can create only one index at a time. • If two connections issue statements on the same table, the CREATE INDEX first statement works; the other gets an error saying that only 1 writer is allowed.
  • Page 161: Number Of Unique Values In The Index

    CHAPTER 4 Adaptive Server IQ Indexes Number of unique values in the index Adaptive Server IQ indexes are optimized according to the number of unique (distinct) values they include. When this number reaches certain levels, choose indexes according to the recommendations in Table 4-1. Table 4-1: Consideration order Number of Unique Values Recommended Index Type...
  • Page 162 Choosing an index type Often, the type of data in a column gives a good indication how the column will be used. For example, a date column will probably be used for range searches clauses, and a column that contains prices or sales amounts will WHERE probably be used in the projection as an argument for aggregate functions , and so on).
  • Page 163: Indexing Criteria: Disk Space Usage

    CHAPTER 4 Adaptive Server IQ Indexes These estimates are generally valid; however, other factors can take precedence: • For range predicates, the number of unique values is a more important factor. • With the set functions , and COUNT COUNT DISTINCT , in order to use any index other than the default, the entire query must be resolvable using a single table or join index.
  • Page 164: Combining Index Types

    Adaptive Server IQ index types • data with more than 255 bytes VARCHAR indexes do not allow , or data. FLOAT REAL DOUBLE All other data types are supported in all index types. If you try to create an index on a column that contains data greater VARCHAR than 255 bytes, you get this error message:...
  • Page 165: Default Column Index

    CHAPTER 4 Adaptive Server IQ Indexes Default column index For any column that has no index defined, or whenever it is the most effective, query results are produced using the default index. This structure is fastest for projections, but generally is slower than any of the three column index types you define for anything other than a projection.
  • Page 166: The High_Group (Hg) Index Type

    Adaptive Server IQ index types Advantages and disadvantages of Low_Fast The following table lists advantages and disadvantages of Low_Fast indexes. Table 4-5: LF advantages/disadvantages Advantages Disadvantages This index is fast, especially for single Can only be used for a maximum of table 10,000 unique values.
  • Page 167 CHAPTER 4 Adaptive Server IQ Indexes Advantages and disadvantages of High_Group The following table lists advantages and disadvantages of High_Group indexes. Table 4-6: HG advantages/disadvantages Advantages Disadvantages Quickly processes queries with This index needs additional disk space compared to the index (it can take up GROUP BY as much as three times more space than raw...
  • Page 168: The High_Non_Group (Hng) Index Type

    Adaptive Server IQ index types However, because multi-column primary keys are always unenforced, the automatically created High_Group index for a multi-column primary key is a phantom index: it includes all of the key columns, but does not contain any data. This structure is used for query optimization, but not for resolving queries.
  • Page 169: Optimizing Performance For Ad Hoc Joins

    CHAPTER 4 Adaptive Server IQ Indexes Table 4-7: HNG advantages/disadvantages Advantages Disadvantages Due to compression algorithms used, This index is not recommended for GROUP disk space requirements can be queries. reduced without sacrificing performance. If the column has a high number of Index not possible if uniqueness enforced.
  • Page 170: Selecting An Index

    Adaptive Server IQ index types AND l_suppkey = s_suppkey AND c_nationkey = s_nationkey AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = ’ASIA’ AND o_orderdate >= ’1994-01-01’ AND o_orderdate < ’1995-01-01’ GROUP BY n_name HAVING n_name LIKE "I%" AND SUM(l_extendedprice*(1-l_discount)) >...
  • Page 171: Adding Column Indexes After Inserting Data

    CHAPTER 4 Adaptive Server IQ Indexes Adding column indexes after inserting data When you create an additional column index, the command CREATE INDEX creates the new index as part of the individual table and as part of any join indexes that include the column. If the existing column indexes in the individual table already contain data, the statement also inserts data into the new index from an existing CREATE INDEX...
  • Page 172: How Join Indexes Are Used For Queries

    Using join indexes How join indexes are used for queries After you create a join index, its use is determined by the criteria of the statement. If a join index exists that joins the tables in the SELECT FROM clause by the relationship specified in the clause, or if a join index WHERE exists that is based on ANSI join syntax for natural or key joins, the join index...
  • Page 173: Columns In The Join Index

    CHAPTER 4 Adaptive Server IQ Indexes Adaptive Server IQ join hierarchies have one table at the top of the tree where the join ends. This table, known as the top table, does not connect to any other tables, although other tables connect to it. The top table always represents the “many”...
  • Page 174: The Join Hierarchy In Query Resolution

    Using join indexes You can set the frequency of these messages with the NOTIFY_MODULUS option, and override the option value in either the CREATE DATABASE command. For examples of these messages, see “Interpreting LOAD TABLE notification messages” on page 187. The join hierarchy in query resolution Adaptive Server IQ can use the same join index to resolve a query that involves the full join relationship specified in the join index, or a query that involves any...
  • Page 175 CHAPTER 4 Adaptive Server IQ Indexes If the join column is made up of more than one column, the combination of the values must be unique on the “one” side. For example, in the asiqdemo database, the in the table and the in the table customer...
  • Page 176: Multiple Table Joins And Performance

    Using join indexes 2307,103,103,’Niedringhaus’ Warning! If the one-to-many relationship is incorrect, the join cannot be synchronized until you remove the extra rows from the “one” table. If you try to synchronize, you get a Duplicate Row error, and the transaction rolls back. When you create a join index, you use ANSI FULL OUTER join syntax.
  • Page 177: Steps In Creating A Join Index

    Create the join index by issuing the command, or in CREATE JOIN INDEX Sybase Central with the Add JoinIndex Wizard. You specify the join hierarchy as part of this step, as described in “Join hierarchy overview”. Note If data exists in the join tables, a synchronize occurs automatically.
  • Page 178: Synchronizing Join Indexes

    Using join indexes The index remains unavailable until all steps are complete. However, you can adjust the order of some steps, depending on the needs of your site: • You can combine steps 1 and 2 by defining relationships when you create the table.
  • Page 179: Defining Join Relationships Between Tables

    CHAPTER 4 Adaptive Server IQ Indexes Performance hints for synchronization Synchronization can be time-consuming. To improve performance, try these suggestions: • Schedule synchronization during off-peak hours. • Synchronize join indexes individually rather than all at once. • Synchronize after executing an entire set of insertions and deletions. It is not a good idea to synchronize after every insertion or deletion, as the time it takes to update a join index depends significantly on the order of the updates to the tables.
  • Page 180 Using join indexes Using foreign references Adaptive Server IQ uses foreign keys to define the relationships among columns that will be used in join indexes, and to optimize queries. However, Adaptive Server IQ does not enforce foreign key constraints. For this reason, when you specify a primary key-foreign key relationship, you must include the keyword.
  • Page 181 CHAPTER 4 Adaptive Server IQ Indexes Alternatively, you could create the table without the clause, and REFERENCES then add the foreign key later, as is done in the following ALTER TABLE statement: ALTER TABLE DBA.sales_order ADD FOREIGN KEY ky_so_customer (cust_id) REFERENCES DBA.customer (id) UNENFORCED Specifying the join type when creating a join index The join type is always...
  • Page 182: Issuing The Create Join Index Statement

    Using join indexes • Use parentheses to control the order in which the join relationships are evaluated. Parentheses control evaluation order just as they do in mathematics, that is, innermost pairs are evaluated first. With this method you start with the top table in the outermost set of parentheses, then any intermediate levels, and include the lowest two levels in the innermost parentheses.
  • Page 183 CHAPTER 4 Adaptive Server IQ Indexes search-condition : [ ( ] search-expression [ AND search-expression ] [ ) ] • The join-clause can be expressed either with or without parentheses. • clause can reference only two tables. One must be the current one, and the other can be any one table in the current join tree.
  • Page 184: Creating A Join Index In Sybase Central

    To create a join index in Sybase Central, follow these steps. To add a join index in Sybase Central: Select the Join Indexes folder in the left panel of the Sybase Central window. Double-click the Add Join Index object in the right panel to open the Join Index editor.
  • Page 185 CHAPTER 4 Adaptive Server IQ Indexes Linear joins You can think of a linear join as a tree with no branches. Each table in the hierarchy is related to the table above it, until you reach the top table. In Figure 4-1 on page 153.
  • Page 186 Using join indexes Example In the sample database used throughout this book, the table sales_order contains three foreign keys, each of which is related to the primary key of another table. You can create this table using the following commands: CREATE TABLE "DBA"."sales_order"( "id"...
  • Page 187: Modifying Tables Included In A Join Index

    CHAPTER 4 Adaptive Server IQ Indexes SELECT sales_rep FROM sales_order WHERE sales_rep = 299 the results show 20 rows with 299 in the sales_rep column. However, if you enter: SELECT emp_id FROM employee WHERE emp_id = 299 the results show only one row with 299 in the column.
  • Page 188: Inserting Or Deleting From Tables In A Join Index

    Using join indexes Adaptive Server IQ automatically applies the changes to the join index at the same time as it changes the base table. You do not need to synchronize the join index after any on nonjoined columns. ALTER TABLE Other restrictions on for join indexes include the following: ALTER TABLE...
  • Page 189: Table Versioning Controls Access To Join Indexes

    CHAPTER 4 Adaptive Server IQ Indexes Table versioning controls access to join indexes Any table is only available for write use to a single user at any given time. For join indexes, this means that when one user is updating any table in a join index, no one else can update any of the tables in that index.
  • Page 190 Estimating the size of a join index These calculations should give you an idea of how much disk space you need for the join index. The results include the segment size in bytes, and the number of blocks. The procedure also tells you how long it will take to create the join index.
  • Page 191: Chapter 5 Moving Data In And Out Of Databases

    Moving Data In and Out of C H A P T E R Databases About this chapter This chapter describes several methods of moving data into and out of your database, and explains when you should use each of them. It also discusses conversion issues for data inserted from other types of databases.
  • Page 192: Input And Output Data Formats

    Import and export overview • To remove specific rows from a table, use the statement. DELETE • To change existing rows in a table, you can also use the UPDATE statement. From DBISQL you can export data to another database in a variety of formats, or produce a text file as output.
  • Page 193: Permissions For Modifying Data

    CHAPTER 5 Moving Data In and Out of Databases Specifying an output format for Interactive SQL You can set the DBISQL output format in three ways: • Select Command Options from the DBISQL menu bar, and then choose an Output Format from the dropdown list. To make this the default output format, click Permanent.
  • Page 194: Exporting Data From A Database

    To export IQ data from your database in this version of Adaptive Server Note IQ, Sybase recommends that you use the method described in this chapter. You may also export data by using a front end tool, written by you or a third party, that effectively queries the IQ database and formats the data as desired.
  • Page 195: Null Value Output

    CHAPTER 5 Moving Data In and Out of Databases Redirecting output redirection symbol redirects all output including error messages and >& and messages statistics for the command on which it appears. For example: SELECT * FROM employee >& empfile Do not enclose the file name in quotation marks. This example outputs the statement to the file empfile, followed by the SELECT...
  • Page 196 Bulk loading data using the LOAD TABLE statement Using command files To load large amounts of data, most users create command files. To create a to load data command file, follow the instructions in the chapter entitled “Getting Started with DBISQL” in the Introduction to Adaptive Server IQ. Transaction When you issue the statement for an IQ table, a savepoint occurs...
  • Page 197 CHAPTER 5 Moving Data In and Out of Databases For each column, you can specify a column-spec. If you omit this option, the format information in the load-options applies to this column. The column- spec and load-options format information tell Adaptive Server IQ what type of data to expect, and how to convert it into a compatible data format if necessary.
  • Page 198 Bulk loading data using the LOAD TABLE statement • string as ASCII characters. You DATE TIME DATETIME TIMESTAMP must define the input-date-format or input-datetime-format of the string using one of the corresponding formats for the data types date datetime supported by Adaptive Server IQ. For information about these, see the Adaptive Server IQ Reference Manual.
  • Page 199 CHAPTER 5 Moving Data In and Out of Databases • If a backslash (\) precedes the characters , or it is considered an escape character. For this reason, to indicate directory paths in Windows NT systems, you must represent the backslash character by two backslashes if the next character is any of those listed.
  • Page 200 Bulk loading data using the LOAD TABLE statement With turned on (the default), trailing blanks are STRIP option STRIP stripped from values before they are inserted. This is effective only for VARCHAR data. To turn the option off, enter the clause as follows: STRIP ...STRIP OFF ...
  • Page 201 CHAPTER 5 Moving Data In and Out of Databases You can specify load options in any order. Syntax for load-options is as follows: [ { BLOCK FACTOR number | BLOCK SIZE number } ] ... [ BYTE ORDER { NATIVE | HIGH | LOW } ] ...
  • Page 202 Bulk loading data using the LOAD TABLE statement Only one single-byte character can be used as an escape character. Note Because you must specify in this version of Adaptive ESCAPES OFF Server IQ, the option has no effect. It is provided for ESCAPE CHARACTER compatibility with Adaptive Server Anywhere.
  • Page 203 CHAPTER 5 Moving Data In and Out of Databases LOAD TABLE nn (l_orderkey, l_quantity ASCII(PREFIX 2), FILLER(2), FROM ’C:\\iq\archive\\mill.txt’ BYTE ORDER LOW Specifies the maximum number of rows to insert into the LIMIT option table. The default is 0 for no limit. works together with the option.
  • Page 204 Bulk loading data using the LOAD TABLE statement • aborts the entire transaction (the default). ROLLBACK • finishes the insertions already completed and ends the load FINISH operation. • returns an error but only skips the file to continue the load CONTINUE operation.
  • Page 205 CHAPTER 5 Moving Data In and Out of Databases You cannot use this option if any input fields contain binary data. With this option, a row terminator causes any missing fields to be set to NULL. All rows must have the same row delimiters, and it must be distinct from all column delimiters.
  • Page 206 Bulk loading data using the LOAD TABLE statement Specifies the id number of a row in the table START ROW ID option where insertions should begin. This option is used for partial-width insertions, which insert into a subset of the columns in the table. If you are inserting data into an existing row, you must define the format of each input column with a column-spec, and use to identify the row where you want to...
  • Page 207: Interpreting Notification Messages

    CHAPTER 5 Moving Data In and Out of Databases Interpreting notification messages By default, Adaptive Server IQ displays information about your database during insert and load operations. The statistics in these messages indicate when you need to perform maintenance and optimization tasks, such as adding more dbspaces. The messages also report on the progress of the load.
  • Page 208: Main Iq Store Blocks Messages

    Bulk loading data using the LOAD TABLE statement Table 5-2: Memory messages Item Description Mem: # mb Current memory being used by this Adaptive Server IQ server, in megabytes. M# mb The maximum number of megabytes used by this IQ server since it was started.
  • Page 209: Temporary Buffer Cache Message

    CHAPTER 5 Moving Data In and Out of Databases Table 5-4: Main IQ Store file message Item Description Main: I: L# Number of logical file reads. Number of physical file reads. O: D# Number of times a buffer was destroyed. Number of physical writes.
  • Page 210: Using The Insert Statement

    Using the INSERT statement Using the INSERT statement statement allows you to insert data without first putting it into a INSERT flat file. Using this command, you can either: • Insert a specified set of values row by row • Insert directly from database tables See the sections that follow for details of these two forms of the command.
  • Page 211: Inserting Selected Rows From The Database

    CHAPTER 5 Moving Data In and Out of Databases • , and columns, you must use a DATE TIME TIMESTAMP DATETIME specific format. See “Converting data on insertion” for information on data type conversions. See the Adaptive Server IQ Reference Manual for a complete description of Adaptive Server IQ data types.
  • Page 212: Inserting From A Different Database

    Inserting selected rows from the database SKIP number-of-rows START ROW ID number This form of the statement lets you insert any number of rows of data, INSERT based on the results of a general statement. SELECT For maximum efficiency, insert as many rows as possible in one INSERT statement.
  • Page 213 Server IQ database into a Version 12 database. In order to use this capability, all of the following must be true: • The Sybase connectivity libraries must be installed on your system, and the load library path environment variable for your platform must point to them.
  • Page 214 Inserting selected rows from the database LOCATION ’detroit.asiq11db’ { SELECT l_shipdate, l_orderkey FROM lineitem } • The destination and source columns may have different names. • The order in which you specify the columns is important, because data from the first source column named is inserted into the first target column named, and so on.
  • Page 215: Importing Data Interactively

    CHAPTER 5 Moving Data In and Out of Databases Importing data interactively If you are inserting small quantities of data, you may prefer to enter it interactively through DBISQL, using the statement INSERT For example, you can insert listed values a single row at a time with the following command: INSERT INTO T1 VALUES ( ...
  • Page 216: Inserting Into Primary And Foreign Key Columns

    Inserting into primary and foreign key columns • The second user's transaction begins before the first user's transaction commits. • The second user tries to update after the first user's transaction commits, but before the join index is synchronized. This problem occurs because Adaptive Server IQ makes a new version of the join index when any of its underlying tables is updated.
  • Page 217: Partial-Width Insertions

    CHAPTER 5 Moving Data In and Out of Databases An easy way to enforce the integrity is to create and run stored procedures that roll back any transaction that violates a constraint. You can use an EXISTS clause to specify violations. Partial-width insertions By default, new rows are inserted wherever there is space in the indexes, and each...
  • Page 218: Partial-Width Insertion Rules

    Partial-width insertions to specify at which row you want to start the insert. This START ROW ID allows you to insert into some of the columns in a row with one partial-width statement, and insert into the other columns in the INSERT LOAD TABLE same row with additional...
  • Page 219 CHAPTER 5 Moving Data In and Out of Databases For the second and any subsequent partial-width inserts for the same set of rows, use the option to specify the row where the insert START ROW ID started. This number is the record number at the beginning of the insert message log, as in this example: In table ’department’, the full width insert of 3 columns...
  • Page 220 Partial-width insertions NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 2127 NULL NULL 1376 NULL NULL NULL NULL (10 rows affected) Example 2 The following example shows the correct way to do this operation. Note the option in the second statement.
  • Page 221 CHAPTER 5 Moving Data In and Out of Databases 1376 (5 rows affected) To ensure that the data from the second two columns is inserted into the same rows as the first two columns, you must specify the row number in the START option on the command for the next two columns.
  • Page 222: Converting Data On Insertion

    Converting data on insertion NULL 152.00 NULL 172.00 (2 rows affected) If you later load data from another file into ps_partkey ps_availqty insertions begin correctly at the next row, as shown below. LOAD TABLE partsupp (ps_partkey ASCII(6), ps_availqty ASCII(6), FILLER(2)) FROM ’C:\\iq\\archive\\mill2.txt’...
  • Page 223 CHAPTER 5 Moving Data In and Out of Databases • When you insert data selected from another database • When you load data from a flat file When an explicit conversion is needed, the way that you specify the conversion depends on whether you are loading from a flat file or inserting selected rows: •...
  • Page 224: Inserting Data From Pre-Version 12 Adaptive Server Iq

    Converting data on insertion You can use a synonym interchangeably with its standard data type. Data is stored internally as the standard data type, where synonyms exist. In error messages, the standard name appears in place of the synonym. By default, Adaptive Server IQ assumes that input data is binary Note (numeric data) and tries to insert it that way.
  • Page 225 CHAPTER 5 Moving Data In and Out of Databases Adaptive Server IQ Option Datatypes Action By default, Adaptive Server IQ assumes same column width ASCII CHAR, VARCHAR between source and destination columns, which may cause it to read input file incorrectly. This option lets you specify a different width for the input column.
  • Page 226 Converting data on insertion The first table shows implicit (I), explicit (E), and unsupported (U) conversions when there is no clause in the statement, or when the WHERE SELECT WHERE clause is based on a comparison operation (=, > or <). Figure 5-2: IQ conversions for comparison operations...
  • Page 227 CHAPTER 5 Moving Data In and Out of Databases The second table shows implicit (I), explicit (E), and unsupported (U) conversions when the clause in a statement is based on an WHERE SELECT arithmetic operation (+, –, etc.). Figure 5-3: IQ conversions for arithmetic operations Note In arithmetic operations, data is implicitly converted to...
  • Page 228: Column Width Issues

    Converting data on insertion Column width issues Adaptive Server IQ assumes the width of the input data is the same as the destination column width and reads the input file accordingly. If they are not the same width, Adaptive Server IQ may read too few or too many bytes of the input file for that column.
  • Page 229 CHAPTER 5 Moving Data In and Out of Databases Truncation of data for If the width of the input column is greater than the width of the destination VARCHAR and CHAR column, Adaptive Server IQ truncates the data upon insertion. If the width of columns the input data is less than the width of the destination column, for CHAR...
  • Page 230: The Date Option

    Converting data on insertion Substitution of NULL or blank characters Adaptive Server IQ supports zero-length data. If the CHAR VARCHAR length of a cell is zero and the cell is not NULL, you get a CHAR VARCHAR zero-length cell. For all other data types, if the length of the cell is zero, Adaptive Server IQ inserts a NULL.
  • Page 231 CHAPTER 5 Moving Data In and Out of Databases Option Meaning mm or MM Represents number of month. Always use leading zeros for number of the month where appropriate, for example ’05’ for May. If you omit the month from a value, the day is DATE treated as a Julian date.
  • Page 232: The Datetime Conversion Option

    Converting data on insertion • Use any character other than Y, M, J, or D to indicate the separator character you want Adaptive Server IQ to skip over. You can even use blanks. • If a format includes only a year and a day number within the year, DATE Adaptive Server IQ treats the date as a Julian date.
  • Page 233 CHAPTER 5 Moving Data In and Out of Databases l_quantity ASCII(4), l_shipdate DATETIME(’MM/DD/YY hh:mm:ss’), FILLER(1)) FROM ’/d1/MILL1/tt.t’ BLOCK FACTOR 1000 PREVIEW ON In this UNIX example, the FILLER(1) clause prevents Adaptive Server IQ from inserting a NULL in the next column (VWAP) after the DATETIME column: LOAD TABLE snapquote_stats_base SYMBOL ‘\x09’,...
  • Page 234 Converting data on insertion The length of the format string is the width of the input column. Table 5-7 describes the date formatting options. The following table describes the time formatting options. Table 5-9: Formatting times Option Meaning Represents hour. Hour is based on 24-hour clock. Always use leading zeros for hour where appropriate, for example ’01’...
  • Page 235: Working With Nulls

    CHAPTER 5 Moving Data In and Out of Databases • The input data can include up to nine positions for seconds, including a floating decimal point, to allow for fractional seconds. On input and query, the decimal point floats, so you can specify up to six decimal positions. However, Adaptive Server IQ always stores only six decimal positions with two positions for whole seconds (ss.ssssss).
  • Page 236: Other Factors Affecting The Display Of Data

    Other factors affecting the display of data • indicates that binary zeros convert to NULLS. ZEROS • indicates that all occurrences of the specified literal convert to literal NULLS. The specified literal must match exactly, including leading and/or trailing blanks, with the value in the input file, for Adaptive Server IQ to recognize it as a match.
  • Page 237: Matching Adaptive Server Enterprise Data Types

    CHAPTER 5 Moving Data In and Out of Databases • When an arithmetic operation results in a higher scale than the predetermined scale, Adaptive Server IQ truncates the results to fit the scale after it has been determined using the rules defined in the Adaptive Server IQ Reference Manual.
  • Page 238: Adaptive Server Enterprise Data Type Equivalents

    Matching Adaptive Server Enterprise data types Adaptive Server Enterprise data type equivalents The table below indicates the Adaptive Server Enterprise exact numeric types and the Adaptive Server IQ equivalents. Table 5-11: Integer data types Adaptive Server Enterprise Adaptive Server IQ Datatype Datatype Notes...
  • Page 239 CHAPTER 5 Moving Data In and Out of Databases Adaptive Server Adaptive Server IQ Enterprise Datatype Datatype Notes double precision DOUBLE real REAL The following table indicates the Adaptive Server Enterprise character data types and the Adaptive Server IQ equivalents. Table 5-13: Character data types Adaptive Server Adaptive Server...
  • Page 240: Handling Conversion Errors On Data Import

    Matching Adaptive Server Enterprise data types Table 5-15: DATE/TIME data types Adaptive Server Adaptive Server Enterprise Datatype IQ Datatype Notes Adaptive Server Enterprise columns maintain date and datetime TIMESTAMP datetime time of day values in 4 bytes for number of days before or after DATE TIME base date of virtual date 0/0/0000 and 8 bytes for time of day,...
  • Page 241: Tuning Bulk Loading Of Data

    CHAPTER 5 Moving Data In and Out of Databases For information on setting DBISQL database options, see “SET OPTION statement” in the Adaptive Server IQ Reference Manual. Tuning bulk loading of data Loading large volumes of data into a database can take a long time and use a lot of disk space.
  • Page 242: Setting Server Startup Options

    Tuning bulk loading of data Adding dbspaces If you run out of space while loading data, Adaptive Server IQ prompts you to create another dbspace, and then continues the operation after you add the dbspace. To avoid this delay, make sure that you have enough room for all of the data you are loading before you start the load operation.
  • Page 243: Reducing Main Iq Store Space Use In Incremental Loads

    CHAPTER 5 Moving Data In and Out of Databases • Increase the size of the database cache. Providing enough memory for the load is a key performance factor. Use the command to adjust SET OPTION . For MAIN_CACHE_MEMORY_MB TEMP_CACHE_MEMORY_MB these options to take effect, you must ensure that no users are using the database where you set the option, and then disconnect from the database.
  • Page 244: Changing Data Using Update

    Changing data using UPDATE The Append_Load option applies to , and LOAD INSERT...SELECT statements. INSERT...VALUES For more information on versioning see Chapter 8, “Transactions and Versioning”. Changing data using UPDATE You can use the statement, followed by the name of the table or view, UPDATE to change single rows, groups of rows, or all rows in a table.
  • Page 245: Deleting Data

    CHAPTER 5 Moving Data In and Out of Databases The search condition need not refer to the column being updated. The company ID for Newton Entertainments is 109. As the ID value is the primary key for the table, you could be sure of updating the correct row using the following statement: UPDATE customer SET company_name = ’Einstein, Inc.’...
  • Page 246: Importing Data By Replication

    If you need to update your IQ data frequently from an Adaptive Server Enterprise database, you may want to consider setting up a replication environment. In this environment, you can use the Sybase Distribution Director to automate the process of replicating data from an Adaptive Server Enterprise database into an Adaptive Server IQ database.
  • Page 247 CHAPTER 5 Moving Data In and Out of Databases For information on using Distribution Director and on setting up an appropriate Replication Server environment, see the Distribution Director User’s Guide.
  • Page 248 Importing data by replication...
  • Page 249: Using Procedures And Batches

    Using Procedures and Batches C H A P T E R About this chapter This chapter explains how you create procedures and batches for use with Adaptive Server IQ. Procedures store procedural SQL statements in the database for use by all applications.
  • Page 250: Benefits Of Procedures

    Benefits of procedures Benefits of procedures Procedures are defined in the database, separate from any one database application. This separation provides a number of advantages. Standardization Procedures allow standardization of any actions that are performed by more than one application program. The action is coded once and stored in the database.
  • Page 251: Creating Procedures

    • If you are using a tool other than DBISQL or Sybase Central, follow the instructions for your tool. You may need to change the command delimiter away from the semicolon before entering the CREATE PROCEDURE statement.
  • Page 252: Calling Procedures

    Introduction to procedures The body of a procedure is a compound statement. The compound statement starts with a statement and concludes with an statement. In the case BEGIN , the compound statement is a single INSERT bracketed by BEGIN new_dept and END statements.
  • Page 253: Permissions To Execute Procedures

    CHAPTER 6 Using Procedures and Batches Permissions to execute procedures A procedure is owned by the user who created it, and that user can execute it without permission. Permission to execute it can be granted to other users using the GRANT EXECUTE command. For example, the owner of the procedure could allow new_dept...
  • Page 254: Returning Procedure Results In Result Sets

    Introduction to procedures Create a variable to hold the procedure output. In this case, the output variable is numeric, with three decimal places, so create a variable as follows: CREATE VARIABLE Average NUMERIC(20,3) Call the procedure, using the created variable to hold the result: CALL AverageSalary(Average) The DBISQL statistics window displays the message "Procedure completed"...
  • Page 255: Introduction To User-Defined Functions

    CHAPTER 6 Using Procedures and Batches Employee ID Salary 72995.000 48023.690 To execute a CALL of a procedure that returns a result set, DBISQL opens a cursor. The cursor is left open after the CALL in case a second result set is returned. The DBISQL statistics window displays the plan of the SELECT query in the procedure and then displays the line: Procedure is executing.
  • Page 256: Calling User-Defined Functions

    Introduction to user-defined functions If you are using a tool other than DBISQL or Sybase Central, you may need to change the command delimiter away from the semicolon before entering the statement. CREATE FUNCTION CREATE FUNCTION fullname (firstname CHAR(30), lastname CHAR(30))
  • Page 257: Dropping User-Defined Functions

    CHAPTER 6 Using Procedures and Batches SELECT fullname (’Jane’, ’Smith’); fullname (’Jane’,’Smith’) Jane Smith function can be used by any user who has been granted fullname EXECUTE permission for the function. Dropping user-defined functions Once a user-defined function is created, it remains in the database until it is explicitly removed.
  • Page 258: Introduction To Batches

    Introduction to batches Introduction to batches A simple batch consists of a set of SQL statements, separated by semicolons. For example, the following set of statements form a batch that adds a new sales representative to the Eastern Sales department, and adds two sales orders for that sales rep.
  • Page 259: Control Statements

    CHAPTER 6 Using Procedures and Batches DBISQL and batches A list of semicolon-separated statements, such as the above, is parsed by DBISQL before it is sent to the server. In this case, DBISQL sends each statement individually to the server, not as a batch. Unless you have such parsing code in your application, the statements would be sent and treated as a batch.
  • Page 260: Using Compound Statements

    Control statements Control statement Syntax Compound statements BEGIN [ ATOMIC ] statement-list Conditional execution: IF IF condition THEN statement-list ELSEIF condition THEN statement-list ELSE statement-list END IF Conditional execution: CASE CASE expression WHEN value THEN statement-list WHEN value THEN statement-list ELSE statement-list END CASE...
  • Page 261: Declarations In Compound Statements

    CHAPTER 6 Using Procedures and Batches A command delimiter is required after every statement in a statement list except for the last, where it is optional. Declarations in compound statements Local declarations in a compound statement immediately follow the BEGIN keyword.
  • Page 262: Atomic Compound Statements

    Control statements FROM customer WHERE nationality(id) = ’CDN’ Declarations of cursors and exceptions are discussed in later sections. Atomic compound statements An atomic statement is a statement that is executed completely or not at all. For example, a statement that inserts thousands of rows might encounter LOAD an error after many rows.
  • Page 263: The Structure Of Procedures

    CHAPTER 6 Using Procedures and Batches The structure of procedures The body of a procedure consists of a compound statement as discussed in “Using compound statements” on page 240. A compound statement consists of a BEGIN and an END, enclosing a set of SQL statements. The statements must be separated by semicolons.
  • Page 264: Declaring Parameters For Procedures

    The structure of procedures Declaring parameters for procedures Procedure parameters, or arguments, are specified as a list in the CREATE PROCEDURE statement. Parameter names must conform to the rules for other database identifiers such as column names. They must be a valid data types (see “SQL Data Types”...
  • Page 265: Passing Parameters To Procedures

    CHAPTER 6 Using Procedures and Batches Passing parameters to procedures You can take advantage of default values of stored procedure parameters with either of two forms of the CALL statement. If the optional parameters are at the end of the argument list in the CREATE PROCEDURE statement, they may be omitted from the CALL statement.
  • Page 266: Returning Results From Procedures

    Returning results from procedures Name Fran Whitney Matthew Cobb Philip Chin Julie Jordan Robert Breault Notes • Default parameters can be used in calling functions. However, parameters cannot be passed to functions by name. • Parameters are passed by value, not by reference. Even if the function changes the value of the parameter, this change is not returned to the calling environment.
  • Page 267: Returning Results As Procedure Parameters

    CHAPTER 6 Using Procedures and Batches CREATE VARIABLE returnval INTEGER ; returnval = CALL myproc() ; Returning results as procedure parameters Procedures can return results to the calling environment in the parameters to the procedure. Within a procedure, parameters and variables can be assigned values in one of the following ways: •...
  • Page 268 Returning results from procedures When a statement is executed, the server retrieves the results of the SELECT statement and places the results in the variables. If the query results SELECT contain more than one row, the server returns an error. For queries returning more than one row, cursors must be used.
  • Page 269: Returning Result Sets From Procedures

    CHAPTER 6 Using Procedures and Batches Returning result sets from procedures If a procedure returns more than one row of results to the calling environment, it does so using result sets. The following procedure returns a list of customers who have placed orders, together with the total value of the orders placed.
  • Page 270: Returning Multiple Result Sets From Procedures

    Returning results from procedures • When testing this procedure, DBISQL opens a cursor to handle the results. The cursor is left open following the SELECT statement, in case the procedure returns more than one result set. You should type RESUME to complete the procedure and close the cursor.
  • Page 271: Using Cursors In Procedures

    CHAPTER 6 Using Procedures and Batches If you are not using this feature of variable result sets, it is recommended that you employ a RESULT clause, for performance reasons and to allow front-end tools to discern the columns and data types the procedure will produce without executing it.
  • Page 272: Cursor Management Overview

    Using cursors in procedures Cursor management overview Managing a cursor is similar to managing a file in a programming language. The following steps are used to manage cursors: Declare a cursor for a particular SELECT statement or procedure using the DECLARE statement.
  • Page 273: Using Cursors On Select Statements In Procedures

    CHAPTER 6 Using Procedures and Batches Using cursors on SELECT statements in procedures The following procedure uses a cursor on a SELECT statement. It illustrates several features of the stored procedure language. It is based on the same query used in the procedure described in “Returning result sets ListCustomerValue from procedures”.
  • Page 274 Using cursors in procedures -- 7. Close the cursor CLOSE ThisCompany; Notes procedure has the following notable features: TopCustomerValue • The "error not found" exception is declared. This exception is used later in the procedure to signal when a loop over the results of a query has completed.
  • Page 275: Errors And Warnings In Procedures

    CHAPTER 6 Using Procedures and Batches AS ThisValue FROM customer INNER JOIN sales_order INNER JOIN sales_order_items INNER JOIN product GROUP BY ThisName IF ThisValue > TopValue THEN SET TopCompany = ThisName; SET TopValue = ThisValue; END IF; END FOR CompanyLoop; Errors and warnings in procedures After an application program executes a SQL statement, it can examine a return code.
  • Page 276: Default Error Handling In Procedures

    Errors and warnings in procedures Default error handling in procedures This section describes how Adaptive Server IQ handles errors that occur during a procedure execution, if you have no error handling built in to the procedure. If you want to have different behavior from that described in this section, you can use exception handlers, described in “Using exception handlers in procedures”...
  • Page 277 CHAPTER 6 Using Procedures and Batches Notes • The DECLARE statement in declares a symbolic name for one InnerProc of the predefined SQLSTATE values associated with error conditions already known to the server. The DECLARE statement does not take any other action.
  • Page 278: Error Handling With On Exception Resume

    Errors and warnings in procedures Error handling with ON EXCEPTION RESUME If the ON EXCEPTION RESUME clause is included in the CREATE PROCEDURE statement, the procedure checks the following statement when an error occurs. If the statement handles the error, then the procedure does not return control to the calling environment when an error occurs.
  • Page 279 CHAPTER 6 Using Procedures and Batches CREATE PROCEDURE OuterProc() ON EXCEPTION RESUME BEGIN DECLARE res CHAR(5); MESSAGE ’Hello from OuterProc.’; CALL InnerProc(); SELECT @res=SQLSTATE; IF @res=’52003’ THEN MESSAGE ’SQLSTATE set to ’, res, ’ in OuterProc.’; END IF END; CREATE PROCEDURE InnerProc() ON EXCEPTION RESUME BEGIN DECLARE column_not_found...
  • Page 280: Default Handling Of Warnings In Procedures

    Errors and warnings in procedures Default handling of warnings in procedures Warnings are handled differently from errors. While the default action for errors is to set a value for the SQLSTATE and SQLCODE variables, and return control to the calling environment, the default action for warnings is to set the SQLSTATE and SQLCODE values and continue execution of the procedure.
  • Page 281: Using Exception Handlers In Procedures

    CHAPTER 6 Using Procedures and Batches The procedures both continued executing after the warning was generated, with SQLSTATE set by the warning (02000). Using exception handlers in procedures It is often desirable to intercept certain types of errors and handle them within a procedure, rather than pass the error back to the calling environment.
  • Page 282 Errors and warnings in procedures MESSAGE ’Column not found handling.’; WHEN OTHERS THEN RESIGNAL ; The EXCEPTION statement declares the exception handler itself. The lines following the EXCEPTION statement are not executed unless an error occurs. Each WHEN clause specifies an exception name (declared with a DECLARE statement) and the statement or statements to be executed in the event of that exception.
  • Page 283: Nested Compound Statements And Exception Handlers

    CHAPTER 6 Using Procedures and Batches • If the error handling code for the exception is simply column not found a RESIGNAL statement, control is passed back to the procedure OuterProc with SQLSTATE still set at the value 52003. This is just as if there were no error handling code in .
  • Page 284: Using The Execute Immediate Statement In Procedures

    Using the EXECUTE IMMEDIATE statement in procedures MESSAGE ’Outer compound statement’; The following statement executes the procedure: InnerProc CALL InnerProc(); The message window of the server then displays the following: Hello from InnerProc Column not found handling Outer compound statement When the SIGNAL statement that causes the error is encountered, control passes to the exception handler for the compound statement, and the Column...
  • Page 285: Transactions And Savepoints In Procedures

    This section provides some pointers for developing procedures. Check if you need to change the command delimiter You do not need to change the command delimiter in DBISQL or Sybase Central when you are writing procedures. However, if you are creating and testing procedures from some other browsing tool, you may need to change the command delimiter from the semicolon to another character.
  • Page 286: Remember To Delimit Statements Within Your Procedure

    Some tips for writing procedures Remember to delimit statements within your procedure You should terminate each statement within the procedure with a semicolon. Although you can leave off semicolons for the last statement in a statement list, it is good practice to use semicolons after each statement. The CREATE PROCEDURE statement itself contains both the RESULT specification and the compound statement that forms its body.
  • Page 287: Verifying Procedure Input Arguments

    CHAPTER 6 Using Procedures and Batches Verifying procedure input arguments You can verify that input arguments to a procedure are passed correctly in several ways. You can display the value of the parameter on the message window of the server using the MESSAGE statement. For example, the following procedure simply displays the value of the input parameter var: CREATE PROCEDURE message_test (IN var char(40)) BEGIN...
  • Page 288: Using Select Statements In Batches

    Calling external libraries from procedures Using SELECT statements in batches You can include one or more SELECT statements in a batch. Multiple SELECT statements are allowed by Interactive SQL only if they return the same number of columns and each column has the same data type. The following is a valid batch: IF EXISTS(SELECT * FROM systable...
  • Page 289: Creating Procedures And Functions With External Calls

    CHAPTER 6 Using Procedures and Batches This section describes how to use the external library calls in procedures. Warning! External libraries can corrupt your database. External libraries called from procedures share the memory of the server. If you call a DLL from a procedure and the DLL contains memory-handling errors, you can crash the server or corrupt your database.
  • Page 290: External Function Declarations

    Calling external libraries from procedures In these statements, function_name is the name of a function in the dynamic link library, and library.dll is the name of the library. The arguments in the procedure argument list must correspond in type and order to the arguments for the library function;...
  • Page 291: How Parameters Are Passed To The External Function

    CHAPTER 6 Using Procedures and Batches How parameters are passed to the external function SQL data types are mapped to their C equivalents as follows: SQL data type C data type INTEGER long (32 bits) SMALLINT short REAL float CHAR( n ) char * These are the only SQL data types you can use: using others produces an error.
  • Page 292: Special Considerations When Passing Character Types

    Calling external libraries from procedures Special considerations when passing character types For the character data type (CHAR), Adaptive Server IQ allocates a 255-byte buffer (including one for the null terminator) for each parameter. If the parameter is an INOUT parameter, the existing value is copied into the buffer and null terminated, and a pointer to this buffer is passed to the external function.
  • Page 293: Chapter 7 Ensuring Data Integrity

    Ensuring Data Integrity C H A P T E R About this chapter This chapter describes facilities for ensuring that the data in your database is valid and reliable. These facilities include constraints on tables and columns, and choosing appropriate data types. The SQL statements in this chapter use the CREATE TABLE statement and ALTER TABLE statement, basic forms of which were introduced in Chapter 3, “Working with Database Objects”...
  • Page 294: Integrity Constraints Belong In The Database

    Data integrity overview Integrity constraints belong in the database To help ensure that the data in a database are valid, you need to formulate checks that define valid and invalid data and design rules to which data must adhere. The rules to which data must conform are often called business rules. The collective name for checks and rules is constraints.
  • Page 295: How Database Contents Get Changed

    CHAPTER 7 Ensuring Data Integrity See “Creating tables” for more information on how constraints affect optimization. For more on join indexes and foreign keys, see “Using join indexes”. Constraints and Load Adaptive Server IQ checks during load operations that certain constraints are Operations obeyed: •...
  • Page 296: Sql Statements For Implementing Integrity Constraints

    Data integrity overview These and other table and column constraints are discussed in “Using table and column constraints”. Column constraints can be inherited from user-defined data types. Entity and referential The information in relational database tables is tied together by the relations integrity between tables.
  • Page 297: Using Table And Column Constraints

    CHAPTER 7 Ensuring Data Integrity Using table and column constraints The CREATE TABLE statement and ALTER TABLE statement can specify many different attributes for a table. Along with the basic table structure (number, name and data type of columns, name and location of the table), you can specify other features that allow control over data integrity.
  • Page 298: Using Iq Unique Constraint On Columns

    Using table and column constraints Using IQ UNIQUE constraint on columns constraint specifies an estimate of the number of distinct IQ UNIQUE values in a column. You can apply the constraint to any column in IQ UNIQUE a table. This constraint helps optimize loading of indexes. For example, in the column of the table, you would specify...
  • Page 299: Column Check Conditions From User-Defined Data Types

    CHAPTER 7 Ensuring Data Integrity By default, string comparisons are case insensitive unless the database is explicitly created as a case-sensitive database, using the CASE RESPECT option. Example 3 You can specify that a date or number falls in a particular range. For example, you may want to require that the column of an employee table must start_date...
  • Page 300: Working With Column Constraints In Sybase Central

    Using table and column constraints Working with column constraints in Sybase Central All adding, altering, and deleting of column constraints in Sybase Central is carried out in the Constraints tab of the column properties sheet. To display the property sheet for a column: Connect to the database.
  • Page 301: Declaring Entity And Referential Integrity

    CHAPTER 7 Ensuring Data Integrity • You can replace a CHECK condition on a column in the same way as you would add a CHECK condition. The following statement adds or replaces an unenforced CHECK condition on the column of the phone customer table:...
  • Page 302: Enforcing Entity Integrity

    Declaring entity and referential integrity Enforcing entity integrity When a new row in a table is created, or when a row is updated, the database server ensures that the primary key for the table is still valid: that each row in the table is uniquely identified by the primary key.
  • Page 303: Primary Keys Enforce Entity Integrity

    CHAPTER 7 Ensuring Data Integrity It is up to the application programmer to decide how to present this information to the user and enable the user to take appropriate action. The appropriate action in this case is usually just to provide a unique value for the primary key. Primary keys enforce entity integrity Once the primary key for each table is specified, no further action is needed by client application developers or by the database administrator to maintain...
  • Page 304: How You Define Foreign Keys

    Declaring entity and referential integrity Example 1 The sample database contains an employee table and a department table. The primary key for the employee table is the employee ID, and the primary key for the department table is the department ID. One of the items of information about each employee is the department ID of the department to which they belong.
  • Page 305: Integrity Rules In The System Tables

    It includes default settings and primary key information for columns. For a description of the contents of each system table, see “System Tables” in the Adaptive Server IQ Reference Manual. You can use Sybase Central or DBISQL to browse these tables and views.
  • Page 306 Integrity rules in the system tables...
  • Page 307: Transactions And Versioning

    Transactions and Versioning C H A P T E R About this chapter This chapter describes Adaptive Server IQ’s approach to transaction processing, called snapshot versioning, and its implications for performance and other aspects of database administration. Overview of transactions and versioning Adaptive Server IQ uses transaction processing to allow many users to read from the database while it is being updated.
  • Page 308 Overview of transactions and versioning Transactions are atomic. In other words, Adaptive Server IQ executes all the statements within a transaction as a unit. At the end of each transaction, changes can be committed to make them permanent. If for any reason all the commands in the transaction do not process properly, then some or all of the intermediate changes can be undone, or rolled back.
  • Page 309 CHAPTER 8 Transactions and Versioning • statement undoes all the changes made by the transaction. ROLLBACK • A disconnection from a database causes an implicit rollback (the default) or commit, depending on whether the DBISQL option COMMIT_ON_EXIT is set. • A statement with a side effect of an automatic commit is executed.
  • Page 310: Introduction To Concurrency

    Overview of transactions and versioning Subdividing transactions You can identify important states within a transaction and return to them selectively or cause other actions to occur by using savepoints. Savepoints are discussed further in “Savepoints within transactions”. Introduction to concurrency Adaptive Server IQ can execute more than one transaction at the same time.
  • Page 311: Introduction To Versioning

    CHAPTER 8 Transactions and Versioning Concurrency and IQ Multiplex IQ Multiplex extends Adaptive Server IQ to allow concurrent processing of read transactions on multiple Adaptive Server IQ servers. IQ Multiplex extends snapshot versioning to maintain the consistency of the database across multiple servers.
  • Page 312 Overview of transactions and versioning Unlike a camera, though, IQ does not need to make a copy of the entire object each time the image changes. Instead, it copies only the parts of the image— the database pages—that have changed. Database pages that have not changed are shared among all active versions in the database.
  • Page 313 CHAPTER 8 Transactions and Versioning Figure 8-1: Only one writer at a time Meanwhile, other users can read from the table at any time. In this customer way queries can proceed while the database administrator inserts and deletes table data. In Figure 8-2, User 3 and User 4 are able to query the table customer while User 1’s write transaction remains open.
  • Page 314 Overview of transactions and versioning Figure 8-2: One writer, multiple readers Multiple writers and readers in a database Within an IQ database that is not multiplex, multiple read-only and read/write users can operate concurrently, as long as the writers are inserting data into (or deleting it from) different tables.
  • Page 315 CHAPTER 8 Transactions and Versioning Figure 8-3: Concurrent insertions to different tables Data definition operations on a single table lock out all other readers and writers from that table. See “Locks for DDL operations” for details. Transactions use committed data Committed data results when a write transaction commits.
  • Page 316 Overview of transactions and versioning In other words, every transaction begins with a snapshot of the data in a reliable state. The snapshot of the data that you see when you issue a query does not change, even if another user is updating the table you are reading. For example, in Figure 8-4, when User 1’s write transaction begins, it uses the table customer...
  • Page 317 CHAPTER 8 Transactions and Versioning • If a user's read transaction commits before a concurrent write transaction does, and that user begins a new read transaction, the version remains the same. • If a read transaction commits after a concurrent write transaction does, any new transaction, whether read-only or read/write, uses a new version.
  • Page 318 Overview of transactions and versioning How Adaptive Server IQ keeps track of versions Adaptive Server IQ assigns a version identifier to each database object that exists in the metadata, and that has a life span beyond a single command. IQ uses these version identifiers to ensure that writes to any database object are always based on the latest version of the object.
  • Page 319: Versioning Prevents Inconsistencies

    CHAPTER 8 Transactions and Versioning Versioning prevents inconsistencies Without versioning, concurrent read and write operations could cause inconsistencies in the database. The table-level versioning provided by Adaptive Server IQ prevents inconsistencies both by serializing transactions, and by making the table the version level. Adaptive Server IQ allows multiple writers to modify a table serially—that is, one after the other, never more than one at a time—while multiple readers continue to work on an original copy of the table.
  • Page 320: Locks For Ddl Operations

    How locking works • Read transactions do not block write transactions. • Write transactions do not block read transactions. • A single update user and multiple read-only users can concurrently access a table. • Only a single user can update the data in a given table at one time. The first transaction to open a table in write mode gains access to the table.
  • Page 321 CHAPTER 8 Transactions and Versioning Cannot perform DDL command now as a DDL command is already in progress. If a command is in progress, and a user CREATE DBSPACE DROP DBSPACE explicitly issues a command, the checkpoint fails with the CHECKPOINT message: Run time SQL Error...
  • Page 322: Primary Keys And Locking

    Isolation levels GRANT, REVOKE, While the commands , and are also considered GRANT REVOKE SET OPTION and SET OPTION are DDL operations, they cause no concurrency conflicts, and so are not restricted. not restricted always cause an automatic commit; causes GRANT REVOKE SET OPTION...
  • Page 323: Checkpoints, Savepoints, And Transaction Rollback

    CHAPTER 8 Transactions and Versioning The level of isolation that Adaptive Server IQ provides prevents several types of inconsistencies. The ones most commonly encountered are listed here: • Dirty Reads Transaction A modifies an object, but does not commit or roll back the change.
  • Page 324: Checkpoints

    Checkpoints, savepoints, and transaction rollback Adaptive Server IQ relies on three transaction-related commands that help you recover a stable set of data in the event of system or media failure. These commands set checkpoints, set and release savepoints, and roll back transactions.
  • Page 325: Savepoints Within Transactions

    CHAPTER 8 Transactions and Versioning • At the start and end of the backup process. • When the database server is shut down. is the maximum time that can pass between CHECKPOINT_TIME checkpoints. It is set by default at 60 minutes. You can adjust the checkpoint interval with the command;...
  • Page 326 Checkpoints, savepoints, and transaction rollback Rolling back to a savepoint You can undo all changes after a savepoint by issuing a ROLLBACK TO . This command rolls back to the savepoint you specify, or to the SAVEPOINT most recent if you do not specify a named savepoint. Rolling back SAVEPOINT to savepoint n undoes all actions for all savepoints greater than or equal to n.
  • Page 327: Rolling Back Transactions

    CHAPTER 8 Transactions and Versioning Rolling back transactions When you roll back a transaction, you undo all of the operations in that transaction. We say that you are rolling back the database, since you are returning the database to an earlier state. What causes a rollback Rollbacks can occur either due to an explicit user request, or automatically.
  • Page 328: How Transaction Information Aids Recovery

    Adaptive Server IQ Troubleshooting and Error Messages Guide for information on how to proceed. You will need information from your server log and IQ message log to recover. Sybase recommends that you run the stored procedure after a sp_iqcheckdb system failure, preferably before allowing users to connect. This procedure checks every block in your database, and produces statistics that allow you to check the consistency and integrity of your database.
  • Page 329: Performance Implications

    CHAPTER 8 Transactions and Versioning • Additional information about checkpoints that occurred during a transaction. When you need to recover your database, instead of repeating all of the lengthy transactions that have occurred, Adaptive Server IQ restores quickly from the information in the transaction log and the checkpoint information.
  • Page 330: Overlapping Versions And Deletions

    Performance implications • Disk space can sometimes become an issue. Storing overlapping versions has the potential to use a lot of disk space, depending on the number and size of versions in use simultaneously. Metadata and database page versions are retained until they are dropped, either at a RELEASE or when the last transaction that can see a given version SAVEPOINT...
  • Page 331: Cursors In Transactions

    CHAPTER 8 Transactions and Versioning Out of disk space After you add space, the deletion resumes. When the delete transaction commits, the space becomes available for other deletions or insertions. If you do not need normally that much space in your database, you can drop the dbspace to regain the extra disk space for other purposes.
  • Page 332: Cursors And Versioning

    Cursors in transactions The rows in a cursor, like those in a table, have no order associated with them. command steps through the rows, but the order may appear FETCH random and can even be inconsistent. For this reason, you will want to impose an order by appending an phrase to your statement.
  • Page 333: Hold Cursors

    CHAPTER 8 Transactions and Versioning Hold cursors Specifying the option when you open a cursor keeps the cursor open past HOLD the end of the transaction, if the transaction ends in a . A hold cursor COMMIT does not remain open across a in which a cursor is opened.
  • Page 334 Cursors in transactions...
  • Page 335: International Languages And Character Sets

    International Languages and C H A P T E R Character Sets About this chapter This chapter describes how to configure your Adaptive Server IQ installation to handle international language issues. Introduction to international languages and character sets This section provides an introduction to the issues you may face when working in an environment that uses more than one character set, or when using languages other than English.
  • Page 336: Using The Default Collation

    Introduction to international languages and character sets • Conditions using the LIKE keyword. IQ indexes that hold character data are created based on the database collation. The database also uses collations to identify valid or unique identifiers (column names and so on). You can set up Adaptive Server IQ to •...
  • Page 337: Understanding Character Sets In Software

    CHAPTER 9 International Languages and Character Sets To answer the question... Consider reading... How are characters represented in “Understanding character sets in software, and Adaptive Server IQ in software” on page 317 particular? What collations does Adaptive Server “Supplied collations” on page 329 IQ provide? How do I ensure that error and “Character translation for database...
  • Page 338: Language Issues In Client/Server Computing

    Understanding character sets in software • Database servers, which sort characters (for example, list names alphabetically), use a collation. A collation is a combination of a character encoding (a map between characters and hexadecimal numbers) and a sort order for the characters. There may be more than one sort order for each character set;...
  • Page 339: Code Pages In Windows And Windows Nt

    CHAPTER 9 International Languages and Character Sets The client operating system has text displayed on • Operating system its interface, and may also process text. For a satisfactory working environment, all these sources of text must work together. Loosely speaking, they must all be working in the user’s language and/or character set.
  • Page 340 Understanding character sets in software Remember that the code page used by the client system determines both the values that are sent to server for each character you enter, and the characters that are displayed when particular values are sent to the client from the server. The code page used by the server system determines how the server interprets values the client sends.
  • Page 341: Multibyte Character Sets

    CHAPTER 9 International Languages and Character Sets Multibyte character sets Some languages, such as Japanese and Chinese, have many more than 256 characters. These characters cannot all be represented using a single byte, but can be represented in multibyte character sets. In addition, some character sets use the much larger number of characters available in a multibyte representation to represent characters from many languages in a single, more comprehensive, character set.
  • Page 342: Sorting Characters Using Collations

    Understanding character sets in software Sorting characters using collations The database collation sequence includes the notion of alphabetic ordering of letters, and extends it to include all characters in the character set, including digits and space characters. Associating more than More than one character can be associated with each sort position.
  • Page 343: Understanding Locales

    CHAPTER 9 International Languages and Character Sets The equivalence of upper and lower case characters is enforced in the collation. There are some collations where particular care may be needed when assuming case insensitivity of identifiers. Example In the Turkish 857TRK collation, the lower case does not have the character as its upper case equivalent.
  • Page 344: Understanding The Locale Language

    Understanding locales • Which language to request from the database. For more information, see “Understanding the locale language” on page 324. • Character set The character set is the code page in use. The client and server both have character set values, and they may differ. If they differ, character set translation may be required to enable interoperability.
  • Page 345: Understanding The Locale Character Set

    CHAPTER 9 International Languages and Character Sets Language label values The following table shows the valid language label values, together with the equivalent ISO 639 labels: Alternative Language label label ISO_639 language code us_english english french german spanish japanese korean portuguese portugue chinese...
  • Page 346 Understanding locales For more information, see “Setting the SQLLOCALE environment variable” on page 328. Open Client applications check the locales.dat file in the Sybase locales directory is used. Character set information from the operating system is used to determine the locale: •...
  • Page 347 CHAPTER 9 International Languages and Character Sets Character set label IANA label Description macgrk2 <N/A> Macintosh Greek macturk <N/A> Macintosh Turkish greek8 <N/A> HP Greek-8 turkish8 <N/A> HP Turkish-8 koi8 <N/A> KOI-8 Cyrillic tis620 <N/A> TIS-620 Thai standard big5 <N/A> Traditional Chinese (cf.
  • Page 348: Understanding The Locale Collation Label

    Understanding collations Understanding the locale collation label Each database has its own collation. The database server determines the collation label as follows: It checks the SQLLOCALE environment variable, if it exists. For more information, see “Setting the SQLLOCALE environment variable” on page 328. It uses an internal table to find a collation label corresponding to the language and character set.
  • Page 349: Supplied Collations

    CHAPTER 9 International Languages and Character Sets • The collation (ASA_Label) • Case sensitivity (Case) • Blank padding (Blank Padding) if it was specified when the database was created. You can also see the collation of your current database by using the dbcollat utility to write the collation into a file: dbcollat -c "...
  • Page 350 Understanding collations Collation label Type Description 819SVE ANSI Code Page 819, Swedish/Finnish 819TRK ANSI Code Page 819, Turkish 850CYR Code Page 850, Cyrillic, Western 850DAN Code Page 850, Danish 850ELL Code Page 850, Greek 850ESP Code Page 850, Spanish 850ISL Code Page 850, Icelandic 850LATIN1 Code Page 850, Latin 1...
  • Page 351: Ansi Or Oem

    1252LATIN1 ANSI Code Page 1252, Windows Latin 1, Western SJIS Multibyte Japanese Shift-JIS Encoding SJIS2 Multibyte Japanese Shift-JIS Encoding, Sybase Adaptive Server Enterprise-compatible EUC_JAPAN Multibyte Japanese EUC JIS X 0208-1990 and JIS X 0212-1990 Encoding EUC_CHINA Multibyte Simplified Chinese GB 2312-80 Encoding...
  • Page 352: Notes On Ansi Collations

    OEM code page than the one on your machine, an incorrect translation will be applied. Both DBISQL and Sybase Central detect whether the database collation is ANSI or OEM by checking the first few characters, and either enable or disable translation as needed.
  • Page 353 CHAPTER 9 International Languages and Character Sets • The upper case and lower case Icelandic Eth (\xD0 and \xF0) is sorted with D in Adaptive Server IQ and Adaptive Server Anywhere, but after all other letters in Adaptive Server Enterprise. •...
  • Page 354: Notes On Oem Collations

    Understanding collations Notes on OEM collations The following table shows the built-in collations that correspond to OEM code pages. The table and the corresponding collations were derived from several manuals from IBM concerning National Language Support, subject to the restrictions mentioned above. (This table represents the best information available at the time of writing.
  • Page 355 CHAPTER 9 International Languages and Character Sets Primary Second- Code Primary ary Code Secondary Country Language Page Collation Page Collation English 437LATIN1 850LATIN1 Zealand Norway Norwegian 865NOR 850NOR Peru Spanish 850ESP 437ESP Poland Polish 852LATIN2 850LATIN2 Portugal Portuguese 850LATIN1 860LATIN1 Romania Romanian 852LATIN2...
  • Page 356: Using Multibyte Collations

    Understanding character set translation Using multibyte collations This section describes how multibyte character sets are handled. The description applies to the supported collations and to any multibyte custom collations you may create. Adaptive Server IQ provides collations using several multibyte character sets. For a complete listing, see “Understanding collations”...
  • Page 357 CHAPTER 9 International Languages and Character Sets Client application users may see messages from the database as well as data from the database. Some database messages, which are strings from the language library, may include placeholders that are filled by characters from the database.
  • Page 358: Connection Strings And Character Sets

    Understanding character set translation Connection strings and character sets Connection strings present a special case for character set translation. The connection string is parsed by the client library, in order to locate or start a database server. This parsing is done with no knowledge of the server character set or language.
  • Page 359: Collation Internals

    CHAPTER 9 International Languages and Character Sets • If the code page on your client machine operating system matches that used in the database, no character set translation is needed for data in the database. For example, in many environments it is appropriate to use the 1252LATIN1 collation in your database, which corresponds to the Windows NT code page in many single-byte environments.
  • Page 360: Comment Lines

    Collation internals Collation files may include the following elements: • Comment lines, which are ignored by the database. • A title line. • A collation sequence section. • An Encodings section. • A Properties section. Comment lines In the collation file, spaces are generally ignored. Comment lines start with either the percent sign ( or two dashes ( The title line...
  • Page 361: The Collation Sequence Section

    CHAPTER 9 International Languages and Character Sets The collation sequence section After the title line, each non-comment line describes one position in the collation. The ordering of the lines determines the sort ordering used by the database, and determines the result of comparisons. Characters on lines appearing higher in the file (closer to the beginning) sort before characters that appear later.
  • Page 362: The Encodings Section

    Collation internals : ’ ’ : \xF2 : \xEE : \xF0 : ’,’ : ’:’ % Sort some letters in alphabetical order : A a A : a a A : B b B : b b B % Sort some E’s from code page 850, % including some accented extended characters: : e e E, \x82 \x82 \x90, \x8A \x8A \xD4 : E e E, \x90 \x82 \x90, \xD4 \x8A \xD4...
  • Page 363: The Properties Section

    CHAPTER 9 International Languages and Character Sets The Encodings section lists which characters are lead-bytes, for multi-byte character sets, and what are valid follow-bytes. For example, the Shift-JIS Encodings section is as follows: Encodings: [\x00-\x80,\xa0-\xdf,\xf0-\xff] [\x81-\x9f,\xe0-\xef][\x40-\x7e,\x80-\xfc] The first line following the section title lists valid single-byte characters. The square brackets enclose a comma-separated list of ranges.
  • Page 364: International Language And Character Set Tasks

    International language and character set tasks International language and character set tasks This section groups together the tasks associated with international language and character set issues. Finding the default collation If you do not explicitly specify a collation when creating a database, a default collation is used.
  • Page 365: Determining Locale Information

    CHAPTER 9 International Languages and Character Sets For more information, see “Creating a database with a named collation” on page 346. When choosing the collation for your database, • Choose a collation that uses a character set and sort order appropriate for the data in the database.
  • Page 366: Setting Locales

    International language and character set tasks SELECT PROPERTY( ’DefaultCollation’ ) The query returns one of the collations listed in “Supplied collations” on page 329. Notes To obtain client locale information, connect to a database server running on your current machine. To obtain the character set for an individual database, execute the following statement: SELECT DB_PROPERTY ( ’CharSet’...
  • Page 367 The wizard has a Collation Sequence page where you choose a collation from a list. You can also see the name of your current collation in Sybase Central. Right- click on the database whose collation you need. In the dropdown menu select Properties, and then click the Extended Information tab.
  • Page 368: Starting A Database Server Using Character Set Translation

    International language and character set tasks CREATE DATABASE ’mydb.db’ COLLATION ’819ELL’ IQ SIZE 100 IQ PATH ’myiq.iq’ Starting a database server using character set translation Character set translation takes place if the client and server locales are different, but only if you specifically turn on character set conversion on the database server command line.
  • Page 369: Character Set Translation For Sybase Central And Dbisql

    Translator from the list of translation drivers. Character set translation for Sybase Central and DBISQL DBISQL and Sybase Central both employ internal OEM to ANSI code page translation if the database uses an OEM character set. As with the ODBC translation driver, there is an assumption that the OEM code page on the local machine matches the data in the database.
  • Page 370 International language and character set tasks You do this using the Collation utility. The output is a collation file. For example, the following statement extracts the 1252LATIN1 collation into a file named mycol.col: dbcollat -z 1252LATIN1 mycol.col Edit the custom collation file. Open the collation file (in this case mycol.col) in a text editor.
  • Page 371: Creating A Database With A Custom Collation

    For instructions on how to create custom collations, see “Creating a custom collation” on page 349. Create the new database. Use the statement or Sybase Central, specifying the CREATE DATABASE name of your custom collation. For example, the following statement creates a database named newcol.db...
  • Page 372: Performance Issues

    Performance issues With these options, uppercase characters precede all lowercase characters in the collation sequence. For example, ’XYZ’ sorts before ’abc’ with these options, just as it did in older versions of Adaptive Server IQ. Performance issues Performance for character data is better with a binary character set and collation sequence than with a non-binary one.
  • Page 373: Chapter 10 Managing User Ids And Permissions

    Among the reasons for using individual user IDs are the following: • The network server screen and the listing of connections in Sybase Central are both much more useful with individual user IDs, as you can tell which connections are which users.
  • Page 374: Dba Authority Overview

    An overview of database permissions DBA authority overview When a database is created, a single usable user ID is created. This first user ID is and the password is initially set to . The DBA user ID is automatically given DBA permissions, also called DBA authority, within the database.
  • Page 375: Resource Authority Overview

    CHAPTER 10 Managing User IDs and Permissions RESOURCE authority overview RESOURCE authority is the permission to create database objects, such as tables, views, and stored procedures. Resource authority may be granted only by the DBA to other users. Ownership permissions overview The creator of a database object becomes the owner of that object.
  • Page 376: Group Permissions Overview

    Using ASE stored The procedures in this chapter let you manage users and groups using DBISQL procedures to manage and Sybase Central. You can perform many of the same tasks using Adaptive users Server Enterprise-compatible stored procedures. If you have previously used Adaptive Server Enterprise or pre-Version 12.0 Adaptive Server IQ, you may...
  • Page 377: Creating New Users

    Click the Users and Groups folder for that database. Double-click Add User. A Wizard is displayed, which leads you through the process. For more information, see the Sybase Central online Help. Changing a password Changing a user’s If you have DBA authority, you can change the password of any existing user...
  • Page 378: Granting Dba And Resource Authority

    Managing individual user IDs and permissions GRANT CONNECT TO userid IDENTIFIED BY password The same command can also be used to add a new user. For this reason, if you inadvertently enter the user ID of an existing user when you mean to add a new user, you are actually changing the password of the existing user.
  • Page 379: Granting Permissions On Tables And Views

    CHAPTER 10 Managing User IDs and Permissions • You should give users with DBA authority two user IDs, one with DBA authority and one without, so that they connect as DBA only when necessary. • RESOURCE authority allows the user to create new database objects, such as tables, views, indexes, or procedures.
  • Page 380: Granting Users The Right To Grant Permissions

    Granting user One way to grant a user permissions on a table in Sybase Central is as follows: permissions on tables in Sybase Central To grant user permission on tables in Sybase Central Connect to the database.
  • Page 381: Granting Permissions On Procedures

    You can use procedures to allow users to carry out well- defined activities on a table, without having any general permissions on the table. Granting user One way to grant a user permissions on a table in Sybase Central is as follows: permissions on procedures in Sybase Central To grant user permissions on procedures in Sybase Central: Connect to the database.
  • Page 382: Revoking User Permissions

    Procedures folder. Click the procedure, and choose Edit Paste from the main menu to grant permissions. For more information, see the Sybase Central online Help. Revoking user permissions Any user’s permissions are a combination of those that have been granted and those that have been revoked.
  • Page 383: Managing Groups

    CHAPTER 10 Managing User IDs and Permissions sp_helptext sp_name_in_question Managing groups Once you understand how to manage permissions for individual users (as described in the previous section) working with groups is straightforward. A group is identified by a user ID, just like a single user, but this user ID is granted the permission to have members.
  • Page 384: Granting Group Membership To Users

    When users are assigned membership in a group, they inherit all the permissions on tables, views, and procedures associated with that group. Adding users to groups in Sybase Central To add a user to a group in Sybase Central: Connect to the database.
  • Page 385: Permissions Of Groups

    In the right panel, select the users you want to add to a group, and drag them to the group. For more information, see the Sybase Central online Help. Permissions of groups Permissions may be granted to groups in exactly the same way as to any other user ID.
  • Page 386: Groups Without Passwords

    Managing groups If a table is owned by the user ID, and if is a employees personnel M_Haneef member of the group, then can refer to the table personnel M_Haneef employees simply as in SQL statements. Users who are not members of the employees group need to use the qualified name personnel...
  • Page 387: Special Groups

    CHAPTER 10 Managing User IDs and Permissions Special groups When a database is created, two groups are also automatically created. These are SYS and PUBLIC. Neither of these groups has passwords, so it is not possible to connect to the database as either SYS or as PUBLIC. The two groups serve important functions in the database.
  • Page 388 Database object names and prefixes SELECT * FROM "DBA".employee The employee table reference is said to be qualified. (In this case the owner name is enclosed in double quotes, as DBA is a SQL keyword.) In other circumstances it is sufficient to give the object name. This section describes when you need to use the owner prefix to identify tables, view and procedures, and when you do not.
  • Page 389: Using Views And Procedures For Extra Security

    CHAPTER 10 Managing User IDs and Permissions SELECT * FROM company.customers To rectify the situation, make the group a member of the group. Sales company GRANT GROUP TO company; GRANT MEMBERSHIP IN GROUP company TO Sales; Now Joe and Sally, being members of the group, are indirectly members Sales of the...
  • Page 390: Using Views For Tailored Security

    Using views and procedures for extra security For information on how to create views, see “Working with views”. Using views for tailored security Views are computed tables that contain a selection of rows and columns from base tables. Views are useful for security when it is appropriate to give a user access to just one portion of a table.
  • Page 391: Using Procedures For Tailored Security

    CHAPTER 10 Managing User IDs and Permissions TO SalesManager Exactly the same command is used to grant permission on a view as to grant permission on a table. Example 2 The next example creates a view which allows the Sales Manager to look at a summary of sales orders.
  • Page 392: How User Permissions Are Assessed

    How user permissions are assessed Strict security For strict security, you can disallow all access to the underlying tables, and grant permissions to users or groups of users to execute certain stored procedures. With this approach, the manner in which data in the database can be modified is strictly defined.
  • Page 393 CHAPTER 10 Managing User IDs and Permissions For example, you may wish to prevent a single connection from taking too much of the available memory or CPU resources, so that one connection does not slow down other users of the database. Adaptive Server IQ provides a set of database options that the DBA can use to control resources.
  • Page 394: Users And Permissions In The System Tables

    Users and permissions in the system tables Sets the maximum size (in bytes) of that part of • JAVA_HEAP_SIZE the memory that is allocated to Java applications on a per connection basis. Limits the number of cursors for a • MAX_CURSOR_COUNT connection.
  • Page 395 CHAPTER 10 Managing User IDs and Permissions Table Default Contents SYSUSERPERM DBA only Database-level permissions and password for each user ID SYSGROUP PUBLIC One row for each member of each group SYSTABLEPERM PUBLIC All permissions on table given by the GRANT commands PUBLIC All columns with UPDATE SYSCOLPERM...
  • Page 396 Users and permissions in the system tables...
  • Page 397: Backup And Data Recovery

    Backup and Data Recovery C H A P T E R About this chapter This chapter explains how to back up your database, and how to recover data when necessary. It tells you why it is important to perform backups on regular basis, and gives recommendations for scheduling backups.
  • Page 398: Backing Up Your Database

    Backing up your database Backing up your database You use the command to back up your IQ database. Backup includes BACKUP both the Adaptive Server IQ data (the IQ Store) and the underlying Adaptive Server Anywhere database (the Catalog Store) Backup runs concurrently with read and write operations in the database.
  • Page 399 CHAPTER 11 Backup and Data Recovery A second automatic checkpoint occurs at the end of backup. Any data that is committed while the backup is in progress is included in any subsequent backups. However, if a failure occurs between the first and second checkpoints, any work that occurred after the first checkpoint cannot be restored.
  • Page 400: Selecting Archive Devices

    All disks on a RAID device are treated as a single device. Tape backup requirements If you regularly back up large databases, you should use DLT drives, if they are supported for your platform. In any case, Sybase recommends that you use multiple tape drives. Adaptive Server IQ...
  • Page 401: Preparing For Backup

    CHAPTER 11 Backup and Data Recovery • 4 mm DDS • 8 mm Adaptive Server IQ also allows Stacker drives with multiple tapes. Adaptive Server IQ does not support jukeboxes or robotic loaders. If BACKUP you need them, use a third party media manager. Adaptive Server IQ does not support fixed-length tape devices on BACKUP...
  • Page 402 Backing up your database Retaining old disk backups overwrites existing disk files of the same name. If you need to retain BACKUP a backup, when you create a new backup either use different file or path names for the archive devices, or move the old backup to another location before starting the backup.
  • Page 403: Concurrency And Backups

    For stacker devices that hold multiple tape drives, all tapes for a given device must be the same size. Sybase recommends that you always start a new tape for every backup. Before starting a backup to disk, Adaptive Server IQ first tests whether there is enough disk file space for the backup.
  • Page 404 Backing up your database ...TO ’ archive_device ’ [ SIZE #_of_KB ][STACKER #_of_drives_in_stack ] ... [ WITH COMMENT ’ string ’ ] If you need to back up an Adaptive Server Anywhere database, see the Note Adaptive Server IQ Reference Manual for additional options. Specifying operator presence controls whether or not human intervention is expected ATTENDED ON...
  • Page 405 For these reasons, Sybase recommends you use a non-rewinding tape device. See the operating system documentation for your platform for appropriate naming conventions.
  • Page 406 SIZE tape backups data on that stripe, in KB. If you use the Sybase–provided backup (as opposed to a third party backup product), you should specify for unattended tape backups on platforms SIZE that do not reliably detect the end-of-tape marker.
  • Page 407 SIZE disk backups data on that stripe, in KB. If you use the Sybase–provided backup, either attended or unattended, specify if you need a maximum size other than the default of 2GB. When you SIZE omit...
  • Page 408: Backup Examples

    Backing up your database Other backup options Specifying the block specifies the number of IQ blocks to write to the archive BLOCK FACTOR factor device at one time. It must be greater than 0, or returns an error BACKUP message. defaults to 25 on UNIX platforms.
  • Page 409: Recovery From Errors During Backup

    CHAPTER 11 Backup and Data Recovery TO ’/dev/rmt/0n’ TO ’/dev/rmt/1n’ WITH COMMENT ’Jan 18 full backup of asiquser’ The Catalog Store is backed up first, to /dev/rmt/0n. The IQ Store is backed up next, to both tapes. Example 2 — To make an incremental backup of the same database, this time using only one Incremental backup tape device, issue the command as follows:...
  • Page 410: After You Complete A Backup

    See “Recording dbspace names” for details on how to record this information after you complete a backup. Performing backups with non-Sybase products Adaptive Server IQ supports backup and restore using a number of third-party products. The package you use must conform to the Adaptive Server Enterprise Backup Interface.
  • Page 411: Performing System-Level Backups

    CHAPTER 11 Backup and Data Recovery The backup program passes vendor information to the third-party program automatically. When you request a third-party backup, it places this information in the backup header file, and writes the header file on the first tape or disk file actually created for each archive_device you specify.
  • Page 412: Backing Up The Right Files

    Performing system-level backups Backing up the right files Required files You must back up the following files: • SYSTEM dbspace file, typically named dbname.db. • The transaction log file, which is required for system recovery, typically named dbname.log • The IQ_SYSTEM_MAIN dbspace file, typically named dbname.iq •...
  • Page 413: Validating Your Database

    CHAPTER 11 Backup and Data Recovery Ensuring that all files Before restoring, review the table of contents of the backup to ensure that all exist files required for IQ are present. The list of files depends on your application. See the discussion of required and optional files in “Backing up the right files” on page 392.
  • Page 414: Interpreting Results

    Validating your database Interpreting results The procedure produces a very long list of statistics about your database. Statistics are listed first for the Main IQ Store, then for Temporary Store. For each store, you see three types of statistics: • Dynamic statistics.
  • Page 415: Concurrency Issues For Sp_Iqcheckdb

    CHAPTER 11 Backup and Data Recovery Figure 11-1: sp_iqcheckdb results Concurrency issues for sp_iqcheckdb When you run , it reads every database page in use. This sp_iqcheckdb procedure consumes most of the database server’s time, so that the I/O is as efficient as possible.
  • Page 416: Restoring Your Databases

    • You must restore the database to the appropriate server, and that server must have the archive devices you need. When you use the Sybase- provided restore, you need the same number of archive devices (that is, the disk files or tape drives) as when the backup was created.
  • Page 417 CHAPTER 11 Backup and Data Recovery • For a full restore, the Catalog Store (by default the .db file) and the transaction log (by default the .log file) must not exist in the location you are restoring to. If either of these files exists, you must delete it or move it to a different directory before doing the full restore.
  • Page 418 When restoring from tape, you must position the tape to the start of the IQ data. does not reposition the tape for you. RESTORE When you restore using the Sybase-provided backup and restore, you must use the same number of tape drives for the restore as were used to create the backup(s) you are restoring.
  • Page 419: The Restore Statement

    CHAPTER 11 Backup and Data Recovery Database has changed since the last restore Note Adaptive Server IQ does not let you do an incremental restore if the database has changed since the previous restore. However, it does not prevent users from making changes. It is the responsibility of the DBA or system operator to ensure that no changes are made to the database until all restores are complete.
  • Page 420 Restoring your databases Just as for backup, each archive_device specifies the API (Sybase or third party) and, for the Sybase API, the physical tape device or disk file name from which you are restoring. For third-party APIs, the content of the archive_device string depends on your vendor.
  • Page 421 CHAPTER 11 Backup and Data Recovery • To move any other database file, you use the option. RENAME Note utility is not supported by Adaptive Server IQ because it DBTRAN regenerates only those parts of the transaction log that are specific to Adaptive Server Anywhere.
  • Page 422 Restoring your databases Relative pathnames in the clause work as they do when you create a RENAME database or dbspace: the main IQ Store dbspace, Temporary Store dbspaces, and Message Log are restored relative to the location of db_file (the Catalog Store);...
  • Page 423: Restoring In The Correct Order

    CHAPTER 11 Backup and Data Recovery RENAME IQ_SYSTEM_MSG TO ’asiquser.iqmsg’ RENAME IQ_USER TO ’/dev/rdsk/c1t5d2s1’ You could also issue these commands with only the last clause, Note RENAME since only one dbspace is being restored to a new location. Listing all of the files or raw partitions, as shown here, ensures that you know exactly where each will be restored.
  • Page 424 Restoring your databases To determine the correct order, you need the information about backup files that is stored in the backup log. See “Getting information about backups and restores” for the content and location of this file. Restore backups as follows: •...
  • Page 425: Renaming The Transaction Log After You Restore

    CHAPTER 11 Backup and Data Recovery Tapes B and B . These must be restored as a set, after Set A, and either Set B before or after Set C. They can be in either the second or third device. Tapes C , and C .
  • Page 426: Validating The Database After You Restore

    Restoring your databases Description The DBLOG command line utility allows you to display or change the name of the transaction log or transaction log mirror associated with a database. You can also stop a database from maintaining a transaction log or mirror, or start maintaining a transaction log or mirror.
  • Page 427: Displaying Header Information

    CHAPTER 11 Backup and Data Recovery In an IQ Multiplex, you must restore on the write server in simplex mode, and synchronize the query server following the completion of the restore. For more information on multiplex restores, see Adaptive Server IQ Multiplex User’s Guide.
  • Page 428: Recovery From Errors During Restore

    If you use symbolic links, you may unknowingly cause dbspaces to be created in a different directory from where you may want them to be. For example, suppose you have created dbspaces in the following files: -rw-r--r-- 1 dkusner sybase 122880000 Feb 26 18:27 asiqdemo.db -rw-r--r-- 1 dkusner sybase 122880000 Feb 26 18:27 asiqdemo.iq1...
  • Page 429: Unattended Backup

    CHAPTER 11 Backup and Data Recovery When you back up the files and restore them with the option, CATALOG ONLY you don’t see anything telling you that these files were links; in fact, this information is not saved. Adaptive Server IQ saves these files as though they were actually present in the directory where the symbolic links reside.
  • Page 430: Getting Information About Backups And Restores

    Getting information about backups and restores If you are using a third-party backup product, the vendor information string needs to convey any information needed for the backup, such as the specification of devices, size of files, and stacker drives. See your vendor’s documentation for details.
  • Page 431: Content Of The Backup Log

    CHAPTER 11 Backup and Data Recovery • On Windows NT, the server tries to place it in the following locations, in this order: • The directory specified by the ASLOGDIR environment variable. • The directory that holds the server executable files. Content of the backup log For every backup or restore you perform, the backup log contains the following fields, separated by commas:...
  • Page 432: Maintaining The Backup Log

    Viewing the backup log in Sybase Central The backup log contains information in raw, unsorted form. To see the information in a form that is easier to understand, you can view it in Sybase Central. This feature is not yet supported.
  • Page 433: Determining Your Data Backup And Recovery Strategy

    CHAPTER 11 Backup and Data Recovery Keep the results of this query some place other than the disk where the database resides, so that you will have a complete list of dbspace names if you need them. You can also run the following script in DBISQL. This script produces an output file that contains the set of rename clauses you would use if you did not actually change the location of any files.
  • Page 434: Scheduling Routine Backups

    Determining your data backup and recovery strategy Scheduling routine backups Make a full backup of each database just after you create it, to provide a base point, and perform full and incremental backups on a fixed schedule thereafter. It is especially important to back up your database after any large number of changes.
  • Page 435: Designating Backup And Restore Responsibilities

    CHAPTER 11 Backup and Data Recovery For example, once you have a full backup of your database, in theory you could perform only incremental backups thereafter. You would not want to do this, however, because any future recovery would be intolerably slow, and would require more tape or disk space than doing a full backup periodically.
  • Page 436 Determining your data backup and recovery strategy Eliminating data verification You can also improve the speed of backup and restore operations by setting in the command. This setting deactivates cyclical CRC OFF BACKUP redundancy checking. With , numbers computed on backup are CRC ON verified during any subsequent restore operation, affecting performance of both commands.
  • Page 437 CHAPTER 11 Backup and Data Recovery Controlling the size of the Catalog Store An IQ database consists of an IQ Store and an underlying Catalog Store. makes a full backup of the Catalog Store at the start of every backup, BACKUP both full and incremental.
  • Page 438 Determining your data backup and recovery strategy...
  • Page 439: Chapter 12 Managing System Resources

    Managing System Resources C H A P T E R About this chapter This chapter describes the way Adaptive Server IQ uses memory, disk I/O, and CPUs, and the relationships among these factors. It also explains how the DBA can tune performance by adjusting resource usage. The suggestions in this chapter are generic.
  • Page 440: Overview Of Memory Use

    Overview of memory use Other considerations, such as hardware and network analysis, can locate bottlenecks in your installation. Overview of memory use Adaptive Server IQ uses memory for several purposes: • Buffers for data read from disk to resolve queries •...
  • Page 441: Utilities To Monitor Swapping

    CHAPTER 12 Managing System Resources To make the maximum use of your physical memory, Adaptive Server IQ uses buffer caches for all reads and writes to your databases. Utilities to monitor swapping You can use the UNIX command, the UNIX command, or the vmstat Windows NT Task Manager, to get statistics on the number of running...
  • Page 442: Managing Buffer Caches

    Overview of memory use Killing processes Killing processes on UNIX systems may result in semaphores or Warning! affects shared shared memory being left behind instead of being cleaned up automatically. memory The correct way to shut down an IQ server on UNIX is the utility, stop_asiq described in “Stopping the database server”...
  • Page 443 CHAPTER 12 Managing System Resources Figure 12-1: Buffer caches in relation to physical memory The following sections describe each part in more detail and provide guidelines to help you determine how much memory each part requires. Operating system and other applications This amount will vary for different platforms and how the system is used.
  • Page 444 Overview of memory use Raw partitions versus file systems For UNIX systems, databases using “cooked” file systems rather than raw partitions may require another 30% of the remaining memory to handle file buffering by the operating system. Windows NT file systems do not have the same overhead as UNIX file systems.
  • Page 445 CHAPTER 12 Managing System Resources Adaptive Server IQ main and temp buffer caches After determining how much overhead memory Adaptive Server IQ needs, you must decide how to split what’s left between your main IQ and temp buffer caches. The dashed line dividing the two areas in Figure 12-1 indicates that this split may change from one database to another based on several factors.
  • Page 446 Overview of memory use Other considerations Adaptive Server IQ buffer cache sizes may differ from one database to the next based on how you use it. For maximum performance, you need to change the settings between inserting, querying the database, and mixed use. In a mixed- use environment, however, it is not always feasible to require all users to exit the database so that you can reset buffer cache options.
  • Page 447: Setting Buffer Cache Sizes

    CHAPTER 12 Managing System Resources Memory available Memory available using "cooked" file using raw partitions systems Amount Memory Use Used Queries Inserts Queries Inserts Memory remaining for the main and temp buffer caches Main_Cache_Memory_Mb setting: 60% of memory remaining for buffer caches Temp_Cache_Memory_Mb setting: 40% of memory remaining for...
  • Page 448 Overview of memory use How long the setting is For more Method When to use it effective information, see server Reset cache sizes when From the time the server is “Setting buffer cache -iqmc -iqtc switches the database is not started until it is stopped size server switches”...
  • Page 449: Specifying Page Size

    CHAPTER 12 Managing System Resources Make sure all users are disconnected from the database, and stop the database. • If the command-line switch is set, the database shuts down automatically after the last user disconnects. • is not set, stop the database, by using the utility on stop_asiq UNIX, or by clicking Shutdown on the database server display on...
  • Page 450 Overview of memory use Because the Catalog Store accounts for only a tiny fraction of I/O, the page size for the Catalog Store has no real impact on performance. The default value of 4096 bytes should be adequate. The IQ page size determines two other performance factors, the default I/O transfer block size, and the maximum data compression for your database.
  • Page 451: Saving Memory

    CHAPTER 12 Managing System Resources Table 12-3: Default block sizes Page Size (KB) Block Size (bytes) 4096 8192 16384 32768 Data compression Adaptive Server IQ compresses all data when storing it on disk. Data compression both reduces disk space requirements and contributes to performance.
  • Page 452: Optimizing For Large Numbers Of Users

    Overview of memory use Use the following guideline to determine BLOCK FACTOR record size * BLOCK FACTOR = memory required You need extra memory for this option, in addition to the memory for the buffers. If you have a lot of memory available, or if no other users are active concurrently, increasing the value of can improve load BLOCK FACTOR...
  • Page 453 Solaris Although the Solaris thread limit is not a problem, developers and Sybase field personnel should be aware that using the Solaris debugger on IQ requires a file descriptor for each thread in addition to the file descriptors for each dbspace.
  • Page 454: Platform-Specific Memory Options

    Since this count is on a per user basis (not a per process basis) this number must be high enough to allow for all threads of all processes running under the Sybase user ID. Platform-specific memory options On all platforms, Adaptive Server IQ uses memory for four primary purposes: •...
  • Page 455 CHAPTER 12 Managing System Resources Table 12-4: Total available memory by platform Platform Total memory available CompaqTru64 (Digital UNIX) Effectively unlimited HP UNIX IBM RS6000 AIX SGI IRIX Effectively unlimited Sun Solaris 32-bit 3.3GB Sun Solaris 64-bit Effectively unlimited Windows NT 2.5GB You must specify the option to get this much memory on HP UNIX and...
  • Page 456 Overview of memory use Unwired memory pool On AIX, Tru64 (Digital UNIX), and HP UNIX systems, you can create an unwired (swappable) memory pool to increase total available memory. Unwired memory can be paged. To create the unwired memory pool, use the command-line switch.
  • Page 457 CHAPTER 12 Managing System Resources Managing large buffer caches on HP On HP UNIX, sets to 500 by default. This setting allows a start_asiq -iqsmem total buffer cache size (i.e., main and temp caches combined) of 2GB. If you need more than 2GB for buffer caches, and your system can accommodate a larger value, you must add unwired memory, by specifying .
  • Page 458: Other Ways To Get More Memory

    Overview of memory use • On Solaris systems with more than 4GB of memory, the file system buffer cache competes with IQ's buffer cache less, so you may decrease performance by turning off file system buffering. • On NT systems, under certain loads and configurations, disabling the file system buffer cache can likely improve performance.
  • Page 459: The Process Threading Model

    CHAPTER 12 Managing System Resources option of the command sets the JAVA_NAMESPACE_SIZE SET OPTION maximum size (in bytes) of that part of the memory that is allocated to Java applications on a per database basis. Per database memory allocations include Java class definitions.
  • Page 460: Insufficient Threads Error

    The process threading model Figure 12-2: Multithreaded architecture Multiple threads improve performance. Even a single-CPU machine gets better performance by using threads. Insufficient threads error When you do not have enough server threads to initiate the query you have issued, you get the error: Not enough server threads available for this query This condition may well be temporary.
  • Page 461: Balancing I/O

    CHAPTER 12 Managing System Resources • To set the maximum number of threads a single user will use, issue the command . This SET OPTION MAX_IQ_THREADS_PER_CONNECTION can be used to control the amount of memory a particular operation consumes. For example, the DBA can set this option before issuing an command.
  • Page 462: Using Disk Striping

    Balancing I/O Using disk striping Traditional file management systems allow you to locate individual files on specific disks. Consequently, all file operations occur against a single disk drive. Some operating systems allow you to create logical devices or volumes that span multiple disk drives. Once a file fills the first disk drive, it is automatically continued onto the next drive in the logical volume.
  • Page 463: Internal Striping

    CHAPTER 12 Managing System Resources Recommendations for disk striping Here are some general rules on disk striping: • For maximum performance, the individual disks in a striped file system should be spread out across several disk controllers. But be careful not to saturate a disk controller with too many disks.
  • Page 464 Balancing I/O Disk striping option This section explains how you can use the option Adaptive Server IQ provides to do disk striping, without using third party software. If you already have a disk striping solution through third party software and hardware, you should use it instead.
  • Page 465: Using Multiple Dbspaces

    CHAPTER 12 Managing System Resources Figure 12-3: Internal disk striping The example above shows disk drive A has two 2GB partitions (a and b) and two 500MB (or .5GB) partitions (c and d). There are three other 1GB disk drives (E, F, and G). You should create your database on partition a, then add dbspaces for E, c, F, b, G and d.
  • Page 466: Strategic File Locations

    Balancing I/O To move or rename the transaction log file, use the Transaction Log utility ). For syntax and details, see “The DBLOG command-line utility” on DBLOG page 405. The Adaptive Server IQ transaction log file is different than most Warning! relational database transaction log files.
  • Page 467: Working Space For Inserting, Deleting, And Synchronizing

    CHAPTER 12 Managing System Resources Figure 12-4: Avoid I/O contention The figure above illustrates how you want to spread access across separate disks to avoid I/O contention. To avoid disk bottlenecks, follow these suggestions: • Keep random disk I/O away from sequential disk I/O. •...
  • Page 468: Options For Tuning Resource Use

    Options for tuning resource use Ordinarily, as long as you maintain a reasonable percentage of free space in your IQ Store, you will have enough free space. However, for certain deletions, depending on the size of the data and its distribution among database pages, you may need a large amount of working space.
  • Page 469: Limiting A Query's Memory Use

    CHAPTER 12 Managing System Resources Limiting a query’s memory use option of the command lets you QUERY_TEMP_SPACE_LIMIT restrict the amount of memory available to any one query. By default, a query can use 1000MB of memory. When you issue a query, Adaptive Server IQ estimates the temporary space needed to resolve the query.
  • Page 470: Limiting The Number Of Cursors

    Adaptive Server IQ for use in prefetching (the read ahead of database pages). This option has a default value of 20, which can degrade multi-user performance. Sybase recommends that you set this option to 0 for multi-user applications. For more information, see the Adaptive Server IQ...
  • Page 471: Optimizing For Typical Usage

    This option should only be set after careful analysis shows it is actually required. Contact Sybase Technical Support with details if you need to set this option. Other ways to improve resource use This section describes several ways to adjust your system for maximum performance or better use of disk space.
  • Page 472: Using Ram Disk

    Indexing tips Operating systems use two different methods to allocate memory to disk cache: fixed and dynamic. A preset amount of memory is used in a fixed allocation; usually a 10–15 percent memory allocation is set aside. The operating system usually manages this workspace using a LRU (least recently used) algorithm.
  • Page 473: Using Join Indexes

    CHAPTER 12 Managing System Resources You should create either an index in addition to the default index on each column referenced by the clause in a join query. Adaptive Server WHERE IQ cannot guarantee that its query optimizer will produce the best execution plan if some columns referenced in the clause lack either an WHERE...
  • Page 474: Managing Database Size And Structure

    Managing database size and structure Managing database size and structure This section offers ideas on improving your database design and managing your data. Managing the size of your database The size of your database depends largely on the indexes you create, and the quantity of data you maintain.
  • Page 475: Denormalization Has Risks

    CHAPTER 12 Managing System Resources Denormalization has risks Denormalization can be successfully performed only with thorough knowledge of the application and should be performed only if performance issues indicate that it is needed. One of the things to consider when you denormalize is the amount of effort it will then take to keep your data up-to-date with changes.
  • Page 476: Deciding To Denormalize

    Improving your queries Deciding to denormalize When deciding whether to denormalize, you need to analyze the data access requirements of the applications in your environment and their actual performance characteristics. Some of the issues to examine when considering denormalization include: •...
  • Page 477: Planning Queries

    CHAPTER 12 Managing System Resources • Join indexes typically cause join queries to execute faster than ad hoc joins, at the expense of using more disk space. However, when a join query does not reference the largest table in a multi-table join index, an ad hoc join usually outperforms the join index.
  • Page 478: Setting Query Optimization Options

    Improving your queries • This option controls the collection of timing statistics QUERY_TIMING on subqueries and some other repetitive functions in the query engine. Normally it should be because for very short correlated subqueries the cost of timing every subquery execution can be very expensive in terms of performance.
  • Page 479: Network Performance

    CHAPTER 12 Managing System Resources • Sets the maximum estimated number of JOIN_MAX_HASH_ROWS rows the query optimizer will consider for a hash algorithm. The default is 125,000 rows. For example, if there is a join between two tables, and the estimated number of rows entering the join from both tables exceeds this option value, the optimizer will not consider a hash join.
  • Page 480: Isolate Heavy Network Users

    Network performance • If large transfers are common, consider installing better network hardware that is suitable for such transfers. For example: • Token ring–responds better during heavy utilization periods than ethernet hardware. • Fiber optic–provides very high bandwidth, but is usually too expensive to use throughout the entire network.
  • Page 481: Put Small Amounts Of Data In Small Packets

    CHAPTER 12 Managing System Resources Figure 12-5: Isolating heavy network users Put small amounts of data in small packets If you send small amounts of data over the network, keep the default network packet size small (default is 512 bytes). The server startup option lets you specify a maximum packet size.
  • Page 482: Put Large Amounts Of Data In Large Packets

    Network performance Figure 12-6: Small data transfers and small packet sizes Put large amounts of data in large packets If most of your applications send and receive large amounts of data, increase default network packet size. This will result in fewer (but larger) transfers. Figure 12-7: Large data transfers and larger packet sizes...
  • Page 483: Process At The Server Level

    CHAPTER 12 Managing System Resources Process at the server level Filter as much data as possible at the server level. Figure 12-8: Work at the server level...
  • Page 484 Network performance...
  • Page 485: Monitoring And Tuning Performance

    Monitoring and Tuning C H A P T E R Performance About this chapter This chapter describes tools you use to monitor Adaptive Server IQ performance. Use these tools to determine whether your system is making optimal use of available resources. To understand how Adaptive Server IQ uses memory, process threads, and disk, and to learn about options you can set to control resource use, see Chapter 12, “Managing System Resources”...
  • Page 486 Example The output from looks like the following: sp_iqstatus Name Value ======================================================= =================== Adaptive Server IQ (TM) Copyright (c) 1992-2000 by Sybase, Inc. All rights reserved. Version: 12.4.2/(32bit mode)/Sun_svr4/OS 5.6/EBF 0000 Time Now: 2000-03-14 12:05:54.288 Build Time: Sat Mar 11, 2000...
  • Page 487: Monitoring The Buffer Caches

    CHAPTER 13 Monitoring and Tuning Performance Block#: 95065709 Temporary IQ Blocks Used: 610 of 17646576, 0%=4Mb, Max Block#: 0 Main Reserved Blocks Available: 1280 of 1280, 100%=10Mb Temporary Reserved Blocks Available: 1280 of 1280, 100%=10Mb Memory: Current: 3351mb, Max: 3384mb Main IQ Buffers: Used: 11172, Locked: 0 Temporary IQ Buffers:...
  • Page 488 Monitoring the buffer caches starts monitoring of the temp buffer cache, for the Temporary Store PRIVATE of the database you are connected to. You need to issue a separate command to monitor each buffer cache. dummy_table_name can be any IQ table. However, it’s a good idea to create a table that you use only for monitoring.
  • Page 489 -cache_by_type -cache IQ page type. (An exception is the Bwaits column, which shows a total only.) This format is most useful when you need to supply information to Sybase Technical Support. • suffix creates a monitor output file named -file_suffix .
  • Page 490 Monitoring the buffer caches • AvPF: Number of currently available buffers for prefetch quota allocation • Slots: Number of currently registered objects using buffer cache quota • PinUser: Number of objects using pin quota • PFUsr: Number of objects using prefetch quota •...
  • Page 491 CHAPTER 13 Monitoring and Tuning Performance • FLWait: Number of times IQ had to wait for the lock on the free list (repeated for the temp cache) • MemLks: Number of times IQ took the memory manager (heap) lock • MemWts: Number of times IQ had to wait for the memory manager lock •...
  • Page 492: Stopping The Buffer Cache Monitor

    Monitoring the buffer caches • is used mainly to supply information to Sybase Technical Support. -debug It displays all the information available to the performance monitor, whether or not there is a standard display mode that covers the same information. The top of the page is an array of statistics broken down by disk block type.
  • Page 493: Examples Of Monitor Results

    CHAPTER 13 Monitoring and Tuning Performance When you run the monitor again from the same database and connection number, by default it overwrites the previous results. If you need to save the results of a monitor run, copy the file to another location before starting the monitor again from the same database or use the option.
  • Page 494 Monitoring the buffer caches Finds Creats Dests Dirty HR% BWaits ReReads FMiss Cloned Reads/ GDirty Pin% Dirty% Writes PFRead 84 99.4 Tm: 1139 109 100.0 Tm: 6794 754 100.0 Tm: 10759 1646 1646 1646 100.0 Example of -io option option produces results like the following, which are for the main buffer cache: Options string for main cache: "-IO -interval 5"...
  • Page 495 CHAPTER 13 Monitoring and Tuning Performance Example of The actual output shows Main Cache, Temp Cache, and Note -contention -contention option Memory Manager on the same line. Because this format is very wide, each of these sets of columns is shown separately here. results for the main cache are: -contention Options string for Main cache:...
  • Page 496: Avoiding Buffer Manager Thrashing

    Avoiding buffer manager thrashing Example of -threads The results of the option look like the following: -threads option Options string for Main cache: "-threads -file_suffix threads-iqmon -append -interval 10" Threads 2000-01-24 10:59:24 CPUs Limit NTeams MaxTms NThrds Resrvd Free Locks Waits Avoiding buffer manager thrashing Operating system paging affects queries that need buffers which exceed the free memory available.
  • Page 497: Monitoring Paging On Windows Nt Systems

    CHAPTER 13 Monitoring and Tuning Performance Buffer manager thrashing occurs when the operating system chooses less optimum buffers to page out to disk, which forces the buffer manager to make extra reads from disk to bring those buffers back to memory. Since Adaptive Server IQ knows which buffers are the best candidates to flush out to disk, you want to avoid this operating system interference by reducing the overall number of page outs.
  • Page 498 Avoiding buffer manager thrashing 0 0 0 3312376 31840 0 0 297 201 472 82 4 14 0 0 0 3312376 31484 2 0 260 169 597 80 3 17 0 0 0 3312368 31116 0 0 205 1202 396 67 4 29 The above output shows a steady Adaptive Server IQ querying state where the physical memory of the machine has not been overallocated.
  • Page 499: System Utilities To Monitor Cpu Use

    CHAPTER 13 Monitoring and Tuning Performance 19 0 0 3246612 26748 273 1248 0 394 1180 92 The above output is from slightly later when the query is underway. This is evident from the user mode CPU level (us field). The buffer cache is not yet full as page-in faults (pi field or KB paged in) are still occurring and the amount of free memory is still going down.
  • Page 500 System utilities to monitor CPU use...
  • Page 501: Chapter 14 Adaptive Server Iq As A Data Server

    If you simply wish to use a Sybase application or a third-party client application with Adaptive Server IQ, you do not need to know any details of connectivity interfaces or network protocols. However, an understanding of how these pieces fit together may be helpful for configuring your database and setting up applications.
  • Page 502 TDS applications, because the Open Client libraries handle the TDS interface. However, some applications (such as Sybase jConnect) are TDS applications even though they do not use the Sybase Open Client libraries (they communicate directly to the TDS layer).
  • Page 503: Configuring Iq Servers With Dsedit

    TDS of their own. Sybase Adaptive Server Enterprise and Adaptive Server IQ both have internal TDS interfaces. They appear to client applications as an Open Server, but do not use the Sybase Open Server libraries.
  • Page 504 Sybase products. Starting DSEDIT The dsedit executable is held in the SYBASE\bin directory, which is added to your path on installation. You can start DSEDIT either from the command line or (Windows NT only) by double-clicking dsedit.exe from the Windows Explorer When you start DSEDIT, the Select Directory Service window appears.
  • Page 505 The DSEDIT utility uses the SYBASE environment variable to locate Note the libtcl.cfg file. If the SYBASE environment variable is not set correctly, DSEDIT cannot locate the libtcl.cfg file. You can add, modify, or delete entries for servers, including Adaptive Server IQ servers, in this window.
  • Page 506 Client/server interfaces to Adaptive Server IQ Select the Server Address in the Attributes box. Double-click on the Server Address or right click and choose Modify Attribute from the popup menu. The Network Address Attribute window appears, showing the current value of the address. If you have no address entered, the box will be empty.
  • Page 507 CHAPTER 14 Adaptive Server IQ as a Data Server to identify the current machine. Port Number The port number you enter must match the port specified on the Adaptive Server IQ database server command line, as described in “Starting the database server as an Open Server”.
  • Page 508: Sybase Applications And Adaptive Server Iq

    Choose Delete from the Server Object menu. Sybase applications and Adaptive Server IQ The ability of Adaptive Server IQ to act as an Open Server enables Sybase applications such as OmniConnect to work with Adaptive Server IQ. Note that, in order to use the Open Client libraries, the client application must use only the supported system tables, views and stored procedures.
  • Page 509: Setting Up Adaptive Server Iq As An Open Server

    • To connect to Adaptive Server IQ 11.x, use server class asiq Client-side In order to use Sybase client applications to connect to an Open Server, requirements including Adaptive Server IQ, you need the following: • Open Client components—The Open Client libraries provide the network libraries that your application needs to communicate via TDS.
  • Page 510: Configuring Your Database For Use With Open Client

    Setting up Adaptive Server IQ as an Open Server asiqdemo.db On UNIX, you can use the utility in place of start_asiq asiqsrv12 The first command line uses both TCP/IP and IPX protocols, of which TCP/IP is available for use by Open Client applications. The second line uses only TCP/IP.
  • Page 511: Characteristics Of Open Client And Jconnect Connections

    CHAPTER 14 Adaptive Server IQ as a Data Server Characteristics of Open Client and jConnect connections When Adaptive Server IQ is serving applications over TDS, it automatically sets relevant database options to values that are compatible with Adaptive Server Enterprise default behavior. These options are set temporarily, for the duration of the connection only.
  • Page 512 Characteristics of Open Client and jConnect connections SET TEMPORARY OPTION DATE_FORMAT=’YYYY-MM-DD’; SET TEMPORARY OPTION TIMESTAMP_FORMAT=’YYYY-MM-DD HH:NN:SS.SSS’; SET TEMPORARY OPTION TIME_FORMAT=’HH:NN:SS.SSS’; SET TEMPORARY OPTION DATE_ORDER=’MDY’; SET TEMPORARY OPTION ESCAPE_CHARACTER=’OFF’ Note Do not edit the procedure yourself. It is for system sp_tsql_environment use only.
  • Page 513: Servers With Multiple Databases

    CHAPTER 14 Adaptive Server IQ as a Data Server Servers with multiple databases Using Open Client Library, you can now connect to a specific database on a server with multiple databases. • Set up entries in the interfaces file for each server. •...
  • Page 514 Characteristics of Open Client and jConnect connections...
  • Page 515: Index

    Index Symbols conversion option data format & ASCII character set UNIX command line about ASCII character sets about asiqdemo database ASTMP environment variable Access disk space ODBC configuration for atomic compound statements ad hoc joins Autocommit performance ODBC configuration Adaptive Server Enterprise AUTOMATIC_TIMESTAMP option inserting from Open Client...
  • Page 516 Index recovering from errors responsibilities switch scheduling cache specifying tape devices on NT See Also buffer cache third party writing to unattended 382, 409 cache pages wait time prefetching base tables cache size batches setting for Catalog Store about 229, 238 CALL statement control statements about...
  • Page 517 315, 317 multibyte fixed width Interactive SQL WIN_LATIN1 multibyte 321, 336 column delimiters single-byte load format option Sybase Central LOAD TABLE statement translation column names Unicode international aspects variable width column set to during load Windows column width characters...
  • Page 518 Index backups 291, 383 troubleshooting data definition using data source in Adaptive Server IQ constraints insertions, deletions, and queries effect on performance read and write CONTINUE_AFTER_RAISERROR option configuration files Open Client using control statements configuring list ODBC data sources conversion options CONN connection parameter DATE about...
  • Page 519 Index limiting number of character ODBC configuration conversion during loading on SELECT statements converting procedures converting between Adaptive Server Enterprise and custom collations Adaptive Server IQ about creating with sp_addtype creating dropping user-defined creating databases FLOAT integer matching Adaptive Server IQ and Adaptive Server Enterprise money REAL...
  • Page 520 Index about DatabaseSwitches connection parameter DatabaseName connection parameter about about DataSourceName connection parameter databases about Adaptive Server Anywhere DATE Adaptive Server IQ data conversion option benefits of denormalizing load conversion option block size DATE data type character set specifying format for conversion checking consistency date data types choosing a location...
  • Page 521 Index about saving DBLOG utility disk striping DBN connection parameter Adaptive Server IQ about definition DBS connection parameter internal about rules dbspaces use in loads creating DLLs definition calling from procedures dropping discouraged DML (Data Manipulation Language) estimating space requirements DMRF connection parameter locating for best performance about...
  • Page 522 Index ODBC configuration EncryptedPassword connection parameter failures about media encryption system network packets FETCH statement Encryption connection parameter procedures about file data source name ENG connection parameter See FileDSN about FileDataSourceName connection parameter EngineName connection parameter See FileDSN about FileDSN ENP connection parameter connection parameter 63, 73...
  • Page 523 Adaptive Server Enterprise dropping LOAD TABLE statement managing in LOAD TABLE membership index types permissions 356, 365 about PUBLIC choosing for performance Sybase Central criteria for choosing without passwords recommendations selecting INDEX_PREFERENCE option Indexes parallel creation indexes HG index about advantages...
  • Page 524 Index creating in Sybase Central constraints 275, 276 disk space usage overview displaying size Interactive SQL dropping command delimiter in system tables See Also DBISQL introduction window problems listing interface libraries parallel creation connections selecting an index type interfaces file...
  • Page 525 ODBC configuration columns in tables LF index creating additional indexes creating in Sybase Central advantages estimating size comparison to other indexes estimating space requirements disadvantages inserting into recommended use join hierarchy libctl.cfg file...
  • Page 526 Index local temporary tables paging about reducing requirements locale requirements for loads character sets restricting use by queries language See Also buffer caches locales unwired about wired setting memory message localhost load notification messages machine name message log locking Adaptive Server IQ tables MESSAGE statement LOG connection parameter...
  • Page 527 Index data sources ODBC data sources named pipes configuring national language support UNIX about ODBC translation driver collations ODBC configuration multibyte character sets OEM code pages overview 315, 317 about natural joins choosing NEAREST_CENTURY option OmniConnect network communications support troubleshooting startup ON clause joins network protocol ON EXCEPTION RESUME clause...
  • Page 528 Parallel CREATE INDEX granting passwords partial-width insertions group about group membership rules groups 356, 365 START ROW ID option in Sybase Central 360, 361 partial-width inserts individual examples inheriting 360, 363 partitions INSERT and DELETE, on views definition listing...
  • Page 529 Index LOAD TABLE statement variable result sets from primary keys verifying input creating warnings entity integrity writing inserting data process threading model order of columns protocols retrieving information switch unenforced multi-column ps command priority monitoring CPUs on UNIX lowering PUBLIC group privileges PWD connection parameter defining database objects...
  • Page 530 Index memory use about RAWDETECT ROLLBACK statement disk striping option compound statements REAL data type procedures matching Adaptive Server Enterprise and Adaptive ROLLBACK TO SAVEPOINT statement Server IQ data ROW DELIMITED BY option recovery LOAD TABLE statement system row id transaction log in displaying transactions in...
  • Page 531 SUM function SQLCODE variable swap files introduction effect on performance SQLCONNECT environment variable swapping connections effect on performance SQLLOCALE environment variable memory about 328, 336 Sybase Central setting adding users to groups SQLSTATE variable altering tables introduction and permissions...
  • Page 532 SYSINFO foreign keys users and groups introduction views permissions system views primary keys integrity stopping permissions system tables SYSUSERAUTH view SYBASE environment variable permissions DSEDIT SYSUSERLIST view synchronizing permissions about SYSUSERPERM table SYS group permissions SYSCOLAUTH view SYSUSERPERMS view permissions...
  • Page 533 Index locking transaction processing owner about permissions transactions qualified names 365, 367 about See Also information in system tables cursors in tabular data stream (TDS) definition about ending tape devices in recovery for backup procedures TCP/IP rolling back addresses savepoints Open Server starting subtransactions and savepoints...
  • Page 534 Visual Basic users ODBC configuration for adding to groups vmstat command adding with monitoring buffer caches on UNIX sp_adduser creating in Sybase Central monitoring CPUs on UNIX creating individual dropping dropping with sp_droplogin Using utilities WarehouseArchitect Transaction Log...
  • Page 535 Index defined WIN_LATIN1 collation about wired memory setting iqwmem switch WITH GRANT OPTION clause year 2000 conversion options -Z option database server zeros converting to NULL...
  • Page 536 Index...

Table of Contents