36
The Complete Sybase ASE Quick Reference Guide ASE versions 15.0, 15.5 & 15.7 6 th edition These pages are taken from "The Complete Sybase ASE Quick Reference Guide", as a sample of the contents. Note that the origi- nal page size is 11 by 22 cm (4.3 by 8.6 inch). The complete book can be ordered from http://www.sypron.nl/qr . Rob Verschoor Sypron Publications

sybase quick reference guide

Embed Size (px)

DESCRIPTION

sybase quick reference quide

Citation preview

  • The Complete Sybase ASE Quick Reference Guide ASE versions 15.0, 15.5 & 15.7 6th edition

    These pages are taken from "The Complete Sybase ASE Quick Reference Guide", as a sample of the contents. Note that the origi-nal page size is 11 by 22 cm (4.3 by 8.6 inch). The complete book can be ordered from http://www.sypron.nl/qr .

    Rob Verschoor Sypron Publications

  • 2 The Complete Sybase ASE Quick Reference Guide

    The Complete Sybase ASE Quick Reference Guide ASE versions 15.0, 15.5 & 15.7 6th edition by Rob Verschoor ISBN 978-90-806117-1-9 Published by:

    Sypron B.V. Het Wolfseind 24 3823 VS Amersfoort The Netherlands Internet www.sypron.nl Email [email protected]

    Printed in The Netherlands

    First edition : January 2001 (ASE 11.9 & 12.0) Second edition : March 2002 (ASE 11.9, 12.0 & 12.5) Third edition : July 2004 (ASE 12.0, 12.5, 12.5.1 & 12.5.2) Fourth edition : August 2006 (ASE 12.0, 12.5.4 & 15.0.1) Fifth edition : April 2009 (ASE 12.5, 15.0.3) Sixth edition : November 2012 (ASE 15.0, 15.5 & 15.7 ESD#3)

    Sypron is a registered trademark of Sypron B.V. Sybase, Transact-SQL, Adaptive Server Enterprise and Replication Server are regis-tered trademarks of Sybase, Inc. Other product or brand names may be (registered) trademarks of their respective owners. Copyright 2001-2012 Sypron B.V. All rights reserved. No part of this publication may be reproduced in any form, or by any means, without the prior written permission of the publisher. While this book has been prepared with care, neither the author, nor the publisher, nor SAP AG or Sybase Inc. (nor their subsidiaries), assume any responsibility for errors or omissions, nor do they accept any liabilities for damages resulting from the use of the information herein.

  • ASE versions 15.0, 15.5 & 15.7 3

    Contents Introduction.................................................................................................. 5 About this Quick Reference Guide .............................................................. 5 ASE versions covered in this edition........................................................................... 5 How to use this Quick Reference Guide ..................................................................... 6 Electronic version of code samples............................................................................. 7 Undocumented commands: warning & disclaimer ...................................................... 7 Starting Points For Common DBA Tasks .................................................... 8 Developer Topics....................................................................................... 10 1 Datatypes.......................................................................................................10

    1.1 Datatype conversion functions................................................................... 11 2 Identifiers .......................................................................................................11 3 Quotes & Comments......................................................................................12 4 Operators .......................................................................................................12 5 Built-in Functions............................................................................................13

    5.1 Date & Time functions ............................................................................... 13 5.2 Date/time formatting .................................................................................. 14 5.3 String functions .......................................................................................... 14 5.4 System functions ....................................................................................... 17 5.5 Mathematical functions .............................................................................. 22 5.6 Trigonometric functions ............................................................................. 23 5.7 Login/user/role functions............................................................................ 23 5.8 Miscellaneous functions............................................................................. 24

    6 Text & Image (LOB) data ...............................................................................24 6.1 LOB Locators (15.7) .................................................................................. 25

    7 Aggregate functions .......................................................................................26 8 DML statements .............................................................................................27

    8.1 Select statement ........................................................................................ 27 8.2 Subqueries................................................................................................. 29 8.3 Joins, ANSI Joins & Outer Joins................................................................ 29 8.4 Statements to modify data ......................................................................... 30

    9 Tables ............................................................................................................31 9.1 Table Partitioning....................................................................................... 33 9.2 Identity columns......................................................................................... 35 9.3 Encrypted Columns (15.0.2) ...................................................................... 36

    10 Indexes ..........................................................................................................40 11 Referential Integrity Constraints .....................................................................41 12 Object storage properties ...............................................................................42 13 Views .............................................................................................................43 14 Materialized Views/Precomp.result sets(15.7 ESD#2)....................................44 15 Rules & Defaults ............................................................................................45 16 Triggers..........................................................................................................46 17 Stored Procedures .........................................................................................47 18 SQL Functions (15.0.2) ..................................................................................48 19 Programming & flow control ...........................................................................48 20 Cursors ..........................................................................................................50

    20.1 Example of cursor programming................................................................ 52 21 Transactions ..................................................................................................52

    21.1 Example of transaction programming ........................................................ 53 22 Settings affecting ASE query behaviour .........................................................54

    22.1 Settings affecting query results.................................................................. 54 22.2 Settings affecting query execution............................................................. 55 22.3 Settings affecting query plans.................................................................... 55 22.4 Advanced settings affecting query plans ................................................... 56 22.5 Settings for displaying query plan information........................................... 57 22.6 Miscellaneous settings............................................................................... 58

    23 Statement cache ............................................................................................59 24 Commonly used system stored procedures....................................................60 25 Java in ASE (SQLJ) .......................................................................................61 26 XML (XPath/XQuery/SQLX) in ASE ...............................................................63 DBA Topics................................................................................................ 66 27 Database devices & dump devices ................................................................66

    27.1 Device mirroring......................................................................................... 67 28 Creating & maintaining databases..................................................................67

    28.1 Temporary databases................................................................................ 70 28.2 Segments................................................................................................... 70 28.3 Thresholds ................................................................................................. 71

    29 Dumping & loading databases (backup & restore)..........................................71 29.1 Quiesce, Mount, Unmount ......................................................................... 74

  • 4 The Complete Sybase ASE Quick Reference Guide

    30 Data Compression (15.7) ...............................................................................75 31 Logins & Users...............................................................................................76

    31.1 Logins (server-level 'users') .......................................................................76 31.2 Passwords..................................................................................................78 31.3 Login profiles (15.7) ...................................................................................80 31.4 Database-level users .................................................................................80 31.5 Roles ..........................................................................................................81

    32 Permissions (grant/revoke) ............................................................................83 32.1 Classic permissions ...................................................................................83 32.2 Granular permissions (15.7 ESD#2)+ ........................................................85 32.3 Row-level access control (access rules) ....................................................85

    33 Managing configuration parameters...............................................................86 34 Memory allocation..........................................................................................87

    34.1 Named caches & buffer pools ....................................................................87 35 CPUs/Cores, Engines & Threads (15.7).........................................................88

    35.1 Logical Process Manager ('Execution Classes') ........................................90 36 Update statistics.............................................................................................90 37 sp_sysmon.....................................................................................................93 38 Reorg.............................................................................................................93 39 Languages & messages.................................................................................94 40 Character set & sort order..............................................................................95

    40.1 Unicode ......................................................................................................96 41 Miscellaneous DBA commands & config parameters .....................................96 42 DBA tools.......................................................................................................98 43 MDA tables / monitoring tables ......................................................................98 44 Setting up sybsystemprocs, pubs3 & sybsyntax.............................................99 45 Setting up 'dbccdb' for 'dbcc checkstorage' ....................................................99

    45.1 'dbccdb' stored procedures ......................................................................100 Advanced DBA Topics............................................................................. 102 46 Advanced configuration parameters.............................................................102 47 Configuring parallel query processing ..........................................................103

    47.1 Parallel index creation..............................................................................103 48 ASE Cluster Edition (CE) .............................................................................104 49 Supported DBCC commands.......................................................................106 50 Unsupported DBCC commands ...................................................................108 51 ASE Traceflags............................................................................................113 52 Accessing data located outside ASE............................................................115

    52.1 Configuring remote access with RPCs ....................................................115 52.2 Configuring remote access with CIS........................................................116 52.3 Component Integration Services (CIS) features ......................................116

    53 Locking ........................................................................................................120 53.1 Transaction isolation levels ......................................................................121 53.2 Lock promotion.........................................................................................121

    54 Resource limits ('Resource Governor').........................................................122 55 XP Server ....................................................................................................123 56 Auditing........................................................................................................123 57 Database recovery.......................................................................................126 58 Abstract Plans..............................................................................................127 59 Query metrics capture..................................................................................128 60 Replication Server........................................................................................129 61 Job Scheduler..............................................................................................129 62 Shared memory dumps................................................................................129 Miscellaneous Topics .............................................................................. 131 63 The interfaces file.........................................................................................131 64 Server programs ..........................................................................................131 65 Client programs............................................................................................133 66 ASE environment variables..........................................................................138 67 Running servers as Windows services.........................................................139 68 Global variables ...........................................................................................139

    68.1 Session-specific global variables .............................................................139 68.2 Server-wide & non-static global variables ................................................141 68.3 Server-wide & static global variables .......................................................142

    69 Logical keys .................................................................................................143 70 Catalog stored procedures...........................................................................143 71 Issues with BCP-in.......................................................................................144 72 Minimally logged operations.........................................................................144 73 Monitor Server & Historical Server (pre-15.7)...............................................144 74 ASE limits ....................................................................................................145 75 ASE license manager & license options.......................................................146 Index ........................................................................................................ 148

  • 8 The Complete Sybase ASE Quick Reference Guide

    Starting Points For Common DBA Tasks Below is a brief list of some common ASE DBA tasks. See the index (p.148) or Table of Contents (p.3) if a topic is not listed here. On Windows, read sqlsrvr.exe instead of dataserver.

    Task Command or procedure / see page Find ASE product manuals sybooks.sybase.com (online searchable and PDF) Install ASE See the ASE installation guide for your platform Download the ASE software, patches and upgrades

    Download ASE from http://sybase.subscribenet.com; download patches from http://downloads.sybase.com

    Manage ASE license options Generate license keys & put in license file (p.146) Get a free version of ASE Developer/Express Ed., see www.sypron.nl/ase_free Create a new ASE server srvbuild[res]; syconfig; sybatch; dataserver -z -b Start an ASE server startserver(p.132); start as Windows service(p.139)Start ASE in standalone (single-user) mode

    Use the -m option when starting dataserver (p.131)

    Stop an ASE server shutdown(p.97); or stop Windows service (p.139) Find running ASE servers showserver (p.132); or use the Windows service

    manager (p.139) Connect to an ASE server isql utility (p.135) Change database context use (p.50), with the database name Using a GUI DBA admin tool Sybase Control Center or Sybase Central (p.98) Find the ASE version @@version (p.143) or dataserver -v (p.131) Find the ASE version for SAP Business Suite

    @@sbssav (p.143) or dataserver --sbssav (p.132)

    Find the ASE edition sp_lmconfig (p.146) Find version of system procs sp_version(p.99) (=version of installmaster etc.) Find the ASE server's IP address and port number

    In a running server, use sp_listener 'status' (p.98); or look in the interfaces file (p.131)

    Add a user to ASE create login or sp_addlogin (p.76) to allow access to the ASE server; sp_adduser or sp_addalias(p.80) to allow access to an ASE database

    Change a login password sp_password or alter loginwith passwd (p.78) List all databases in an ASE server

    sp_helpdb (p.69), without parameters

    List all tables/objects in an ASE database

    sp_help (p.60); or a direct query against the catalog: select name, type, crdate from sysobjects

    Display free/used space in an ASE database

    sp_spaceused (p.33) without database name sp_helpdb (p.69) with database name

    Find size of a table sp_spaceused (p.33), with the table name Find schema and indexes for a table

    sp_help (p.60), with the table name ddlgen utility (p.134)

    Find SQL code for stored procs, views, triggers, etc.

    sp_showtext, sp_helptext (p.61) defncopy utility (p.135); ddlgen utility (p.134)

    Copy data to/from table/file bcp utility (p.133) Backup an ASE database dump database & dump transaction (p.71) Restore an ASE database from backups

    load database & load transaction (p.71), followed by online database

    Information about database devices

    sp_helpdevice (p.67)

    Create an ASE database disk init (p.66) and create database (p.67) Enlarge a database device disk resize (p.66) Enlarge an ASE database alter database (p.68) Shrink an ASE database alter databaselog off (p.68; transaction log only) Display ASE configuration parameters

    sp_configure for all parameters (p.86) sp_configure 'nondefault' for non-default parameters

    Check database corruptions dbcc checkstorage (p.106) Display all current users sp_who (p.61) Kill a user connection kill (p.96) Monitor ASE activity and resource usage

    sp_monitorconfig (p.87); MDA tables (p.98); sp_sysmon (p.93)

    Look at ASE query plans set showplan (p.57); set statistics plancost (p.57)sp_showplan (p.61); show_plan() (p.60); & others

    Gathering information for Sybase TechSupport

    sybdiag utility (p.137)

    Find ASE limits p.145

  • 12 The Complete Sybase ASE Quick Reference Guide

    requiring set quoted_identifier on. The quotes/brackets reduce the max. length by 2. Examples: set quoted_identifier on create table "This is my table!" ("My Column!" int, YourColumn int)

    select [name] from [sysobjects] where [type] = 'U' valid_name ( character_expression [, length ] ) Returns 0 if character_expression is not a valid identifier, or a number other than 0 if it is a valid identifier. With length (1..255, default=30), character_expression will be deemed an invalid identifier (i.e. returns 0) if its length exceeds length. In 15.7, returns 128 when the config setting 'quoted identifier enhancements' = 1, set quoted identifier = on, and character_expression is a quoted identifier that is valid under these settings, but would be invalid otherwise. (15.7) sp_configure 'quoted identifier enhancements', { 0 | 1 } (static) When 1 (default=0), certain aspects of quoted identifiers behave differently; see the ASE manuals for details. Also see valid_name(). This parameter can also be set via the config setting 'enable functionality group'.

    3 Quotes & Comments /* comment */ Comment delimiters, which can extend over multiple lines; they may also be nested. -- a comment until the end of the line Single-line comment delimiter. All text after -- until the end of the line, is a comment. Quotes as string delimiters Character constants (often referred to as 'strings') must be enclosed in either single or double quotes; the opening and closing quote must be identical. When the delimiter quote appears twice, it evaluates to a single character in the string. With set quoted_identifier on (default=off), double quotes are interpreted as quoted identifiers and cannot be used as string delimiters, so best use single quotes instead. Examples: 'abc' or "abc" - these strings are identical "'" - a string consisting of a single quote, enclosed in double quotes 'He said: "How are you ?" ' - a string containing double quotes "He said: ""How are you ?"" " - the same string, but in double quotes Line continuation character Strings in T-SQL statements can span multiple lines when using the line continuation character '\'. This character will not be part of the actual string. Example: exec( ' print "This is a pretty long string, but fortunately, \ we can use two lines for it !" ' ) Without '\', this example is still valid T-SQL, but the string contains a newline.

    4 Operators Numeric operators For all numeric datatypes, the operators +, -, *, / are supported. In pre-15.0.2, % (modulo) is supported for tinyint, smallint and int only; in 15.0.2, also for nu-meric, float, etc. For mathematical functions, such as abs() and power(), see p.22. String operators The only string operators is + (|| is identical) to concatenate two strings ( [var]binary as well as [var]char); in 15.7, this also concatenates LOB variables or LOB locators (but not LOB columns). For string functions (like substring()), p.14. Logical operators Logical operators are used in logical expressions (such as in predicates and if-statements), which evaluate to true or false (except for some cases involving NULL values, where the result can be unknown). =, , != , > , >= , @b) and (@x != @y) not - negates a logical expression: if not (@a > @b) [not] like - a pattern matching operator; see next paragraph. [not] in - matches a list of values: where a in (3,4,5) is equivalent to

    where a=3 or a=4 or a=5 [not] between - matches an interval (incl. boundaries): where a between @x

    and @y - this is equivalent to where a >= @x and a

  • ASE versions 15.0, 15.5 & 15.7 21

    rm_appcontext ( 'app_context_name', 'attribute_name' ) Deletes the specified attribute from the specified application context. (pre-15) rowcnt ( doampg ) Returns the number of rows in a table, without scanning the entire table; instead, the rowcount is retrieved from the table's OAM page. Note that this value will usually be correct, but may be slightly off during heavy insert/delete activity on the table. Use the function in a query against the sysindexes table, for example:

    select rowcnt( doampg ) from sysindexes where indid < 2 and id = object_id( 'my_table' )

    Replaced by row_count() in 15.0.

    row_count ( db_id, object_id [, ptn_id ] ) Replaces rowcnt() in 15.0. Example: select row_count( db_id(), object_id( 'my_table' )) set_appcontext ( 'app_context_name', 'attribute_name', 'attribute_value' ) Creates an attribute in the specified application context; if the context does not yet exist, it will be created as well. The size of the attribute value must be 255 bytes. The application context can also be set by a login trigger (p.77). Example: select set_appcontext ( 'my_context', 'attrib_1', 'value_1' ) show_sec_services () Lists the active security services for the current session. showplan_in_xml () Returns information about query optimization/execution, in XML format; p.58. (15.0.2) show_plan (), show_cached_text[_long] () Display information about queries/plans in the statement cache; p.60. (15.7) show_cached_plan_in_xml (), show_dynamic_params_in_xml() Returns information about plans in the statement cache, in XML format; p.60. syb_quit () Causes ASE to terminate the current session. Example: select syb_quit(). syb_sendmsg ( 'ip_address', port_nr, 'message_string' ) (Unix only) Sends a UDP message to the specified port; requires the config option 'allow sendmsg' (dynamic) to be set to 1. The config option 'syb_sendmsg port number' (static) defines the outgoing port number used by ASE. The message string can be max. 16384 bytes; in pre-15.0.2, max. 255 bytes. sp_sendmsg is a wrapper around syb_sendmsg(), taking the same parameters (though in 15.0.2, the max. message length is 4096 bytes). tempdb_id ( [ spid ] ) Returns the database ID of the specified session's temporary database; without spid, for the current session. tran_dumpable_status ( db_name ) Returns 0 when the transaction log of the specified database can be dumped. Other-wise, returns a bitmap indicating the reasons why this is not possible. In 15.5, sp_tran_dumpable_status [ db_name ] displays both the bits and reason.

    Bit Reason 1 the specified database does not exist 2 the transaction log is not on a separate device 4 the first log page is on a data-only fragment 8 database option 'trunc log on chkpt' is enabled 16 non-logged writes occurred in this database 32 dump tranwith truncate_only has been performed 64 database is newly created or upgraded; database dump is required first 128 the database's durability does not allow the log to be dumped 256 the database is read-only; a log dump starts a transaction 512 database is online for standby_access; a log dump starts a transaction1024 the database is an archive database; log dump not supported

    (pre-15) used_pgs ( object_id, doampg, ioampg ) Returns the number of pages used by a table and its clustered index. Use in a query against sysindexes; see rowcnt() for an example. Replaced by used_pages() in 15.0.

  • ASE versions 15.0, 15.5 & 15.7 37

    must have been run in this database, or, in 15.7, a master key created. For as de-fault, see alter encryption key. options can be: keylength length - key length in bits; for AES: 128 (=default), 192 or 256. init_vector [ random | NULL ] - with random (=default), uses an initialization

    vector during encryption, so that identical plaintext values produce different ci-phertext; with NULL, no initialization vector is used.

    pad [ random | NULL ] - with random, encrypted values are padded randomly for better security; with NULL (=default), no padding is done.

    passwd 'key_passwd' - a password to protect (=encrypt) the encryption key with; it must satisfy configuration settings 'minimum password length' and 'check password for digit' (but not the sp_passwordpolicy settings). Before the key can be used, set encryption passwd must be executed. NB: a lost password cannot be recovered unless a recovery key copy has been created (with alter encryption keyfor recovery).

    (15.7) dual_control - specifies that the encryption key must be protected by two passwords (for PCI compliance). Without with passwd, the key is protected by the master key and dual master key, which must both exist; with with passwd, it is protected by this key password and the master key. dual_control is ignored when a master or dual master key is created.

    Note: to index an encrypted column, init_vector NULL and pad NULL are required. Example: create encryption key my_key for AES with init_vector null pad null create table my_tab (my_col int encrypt with my_key) insert my_tab values (1) (15.7) create encryption key [ dual ] master [ for AES ] with passwd 'key_passwd' alter encryption key [ dual ] master with passwd 'old_passwd' modify encryption with passwd 'new_passwd' Without dual, creates a master key in the current database, or changes its password. The master key is used to protect (=encrypt) encryption keys. Alternatively, sp_encryption system_encr_passwd can be used. For password requirements, see create encryption keywith passwd above. With dual, creates a dual master key in the current database, which is used together with the master key to encrypt encryption keys that are created with the dual_control option but without a key password. The master key and the dual master key must have different owners. When using a (dual) master key, the key password must be set (with set encryption passwd) before data can be encrypted/decrypted. When using unattended startup mode with the master key startup file, this is not needed. This requires running alter encryption keyfor automatic_startup (p.38) for the (dual) master key, and enabling the config setting 'automatic master key access'. Example: create encryption key master with passwd 'S3cret'

    set encryption passwd 'S3cret' for key master create encryption key my_key create table my_tab (my_col int encrypt with my_key)

    drop encryption key key_name Drops the specified encryption key, including all its key copies. No columns or keys must be encrypted with the key. alter encryption key key_name remainder-of-command Modifies the specified encryption key or key copy. The remainder of the command can be as follows: as [ not ] default - when marked as default, this key will be used for encrypted

    columns where no key name is specified in the DDL statement. sp_encryption displays which key, if any, is the default key.

    modify owner 'user_name' - changes key ownership; see p.98 for full syntax. with passwd 'orig_passwd' add encryption with passwd 'key_copy_passwd'

    for user 'user_name' [ for recovery ] - creates a key copy of the specfied key for exclusive use by the specified user. A key copy is identical to the original key, but is protected with a different password, and accessible only by the des-ignated user. orig_passwd is the key's original password, known only to the key owner/key custodian. key_copy_passwd will be shared with the specified user (who can change it with alter encryption keymodify encryption). With for recovery, the key copy can be used for recovery purposes only; no encrypted data can be accessed through it. The designated user should be trustworthy, modify the password, and keep it in a safe place. To find recovery key copies, run sp_encryption with helpcol or helpuser, and key_copy.

    with passwd 'passwd' add encryption for user 'user_name' for login_association - creates a key copy for the specified user, encrypted with the user's login password. passwd is the key's original password, known only to the key owner/key custodian.

  • 50 The Complete Sybase ASE Quick Reference Guide

    raiserror error_nr [, value_list ] raiserror error_nr { 'format_string' | @ variable } ] [, value_list ] [ with errordata list ] With a comma following error_nr, the corresponding message in the session's current language will be retrieved, formatted using values in value_list, and printed. For sys-tem-defined messages (in master..sysmessages), error_nr must be between 17000 and 19999; for user-defined messages (in sysusermessages in the current data-base), error_nr must be 20000. format_string or @variable are used to format and display a message. Without a comma following error_nr, no message is retrieved, but an instant message is com-posed from the specified format string or variable, and any values in value_list. When raiserror completes, @@error will contain the value of error_nr. The clause with errordata list is for use with CT-Lib programs only. Examples: sp_addmessage 22222, 'This is a %1! message!'

    raiserror 22222, 'strange' raiserror 33333 'This is an %1! message', instant -- note: no comma !

    return [ [ ( ] expression [ ) ] ] [ AP ] Exits from a stored procedure or SQL function to the caller. expression will be the return value of the procedure or function. If the expression involves a query, this must evaluate to a single integer value. For procedures, ASE uses negative return values to indicate certain types of errors; therefore, don't use these in your SQL code. When the AP clause is used, the parentheses ( '(' and ')' ) are mandatory. See the while statement for more information about this optional AP clause. waitfor delay 'hh:mm:ss[.cccuuu]' / waitfor delay @variable waitfor time 'hh:mm:ss' / waitfor time @variable Waits for a while. delay waits for the specified interval (max. 24 hours); time waits until the specified time (max. 24 hours away). The number of concurrent waitfor statements is limited by config setting 'number of alarms' (dynamic); default=40. while logical_expression [ AP ] T-SQL-statement If logical_expression is true, executes T-SQL-statement in a loop until the expression is no longer true, or until the loop is exited via a break, return or goto statement. Example: while @i < 100 begin exec my_proc select @i = @i + 1 end If the expression involves a query, AP can specify the abstract plan for this query as plan '( AP-language )' ; p.127 for info on abstract plans. break Exits from a while-loop; execution continues at the first statement after the loop. continue Returns to the top of the while-loop and re-evaluates the logical expression. use { db_name | @character_variable } Changes the current database to db_name, or to the database in the character vari-able, effective as of the next query batch. use cannot be used in stored procedures or triggers. The use of @character_variable is undocumented. Also note: system stored procedures can access other databases without changing the current database though the use command. Example: to display the schema of table other_db..t1, regardless of the current database, use this: exec other_db..sp_help t1.

    20 Cursors Cursors can be used for implementing loop-based, sequential, non-relational algo-rithms like those which are common in 3GL languages. ASE has 4 types of cursors: server cursor - declared in a stored procedure. language cursor - declared in command batches, outside a stored procedure. client cursor and execute cursor - defined on the client side and implemented

    though OpenClient (typically in a C-program) or Embedded SQL. These cursors can not be created interactively using client applications like isql.

    The rest of this section applies only to language cursors or server cursors. declare cursor_name [ semi_sensitive | insensitive ] [ scroll | no scroll ] [(15.7) release_locks_on_close ] cursor for select_statement [ for { read only | update [ of updated_column_names_list ] } ] Declares (creates) a cursor based on the specified select statement. With no scroll (=default), the cursor is non-scrollable (i.e. only the next row can be fetched). With scroll, the cursor is scrollable (i.e. any row can be fetched). With semi_sensitive (=default in 15.0), changes to the underlying data rows may be visible through the cursor; with insensitive (=behaviour in pre-15), such changes are not visible. Trace-

  • ASE versions 15.0, 15.5 & 15.7 63

    the related classes are dropped as well, unless retain classes is specified. To extract a JAR and its Java classes, use extractjava (Windows:extrjava); p.135. In pre-15.0.3, a debugger for Java-in-ASE is in $SYBASE/$SYBASE_ASE/debugger /Debug.jar. To start, run: java sybase.vm.Debug (from the command line). In 15.0.3, any Java-compliant debugger can be used, like jdb (requires installing the JDK). See the ASE manual Java in Adaptive Server Enterprise for details.

    26 XML (XPath/XQuery/SQLX) in ASE ASE processes XML natively, with support for XPath queries (p.65). For full details on XML/XPath/SQLX, see the manual XML Services in Adaptive Server Enterprise. sp_configure 'enable xml', { 0 | 1 } (dynamic) Enables (1) or disables (0) native XML features. Enabling requires, in pre-15 only, the ASE_XML license option. select rest of statement for xml [ schema | all ] [ returns datatype ] [ option 'sqlx_options'] } For a select statement only, specifying for xml converts the SQL result set to a SQLX-XML document. returns can only be used when the select is a subquery. for xml schema generates the XML schema describing the result set generated by for xml, but not the result set data itself; for xml all generates both schema and data. For sqlx_options, see below. Example: select * from my_table where col1 > 0 order by col2 for xml option 'columnstyle=attribute statement=yes' xmlextract ( 'xpath_query[/text()]', xml_doc [ option 'options'] returns datatype ] ) Extracts elements from the XML document, based on the XPath query, returning a scalar value. xmlextract() can be used in expressions and predicates (also see xmltable() (below), which can be used in the from clause). By default, the result is returned as an XML document; when /text() is appended, the outermost XML tags are removed. By default, the result datatype is text, unless specified otherwise (as an ASE datatype or as java.lang.String) with returns. op-tions can be xmlerror and ncr (see sqlx_options below). In 15.7, local variables and parameters can be of type text or image which can be useful when handling XML. Examples: select xmlextract('//t', 'Hello') returns: 'Hello' select xmlextract('//t/text()', 'Hello') returns: 'Hello' select xmlextract('//t/text()', '1234' returns int) returns: 1234 (as an integer) select xmlextract('//t', xml_col option 'xmlerror=message' returns int) from your_tab rest of query xmlparse ( xml_doc [ option 'options'] ) Parses an XML document, returning it as an image value. Parsed XML data can be accessed faster than raw XML. options can be xmlerror (see sqlx_options below) and also dtdvalidate={yes|no}: with yes (default=no), the XML document is validated against an embedded DTD. Example: create table my_tab (my_col int, xml_col image NULL) insert my_tab values (123, xmlparse('Hello')) -- parsed XML insert my_tab values (456, 'Bonjour') -- raw XML xmlrepresentation ( image_column ) Determines if an image column contains a parsed XML document; if so, returns 0, otherwise returns >0; if the input is NULL, returns NULL. Example: select my_col, xmlrepresentation(xml_col) from my_tab 'xpath_query' xmltest xml_doc [ option 'options'] xmltest evaluates to true or false (or NULL), after applying the XPath query against the XML document. This can be used like a logical expression, for example in a where clause, case expression, if statement etc. To negate the result, use not. options can be xmlerror (message and NULL only); see sqlx_options below. Example: select my_col from my_tab

    where '//t="Hello"' xmltest xml_col option 'xmlerror=NULL' and further predicates

    (15.0.2) xmltable ( 'xpath_rows' passing xml_doc columns col_name datatype [ not null ] [ path 'xpath_cols' ] [ for ordinality ] [,more columns] ) Extracts elements from the XML document (which can also be a variable, column or subquery), returning a table that must be used as a derived table in the from clause. xmltable() can be seen as providing a relational view on XML data. Also, it simplifies

  • ASE versions 15.0, 15.5 & 15.7 77

    login), enables (add) or disables (drop) that the roles are activated when the user logs into ASE. Default=not activated. System roles are always activated. all = all roles. When multiple roles are listed, they must be comma-separated. (15.7) alter login login_name drop attribute [attribute] Removes one or more attribute settings for an existing login, reverting to the default setting. See alter loginmodify for attributes that can be modified. Example: alter login jsmith drop login script min passwd length (15.7) drop login list_of_login_names [ with override ] sp_droplogin login_name [(15.7) , 1 ] Drops a login. drop login can drop multiple (comma-separated) logins. This fails when a login is still mapped to a database user and/or owns objects; in this case, use the stored proc sp_rv_helplogin (from www.sypron.nl/new_ssp.html) to help re-solve the problem; in 15.7, sp_helpuser, display_object also gives some info. drop loginwith override and sp_droplogin with 1 as 2nd parameter will drop a login even if some databases cannot be accessed. In 15.7, use drop login. sp_addlogin login_name, passwd [, def_db [, def_lang [, full_name [, passwd_expi-ration [, min_passwd_len [, max_failed_logins [, authenticate_with ]]]]]]] Creates a new login with the specified password and optional attributes (which can also be set with sp_modifylogin). In 15.7, use create login which has more options. sp_modifylogin login_name, attribute, 'value' Modifies attributes of the specified login. In 15.7, use alter login instead. Possible values for attribute are below; see the corresponding attributes for alter login/create login as indicated with 'see'. Note that value must always be quoted. 'fullname' (see fullname), 'defdb' (see default database), 'deflanguage' (see

    default language), 'passwd expiration' (see password expiration), 'min passwd length' (see min password length), 'max failed_logins' (see max failed attempts), 'authenticate with' (see authenticate with).

    For 'login script', see login script; also, specify value = NULL to drop the setting, or a different name to change it. In 15.0.2, with login_name = NULL, de-fines or removes a global login trigger (see sp_logintrigger for full details).

    For 'add default role' and 'drop default role', see alter loginadd/drop auto activated roles.

    When option is 'passwd expiration', 'min passwd length' or 'max failed_logins': when login_name is 'all overrides', the setting is applied to all logins with a

    non-default setting; with also '-1' for value, all non-default settings are dropped. in 15.0.2, when value is 'clear', removes the login-specific setting. sp_displaylogin [ 'login_name' ] (15.0.2) sp_displaylogin [ 'suid' | 'login_name_pattern' ] Displays attributes of the specified login(s). Without parameter, displays the current session's login. In 15.0.2, the login name may contain wildcards; also, the login's suid number may be specified (as a quoted string). To display all existing logins, use this query: select name, suid from master..syslogins or, in 15.0.2, sp_displaylogin '%' (15.0.2) sp_logintrigger [ '[db_name.[owner].]proc_name' | 'drop' ] Defines or modifies (with proc_name) or removes (with 'drop') a global login trigger. This is executed for all logins (incl. sa), before a login's own login trigger, if defined. Without db_name, it must exist in the login's default database. Without parameter, shows the current setting, which is also in @@logintrigger. Running sp_logintrigger is equivalent to sp_modifylogin NULL, 'login script', The global login trigger is disabled with boot-time traceflag 4072 (undocumented). Example: sp_logintrigger 'my_db.dbo.p_globaltrg' suser_id ( [ login_name ] ) suser_name ( [ suid ] ) Returns the login ID (suid) or login name for the specified login name or ID, respec-tively, as stored in the master..syslogins table. Without parameter, returns the current session's login ID or login name. set proxy login_name set session authorization login_name Changes the current session's login name (suid) to login_name, inheriting all roles and permissions granted to login_name. To return to the session's original login name, specify the original login_name. The inherited roles can be restricted with grant set proxyrestrict role (p.83). Before set proxy can be used, a user with sso_role must execute grant set proxy in

  • 96 The Complete Sybase ASE Quick Reference Guide

    sp_configure 'default sortorder id', sortorder_id (static) Changes the sort order for the current default character set. After restarting the ASE server, run sp_indsuspect to check for invalid indexes and sp_tab_suspectptn to check for invalid partitioned tables. To display the available sort orders (and their IDs) in the server: select id, csid, name, description from master..syscharsets where type >= 2000 sp_configure 'default character set id', charset_id (static) Changes the default character set used by the server. When ASE is restarted, the default character set will be changed and ASE will shutdown automatically. To display the available character sets (and their IDs) in the current server: select id, csid, name, description from master..syscharsets where type < 2000 sp_configure 'disable character set conversion', { 0 | 1 } (static) Enables (0, =default) or disables (1) automatic conversion between the character sets of the server and the client. sp_checknames Displays all identifiers in the current database that contain non-7-bit-ASCII characters. sp_helpsort Displays the default character set and sort order used by the server. sp_indsuspect [ table_name ] Checks the specified table_name (if omitted, checks all tables in the current data-base) for indexes marked as suspect during recovery as the result of changing the server sort order. Suspect indexes can be fixed by running dbcc reindex. set char_convert on [ with { error | no_error } ] set char_convert off set char_convert character_set [ with { error | no_error } ] Defines conversion between the character sets of server and client. on (=default) enables character set conversion; off disables it; character_set explicitly specifies the client character set to convert to. with no_error specifies that no error message is raised for conversion errors (ASE-to-client only); default=with error. @@char_convert indicates if character set conversion is currently in effect (1) or not (0). The global variables @@maxcharlen, @@ncharsize, @@client_csexpansion @@client_csname, @@client_csid are also related to character sets (p.140). 40.1 Unicode To store Unicode data in [var]char or text data, configure ASE with the utf8 character set. Datatypes uni[var]char and unitext, which store UTF-16 values, and Unicode notation (like U&'\0041', = 'A'), can be used independent of the ASE character set.

    Unicode-related configuration parameters are the following, set with sp_configure: (15.7) 'enable permissive unicode', { 0 | 1 } (dynamic) - when 0 (=default),

    uses strict Unicode and raises an error when encountering Unicode non-characters (like U&'\fffe'); when 1, such non-characters are allowed.

    'default unicode sortorder', sortorder (static) - the default Unicode sort order, default=binary.

    'enable unicode conversions', 'enable unicode normalization', 'enable surrogate processing' - all dynamic, and 0 or 1 (see ASE manuals for details).

    Unicode-related functions and global variables: to_unichar ( integer_expression ) - returns the Unicode expression for the

    integer expression. uhighsurr / ulowsurr ( unicode_expression, start ) - tests the Unicode value at

    position start in the Unicode expression: if this is the high or low half, respec-tively, of a surrogate pair, returns 1; otherwise returns 0.

    uscalar ( unicode_expression ) - returns the Unicode scalar value for the first character in the Unicode expression.

    @@unicharsize - contains 2, the length (in bytes) of a unicode character.

    41 Miscellaneous DBA commands & config parameters kill spid [ with trace ] kill spid with statusonly Kills the specified session. The undocumented option with trace prints a stacktrace for the killed session to the errorlog (this may not always work). killwith statusonly does not kill, but only reports progress while the session is performing a rollback.

  • 108 The Complete Sybase ASE Quick Reference Guide

    dbcc tune ( option, value_1, value_2) Modify certain run-time configuration settings. These settings are not persistent (i.e. not maintained after an ASE restart) unless specified otherwise. Possible options are: ('ascinserts', value, table_name) - only for APLs tables with a composite clus-

    tered index, when set to 1 (default=0) reduces page splits for inserts in ascending key order. This setting is persistent. In 15.0.2, this property can also be set with sp_chgattribute, and displayed with sp_help.

    ('cleanup', value) - if value = 0, memory cleanup checking is enabled (=default); if value = 1, disabled.

    ('cpuaffinity', firstcpu, { 'on' | 'off' } ) - enables/disables CPU affinity, provided this is supported by the platform; starting with engine 0, engines are bound to CPU firstcpu. Run ('cpuaffinity', -1) to write current setting to server errorlog.

    ('des_bind', db_id, table_name ) - binds a table to an object descriptor so that it won't be pushed out of the metadata cache. Use for hot tables when seeing Ob-ject Manager Spinlock contention in sp_sysmon. Use 'des_unbind' to remove.

    ('des_greedyalloc', db_id, table_name, { 'on' | 'off' } ) - enables (on) or dis-ables (off, =default) 'greedy allocation' for the table (to reduce latch contention).

    ('deviochar', vdevno, value) - sets max. outstanding I/Os by housekeeper for device vdevno to value (1..255; default=3); if vdevno = -1; applies to all devices.

    (pre-12.5.1) ('doneinproc', { 0 | 1 } ) - obsolete; replaced by sp_configure 'send doneinproc tokens' (p.102).

    (pre-12.5.1) ('maxwritedes', value) - obsolete; replaced by sp_configure 'i/o batch size' (p.102).

    50 Unsupported DBCC commands WARNING! These (arbitrarily selected) DBCC commands represent unsup-ported functionality which may have unexpected side effects, may cause irreversible damage to your databases and/or lead to loss of data. Use entirely at your own risk. Do not contact Sybase Technical Support for assistance ! Many dbcc commands require that the role sybase_ts_role be enabled for the exe-cuting session. This can be done as follows (assuming the login is 'sa'):

    grant role sybase_ts_role to sa set role sybase_ts_role on

    dbcc help ( command ) Displays syntax info for the specified dbcc command. dbcc addtempdb ( db_id | db_name ) Adds a temporary database to the global list of temporary databases. dbcc allocdump ( db_id |db_name, alloc_page_nr ) Lists extents in an allocation unit, identified by the allocation page number. dbcc bytes ( address, length ) / dbcc bytes ( address, printopt, structure_name ) Dumps length bytes, starting at address (e.g. a physical page address), in hex & ASCII. dbcc bytes(0,0,'showlist') displays all structures that can be specified as masks in dbcc bytes(address, printopt, structure_name). Specify -1 for printopt. dbcc cacheremove ( db_id | db_name, object_id | object_name ) Deallocates the object descriptor (DES) for the specified table. dbcc dbcacheremove ( db_id | db_name ) Clears the DBTABLE information for the specified database, for use when commands fail with a 'keep count' reported as > 0 although no users are active in the database. (15.0.3) dbcc cachedataremove ( db_id | db_name [, object_id | object_name [, ix_id | ix_name [, ptn_id | ptn_name ]]] ) Removes all pages for the specified database/object/partition from the data cache. dbcc cis ( subcommand ) Displays CIS-related information. Subcommands are: 'remcon' displays all CIS remote connections 'showcaps' [, 'server_name' ] - displays the capabilities of the remote server 'srvdes' [, server_id ] - without argument, displays all SRVDES structures. With

    server_id, syncs the in-memory SRVDES with master..sysservers dbcc connection_hangup ( remote_server_name ) Closes a site handler connection to the specified remote server (like a Backup Server).

  • ASE versions 15.0, 15.5 & 15.7 131

    Miscellaneous Topics

    63 The interfaces file The interfaces file is an essential part of the Sybase client-server environment. For client applications, it must contain the network address for every server the client application connects to. To start a server, it must be able to find its own network ad-dress in the interfaces file. By default, the interfaces file is $SYBASE/interfaces (on Windows: %SYBASE%\INI\SQL.INI). When named or located differently, it must be specified with a command-line parameter for the client or server program (see the following sections). An LDAP server can replace the interfaces file for looking up the server network address by client apps; no license option is needed for this. For user authentication by an LDAP server instead of syslogins, license option ASE_SECDIR is needed. Best use the dsedit or dscp utilities to edit the interfaces file. Note that the inter-faces file (for Unix) and the SQL.INI file (for Windows) use incompatible formatting. dscp (Unix only) - an ASCII-interface utility to view/edit the interfaces file. dscp has its own command set. At the prompt, type help for on-line help. dsedit - a GUI utility to view/edit the interfaces file.

    64 Server programs For all programs, the option -v displays the software version. backupserver (Windows: bcksrvr.exe) - Backup Server, for creating/loading data-base dumps and transaction log dumps. [-C nr_connections] max. # Backup Server connections (default=30) [-S server_name] server name (default=$DSLISTEN, otherwise SYB_BACKUP) [-I interfaces_file] interfaces file pathname (default=$SYBASE/interfaces) [-e errorlog_file] Backup Server errorlog (default=backup.log) [-M sybmultbuf] pathname of the sybmultbuf binary file [-N net_connections] max. # of Backup Server network connections (default=25) [-L language] language used by Backup Server [-J character_set] character set used by Backup Server [-P active_threads] max. # active stripes (for multiple dump/load sessions) [-c tape_config_file] tape configuration file (default=$SYBASE/backup_tape.cfg) [-Vn] error logging detail level, n=0..3, in 15.5 also 4; lower=more

    detail, except -V4 (=-V0, but without connection events) [-T traceflag] boot-time OpenServer traceflags [-m max_MB] max. amount of memory (MB) to be used by Backup Server

    (default= (number of active stripes)*1MB) [-p packet_size] TDS packet size (in bytes; default=2048) requested by a local

    Backup Server from a remote Backup Server for a remote dump/load. Both servers must allow the requested value.

    (Undocumented) Backup Server traceflags can be dynamically set with RPCs qatra-ceon (enable) or qatraceoff (disable): SYB_BACKUPqatraceon N, where N can be 1 (prints blocksize), 2 (prints I/O optimization parameters), 3 (allows dumping to /dev/null), 4 (print allocation %age), 5 (print DB page size), 0 (prints active traceflags). dataserver (Windows: sqlsrvr.exe) - the ASE server itself. The options marked '(build)' apply only when building a new ASE server. In 15.5, all options also have a GNU-style equivalent (e.g. --error-log for -e); use -h to display these. The pre-12.5 buildmaster utility is replaced by dataserver -z -b and other '(build)' flags. [-v] displays software version of the ASE server [-h] 'help' function; displays all possible parameters [-d master_device] master device pathname [-r master_mirror] master device mirror pathname (when master is mirrored) [-s server_name] server name (default= $DSLISTEN, otherwise SYBASE) [-c config_file] server config. file (default= $SYBASE/server_name.cfg) [-e errorlog_file] ASE server errorlog (default=errorlog) [-m] start server in standalone (single-user) mode; this can be

    tested with is_singleusermode() (p.18) [-M sharedmem_dir] shared memory directory [-i interfaces_file_dir] directory containing interfaces file (default=$SYBASE) [-T traceflag] boot-time traceflags (multiple -T options can be specified) [-a keytab_file] CAPs directive filename [-G logserver_name] specifies a server name for event logging [-g] disables event logging

  • 132 The Complete Sybase ASE Quick Reference Guide

    [-H] specified when using the High Availability feature (ASE_HA) [-K keytab_file] keytab filename (when using DCE) [-k principal_name ] (15.0.2) server's principal name (used with Kerberos) [-N lic_prop_file] license properties file,dft=ASE-15_0/sysam/srvnm.properties [-P] (Windows) start ASE server with high priority(default=medium) [-p login_name] generates a new random password (printed on the console) for

    the specified login (which must have been granted sso_role) [-u role_or_login] unlocks the specified role or login (which must have sa_role

    and/or sso_role) [-A role_name] (15.7 ESD#2) list (max.10) unlocked logins with role_name [-n permission] (15.7 ESD#2) list (max.10) unlocked logins with (granular) permission [-q] databases 'created' via quiesce database for external dump

    remain offline (so log dumps can be loaded) [-X] start a diagnostic tool known as 'sybmon' [-b sizek|K|m|M|g|G|t|T] (build) size of master device to create [-f[orcebuild]] (build) use with -b, -w and -z to override an existing situation [-w db_name ] (build) rewrites specified database (only master or model) [-z page_sizek|K] (build) server page size (2k, 4k, 8k, or 16k) [-D sizek|K|m|M|g|G] (build) default database size (for model and tempdb) [-Z sizek|K|m|M|g|G] (build) size of master database [-Q |--quorum_dev=device_name](CE) quorum device pathname; required for CE [--instance=instance_name] (CE) instance to be started; required for CE [--buildquorum[=force]] (CE) creates or overwrites a quorum device [-F |--cluster_input=input_file] (CE) cluster config input file for --buildquorum [--cluster_takeover] (CE) allow recovering from cluster failures that left the quorum device in incorrect state (p.104) [--create_cluster_id] (CE) repairs coupling of quorum + master device [--sbssav] (15.7) displays @@sbssav (ASE version for SAP Business Suite) [--master-key-passwd[=passwd]] (15.7) master key encryption password in master

    database (no need for set encryption passwd) diagserver (Windows: diagsrvr.exe) - a diagnostic, but otherwise functionally identi-cal, version of dataserver. Run this only when instructed by Sybase Technical Support. (pre-15.7) monserver (Windows: monsrvr.exe) - Monitor Server -M Mon_server_name name of the Monitor Server -S ASE_server_name name of the ASE server to monitor -U login_name login into the ASE server; also a login into Monitor Server [-P password] password for login_name [-E] don't overwrite an exiting .mrg file [-O] overwrite an exiting .mrg file [-i interfaces_file] interfaces file pathname (default=$SYBASE/interfaces) [-l errorlog_file] Monitor Server errorlog (default=ms.log) [-L config_file] Monitor Server configuration file [-m sharedmem_dir] ASE server shared memory directory [-n max_connections] max. number of client connections to Monitor Server [-p] (Windows only) sets Monitor Server execution priority to high [-T0] Monitor Server does not print ASE error messages [-T1] Monitor Server will not shut down when ASE shuts down (pre-15.7) histserver (Windows: histsrvr.exe) - Historical Server -D home_directory directory containing control file and recorded data files [-S Hist_server_name] name of the Historical Server [-U login_name] Historical Server super-user login (to execute hs_ commands) [-P password] password for super-user login [-i interfaces_file] interfaces file pathname (default=$SYBASE/interfaces) [-l errorlog_file] Historical Server errorlog (default=hs.log) [-n max_connections] max. number of client connections to Historical Server showserver (Unix only) - Displays running servers on the current host; located in $SYBASE/$SYBASE_ASE/install. startserver (Unix only) - starts one or more ASE-, Backup-, or other servers; located in $SYBASE/$SYBASE_ASE/install. [-f RUN_server_file] [-f ] file name of the RUN_servername file; multiple allowed Example: startserver -f RUN_PROD

  • 148 The Complete Sybase ASE Quick Reference Guide

    Index Legend Keywords followed by ', sp_' are stored procedures where the sp_ prefix has

    been chopped off to make a better reference; for example, addserver, sp_ refers to sp_addserver. This is done for other commands as well; for example checkdb, dbcc refers to dbcc checkdb, and showplan, set to set showplan.

    Keywords followed by (config) are server configuration options, settable with sp_configure. Keywords followed by (DB option) are database options, setta-ble with sp_dboption.

    @ @@active_instances......................... 142 @@authmech ............................. 17, 139 @@bootcount ................................... 142 @@boottime ..................................... 142 @@bulkarraysize.............................. 139 @@bulkbatchsize ............................. 139 @@char_convert .............................. 139 @@cis_rpc_handling ........................ 140 @@cis_version ......................... 116, 142 @@client_csexpansion..................... 139 @@client_csid .................................. 139 @@client_csname ............................ 139 @@clusterboottime........................... 142 @@clustercoordid............................. 142 @@clustermode................................ 142 @@clustername................................ 142 @@connections................................ 141 @@cpu_busy.................................... 141 @@curloid ........................................ 140 @@cursor_rows.......................... 51, 140 @@datefirst ................................ 14, 140 @@dbts ............................................ 141 @@error ........................................... 140 @@errorlog....................................... 142 @@fetch_status.......................... 51, 141 @@identity.................................. 36, 140 @@idle ............................................. 141 @@instanceid................................... 142 @@instancename............................. 142 @@io_busy....................................... 141 @@isolation.............................. 121, 140 @@kernelmode .......................... 89, 142 @@langid ......................................... 140 @@language .................................... 140 @@lastkpgendate............................. 142 @@lastlogindate............................... 140 @@lock_timeout ....................... 121, 140 @@logintrigger ........................... 77, 141 @@lwpid............................................. 60 @@max_connections ................. 97, 142 @@max_precision ............................ 142 @@maxcharlen ................................ 140 @@maxpagesize.............................. 142 @@monitors_active .......................... 142 @@ncharsize.................................... 140 @@nestlevel......................... 47, 48, 140 @@nextkpgendate............................ 142 @@nodeid ........................................ 142 @@optgoal ................................. 55, 140 @@options ....................................... 140 @@optlevel................................. 55, 140 @@opttimeoutlimit ...................... 57, 140 @@ospid .......................................... 140

    @@pack_received.............................142 @@pack_sent ...................................142 @@packet_errors..............................142 @@pagesize .....................................142 @@parallel_degree...................103, 140 @@plwpid ...........................................60 @@procid....................................48, 140

    in a trigger.......................................47 @@qpmode.................................56, 141 @@quorum_physname .....................142 @@recovery_state ....................126, 142 @@repartition_degree.................57, 141 @@resource_granularity .............57, 141 @@rowcount .....................................141

    in a cursor.......................................51 in a trigger.......................................47

    @@sbssav ................................132, 143 @@scan_parallel_degree..........103, 140 @@servername.................................143 @@setrowcount ..........................54, 141 @@spid.............................................141 @@sqlstatus ...............................51, 141 @@ssl_ciphersuite ............................141 @@stringsize ..............................62, 141 @@sys_tempdbid .......................70, 143 @@system_busy...............................141 @@system_view ...............................104 @@tempdbid...............................70, 141 @@textcolid ........................................25 @@textdataptnid .................................25 @@textdbid.........................................25 @@textobjid ........................................25 @@textptnid ........................................25 @@textptr ...........................................25 @@textptr_parameters................25, 141 @@textsize .........................................25 @@textts.............................................25 @@thresh_hysteresis..................71, 143 @@timeticks..............................102, 143 @@total_errors .................................142 @@total_read....................................142 @@total_write ...................................142 @@tranchained.................................141 @@trancount...............................53, 141 @@transactional_rpc ........................141 @@transtate................................53, 141 @@unicharsize ...................................96 @@user_busy ...................................141 @@version........................................143 @@version_as_integer .....................143 @@version_number ..........................143

    A abort tran on log full (DB option) ..........68 abs() ....................................................22

  • ASE versions 15.0, 15.5 & 15.7 149

    abstract plan (show) ............................58 abstract plan cache (config)...............128 abstract plan dump (config) ...............127 abstract plan load (config)..................127 abstract plan replace (config).............128 abstract plans ....................................127 abstract query plan .... See abstract plans access rules...................................45, 86 acos() ..................................................23 acronyms used in this book ...................6 activeroles, sp_....................................82 add_qpgroup, sp_..............................128 add_resource_limit, sp_.....................122 add_time_range, sp_ .........................122 addalias, sp_ .......................................81 addauditrecord, sp_...........................124 addaudittable, sp_ .............................124 addengine, sp_ ....................................90 addexeclass, sp_.................................90 addextendedproc, sp_ .......................123 addexternlogin, sp_ ...........................117 addgroup, sp_......................................81 additional network memory (config) .....97 addlanguage, sp_ ................................94 addlogin, sp_ .......................................77 addmessage, sp_ ................................95 addobjectdef, sp_ ..............................119 addremotelogin, sp_ ..........................115 addsegment, sp_ .................................71 addserver, sp_...........................115, 116 addtempdb, dbcc ...............................108 addthreshold, sp_ ................................71 addtype, sp_........................................10 addumpdevice, sp_..............................67 adduser, sp_........................................81 aggregate functions .............................26 all (opposite of distinct) (operator)........27 all (subquery operator).........................29 allocate max shared memory (config) ..87 allocdump, dbcc.................................108 allocinfo().............................................19 allow nested triggers (config), ..............46 allow nulls by default (DB option).........68 allow procedure grouping (config)........47 allow remote access (config) .......72, 115 allow resource limits (config)..............122 allow sendmsg (config) ........................21 allow sql server async i/o (config) ......102 allow updates to system tables (conf) ..97 allow wide dol rows (DB option)...........68 allow_dup_row.....................................40 allpages (lock scheme) ......................120 allrows_dss (optgoal)...........................55 allrows_mix (optgoal)...........................55 allrows_oltp (optgoal)...........................55 alter database

    for proxy_update...........................117 log off .............................................68 on, log on........................................68 set [lob_]compression.....................75

    alter encryption key..............................37 add encryption..........................37, 38 as default........................................37 drop encryption...............................38 modify encryption ...........................38 modify owner ..................................37 recover encryption ..........................38 regenerate key................................38

    alter login.......................................76, 77 alter login profile ..................................80 alter materialized view .........................44

    alter precomputed result set ................ 44 alter role .............................................. 82 alter table

    add (column) .................................. 31 add constraint .......................... 41, 42 add partition ................................... 34 decrypt ........................................... 38 disable trigger ................................ 46 drop................................................ 32 drop constraint ............................... 42 drop partition .................................. 34 enable trigger ................................. 46 encrypt ........................................... 38 lock .............................................. 120 merge partition ............................... 34 modify ............................................ 32 modify owner.................................. 98 move partition ................................ 34 partition .......................................... 34 partition by ..................................... 33 replace ........................................... 42 set dml_logging.............................. 32 set transfer table ............................ 32 split partition................................... 34 unpartition ...................................... 34

    alter thread pool .................................. 89 altermessage, sp_............................... 95 alterws, sp_dbcc_ ............................. 100 and (operator) ..................................... 12 ANSI join ............................................. 30 ansi_permissions, set.......................... 54 ansinull, set ......................................... 54 any (subquery operator) ...................... 29 AP, AQP.....................See abstract plans APL (allpages lock scheme).............. 120 application context .............................. 17 application tracing ......................... 20, 59 archive databases ................... 67, 69, 73 arithabort arith_overflow, set ............... 54 arithabort numeric_truncation, set ....... 54 arithignore, set .................................... 54 ascii() .................................................. 15 ascinserts.................................... 43, 108 ASE editions

    Cluster Edition (CE) ..................... 104 Developer Edition......................... 146 Enterprise Edition (EE)................. 146 Express Edition ............................ 146 Small Business Edition (SBE) ...... 146

    ASE environment variables ............... 138 ASE licensing.................................... 146 ASE limits.......................................... 145 ASE resources on the Internet .............. 9 asecfg ............................................... 133 asehostname() .................................... 18 asin() ................................................... 23 aspects................................................ 12 async log service (DB option).............. 68 atan()................................................... 23 atn2()................................................... 23 AUDIT PROCESS thread.................. 124 audit queue size (config) ................... 124 audit, sp_ .......................................... 124 audit_event_name() .................... 17, 126 auditing ............................................. 123 auditing (config)................................. 124 auditinit.............................................. 133 authentication method ........17, 76, 78, 80 authmech().......................................... 17 auto identity (DB option)................ 36, 69 auto_temptable_stats, set ................... 56

  • 150 The Complete Sybase ASE Quick Reference Guide

    autoconnect, sp_ ............................... 118 autoformat, sp_ ................................... 60 automatic cluster takeover (config).... 104 automatic master key access (config).. 39 avg() (aggregate)................................ 26

    B background, set................................... 58 Backup Server..................................... 72

    in ASE CE .................................... 104 backups (dumps)................................. 71 backupserver..................................... 131 bcksrvr.exe........................................ 131 bcp .................................................... 133 bcp (fast/normal) ............................... 144 bcp (identity columns).......................... 36 begin transaction ................................. 52 beginend.......................................... 48 between (operator) .............................. 12 biginttohex() ........................................ 11 bind objects to cache, sp_bindcache... 88 bindcache, sp_ .................................... 88 bindefault, sp_..................................... 45 bindexeclass, sp_................................ 90 bindmsg, sp_................................. 42, 95 bindrule, sp_........................................ 45 bintostr() .............................................. 11 bit operators ........................................ 13 block device .................................. 18, 66 break ................................................... 50 buffer pools ......................................... 87 buildmaster........................................ 131 builtin date strings (config)................... 11 builtin_date_strings, set....................... 11 bulk array size, set ............................ 119 bulk batch size, set............................ 119 Business Suite.. See SAP Business Suite bypass recovery ........................ 112, 114 bytes, dbcc ........................................ 108

    C cache overhead, with sp_helpcache.... 88 cache partitions ................................... 88 cache wizard (sp_sysmon) .................. 93 cache_usage()..................................... 17 cacheconfig, sp_ ........................... 87, 88 cachedataremove, dbcc .................... 108 cachelets .................See cache partitions cacheremove, dbcc ........................... 108 caches................................................. 87 cachestrategy, sp_ .............................. 88 caching query plans............................. 59 capture missing statistics (config)........ 58 case expression .................................. 48 case-(in)sensitive identifiers ................ 11 cast() ................................................... 11 catalog stored procedures ................. 143 CE .............................See Cluster Edition ceiling()................................................ 22 certificates, SSL .................................. 98 chained, set................................. 53, 135 change ownership

    for databases ................................. 69 for objects....................................... 98

    change password ................................ 78 changedbowner, sp_ ........................... 69 changegroup, sp_................................ 81

    char() ...................................................15 char_convert, set .................................96 char_length()........................................15 character device.............................18, 66 character set

    install/change..................95, 134, 137 charindex()...........................................15 charset (utility)....................................134 check (constraint)...........................41, 42 check option, create viewwith ...........43 check password for digit (config)..........78 checkalloc, dbcc.................................106 checkcatalog, dbcc ............................106 checkdb, dbcc....................................106 checkindex, dbcc ...............................106 checknames, sp_.................................96 checkpoint............................................53 checkreswords, sp_ .............................60 checksource, sp_.................................61 checkstorage, dbcc ............................106 checktable, dbcc ................................106 checkverify, dbcc ...............................106 chgattribute, sp_ .. 25, 33, 35, 36, 41, 120 ciphertext, set ......................................39 cis bulk insert array size (config) ........119 cis bulk insert batch size (config) .......119 cis connect timeout (config) ...............116 cis hafailover (server option) ..............117 cis idle connection timeout (config) ....116 cis packet size (config).......................119 cis rpc handling (config) .............115, 119 CIS RPCs ..........................................115 CIS(Component Integration Services)116 cis, dbcc.............................................108 cis_rpc_handling, set .................115, 119 cleanpwdchecks, sp_...........................79 cleanup, dbcc tune.............................108 clearpsexe, sp_....................................90 clearstats, sp_......................................98 client cursor .........................................50 client password encrypt...97,116,117,133 client programs ..................................133 client_addr, sp_....................................60 clientapplname, set ..............................58 clienthostname, set ..............................58 clientname, set.....................................58 close ....................................................51 close on endtran, set............................51 Cluster Edition (CE) ...........................104 cluster heartbeat interval (config) .......104 cluster heartbeat retries (config).........104 cluster vote timeout (config) ...............104 cluster, sp_ ........................................104 clustered ........................................40, 41 cmdtext (auditing) ..............................124 cmp_all_qplans, sp_ ..........................128 cmp_qplans, sp_................................128 coalesce() ............................................49 col_length() ..........................................17 col_name()...........................................17 column default cache size (config) .......32 Column encryption ...............................36 column_privileges, sp_.......................143 columns, sp_......................................143 combo (dbccdb exclusions)................100 command.............................................87 command_status_reporting, set .........107 Comment delimiters .............................12 comments ............................................12 commit .................................................52 common.loc (file)..................................14

  • ASE versions 15.0, 15.5 & 15.7 151

    commonkey, sp_ ...............................143 compare() ............................................15 compatibility_mode, set .......................56 compatmode, sp_ ................................56 complete_xact, dbcc ..........................107 Component Integration Services(CIS)116 compression info pool size (config)......75 compression memory size (config) ......69 compression, data ...............................75 compute (clause) .................................29 computed column ........................32, 134 concurrency_opt_threshold..................42 config_dump, sp_ ................................74 config_rep_agent, sp_ .......................129 configreport, sp_dbcc_ ......................100 configuration file (config)......................86

    recreating .......................................86 Configuration parameters

    abstract plan cache ......................128 abstract plan dump .......................127 abstract plan load .........................127 abstract plan replace ....................128 additional network memory.............97 allocate max shared memory..........87 allow nested triggers.......................46 allow procedure grouping ...............47 allow remote access ...............72, 115 allow resource limits .....................122 allow sendmsg................................21 allow sql server async i/o..............102 allow updates to system tables .......97 audit queue size ...........................124 auditing.........................................124 automatic cluster takeover............104 automatic master key access..........39 builtin date strings...........................11 capture missing statistics................58 check password for digit .................78 cis bulk insert array size ...............119 cis bulk insert batch size...............119 cis connect timeout.......................116 cis idle connection timeout............116 cis packet size ..............................119 cis rpc handling..................... 115, 119 cluster heartbeat interval ..............104 cluster heartbeat retries ................104 cluster vote timeout ......................104 column default cache size ..............32 compression info pool size .............75 compression memory size ..............69 configuration file .............................86 cost of a cpu unit ............................57 cost of a logical io ...........................57 cost of a physical io ........................57 cpu grace time..............................102 current audit table.........................124 deadlock retries ............................120 default character set id .............95, 96 default database size......................67 default exp_row_size percent .........43 default fill factor percent..................43 default language id .........................95 default network packet size ............97 default sortorder id....................95, 96 default unicode sortorder ................96 deferred name resolution................58 disable character set conversion ....96 disable disk mirroring......................67 disable varbinary truncation............10 disk i/o structures............................97 displaying non-defaults ...................86

    dump on conditions ...................... 130 dynamic allocation on demand....... 87 enable async database init............. 68 enable backupserver HA........ 72, 104 enable cis..................................... 116 enable compatibility mode.............. 56 enable compression ....................... 75 enable concurrent dump tran.......... 74 enable console logging................. 102 enable dump history....................... 74 enable encrypted columns ............. 36 enable file access......................... 118 enable functionality group .............. 59 enable granular permissions .... 81, 85 enable housekeeper GC ................ 94 enable hp posix async i/o ............. 102 enable i/o fencing ......................... 104 enable inline default sharing........... 45 enable java..................................... 62 enable literal autoparam................. 59 enable logins during recovery......... 97 enable merge join........................... 56 enable metrics capture................. 129 enable monitoring........................... 99 enable pci....................................... 62 enable permissive unicode............. 96 enable plan sharing........................ 59 enable predicated privileges........... 84 enable rep agent threads ............. 129 enable row level access ........... 85, 86 enable semantic partitioning........... 33 enable sort-merge joins and JTC ... 57 enable sql debugger..................... 138 enable ssl....................................... 97 enable surrogate processing .......... 96 enable unicode conversions........... 96 enable unicode normalization......... 96 enable xml...................................... 63 enforce dump configuration............ 74 extended cache size ...................... 88 FIPS login password encryption ..... 97 global cache partition number ........ 88 heap memory per user ................. 102 histogram tuning factor................... 92 housekeeper free write percent .... 102 i/o batch size ................................ 102 i/o polling process count............... 102 identity burning set factor ............... 36 identity grab size ............................ 36 identity reservation size.................. 36 idle migration timeout ................... 104 kernel mode ................................... 89 kernel resource memory................. 89 license information ....................... 147 lock address spinlock ratio ........... 102 lock hashtable size....................... 102 lock scheme ................................. 120 lock shared memory......