Guia de Sybase

download Guia de Sybase

of 36

Transcript of Guia de Sybase

  • 8/9/2019 Guia de Sybase

    1/36

    The Complete Sybase ASE

    Quick Reference Guide

    ASE versions 15.0, 15.5 & 15.76

    thedition

    These pages are taken from "The Complete

    Sybase ASE Quick Reference Guide", as asample of the contents. Note that the origi-nal page size is 11 by 22 cm (4.3 by 8.6inch).The complete book can be orderedfrom http://www.sypron.nl/qr .

    Rob Verschoor

    Sypron Publications

  • 8/9/2019 Guia de Sybase

    2/36

    2 The Complete Sybase ASE Quick Reference Guide

    The Complete Sybase ASE Quick Reference GuideASE versions 15.0, 15.5 & 15.76

    thedition

    by Rob Verschoor

    ISBN 978-90-806117-1-9

    Published by:Sypron B.V.Het Wolfseind 243823 VS AmersfoortThe NetherlandsInternet www.sypron.nlEmail [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 permissionof 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 forerrors or omissions, nor do they accept any liabilities for damages resulting from theuse of the information herein.

  • 8/9/2019 Guia de Sybase

    3/36

    ASE versions 15.0, 15.5 & 15.7 3

    ContentsIntroduction.................................................................................................. 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............................................................................. 7Undocumented commands: warning & disclaimer ...................................................... 7

    Starting Points For Common DBA Tasks .................................................... 8

    Developer Topics....................................................................................... 101 Datatypes.......................................................................................................10

    1.1 Datatype conversion functions................................................................... 11

    2 Identifiers .......................................................................................................11

    3

    Quotes & Comments......................................................................................124 Operators .......................................................................................................12

    5 Built-in Functions............................................................................................135.1 Date & Time functions ............................................................................... 135.2 Date/time formatting .................................................................................. 145.3 String functions .......................................................................................... 145.4 System functions ....................................................................................... 175.5 Mathematical functions .............................................................................. 225.6 Trigonometric functions ............................................................................. 235.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 .......................................................................................268 DML statements .............................................................................................27

    8.1 Select statement ........................................................................................ 278.2 Subqueries................................................................................................. 298.3 Joins, ANSI Joins & Outer Joins................................................................ 298.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 ..........................................................................................................4011 Referential Integrity Constraints .....................................................................4112 Object storage properties ...............................................................................4213 Views .............................................................................................................4314 Materialized Views/Precomp.result sets(15.7 ESD#2)....................................4415 Rules & Defaults ............................................................................................4516 Triggers..........................................................................................................46

    17

    Stored Procedures .........................................................................................47

    18

    SQL Functions (15.0.2) ..................................................................................48

    19 Programming & flow control ...........................................................................4820 Cursors ..........................................................................................................50

    20.1 Example of cursor programming................................................................ 52

    21 Transactions ..................................................................................................5221.1 Example of transaction programming ........................................................ 53

    22 Settings affecting ASE query behaviour .........................................................5422.1 Settings affecting query results.................................................................. 5422.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 ........................................... 5722.6 Miscellaneous settings............................................................................... 58

    23 Statement cache ............................................................................................5924 Commonly used system stored procedures....................................................6025 Java in ASE (SQLJ) .......................................................................................6126 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..................................................................6728.1 Temporary databases ................................................................................ 7028.2 Segments................................................................................................... 7028.3 Thresholds ................................................................................................. 71

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

  • 8/9/2019 Guia de Sybase

    4/36

    4 The Complete Sybase ASE Quick Reference Guide

    30 Data Compression (15.7) ...............................................................................7531 Logins & Users...............................................................................................76

    31.1 Logins (server-level 'users') .......................................................................7631.2 Passwords..................................................................................................7831.3 Login profiles (15.7) ...................................................................................8031.4 Database-level users .................................................................................8031.5

    Roles ..........................................................................................................8132 Permissions (grant/revoke) ............................................................................83

    32.1 Classic permissions ...................................................................................8332.2 Granular permissions (15.7 ESD#2)+ ........................................................8532.3 Row-level access control (access rules)....................................................85

    33 Managing configuration parameters...............................................................8634 Memory allocation..........................................................................................87

    34.1 Named caches & buffer pools ....................................................................87

    35 CPUs/Cores, Engines & Threads (15.7).........................................................8835.1 Logical Process Manager ('Execution Classes') ........................................90

    36

    Update statistics.............................................................................................9037 sp_sysmon.....................................................................................................93

    38 Reorg.............................................................................................................9339 Languages & messages.................................................................................9440 Character set & sort order..............................................................................95

    40.1 Unicode ......................................................................................................96

    41 Miscellaneous DBA commands & config parameters.....................................9642 DBA tools.......................................................................................................9843 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............................................................................. 10246 Advanced configuration parameters.............................................................10247 Configuring parallel query processing ..........................................................103

    47.1 Parallel index creation..............................................................................103

    48 ASE Cluster Edition (CE) .............................................................................10449 Supported DBCC commands.......................................................................10650 Unsupported DBCC commands...................................................................10851

    ASE Traceflags............................................................................................11352 Accessing data located outside ASE............................................................115

    52.1 Configuring remote access with RPCs ....................................................11552.2 Configuring remote access with CIS........................................................11652.3 Component Integration Services (CIS) features ......................................116

    53 Locking ........................................................................................................12053.1 Transaction isolation levels ......................................................................12153.2 Lock promotion.........................................................................................121

    54 Resource limits ('Resource Governor').........................................................12255 XP Server ....................................................................................................12356

    Auditing........................................................................................................12357 Database recovery.......................................................................................126

    58 Abstract Plans..............................................................................................12759 Query metrics capture..................................................................................12860 Replication Server........................................................................................12961 Job Scheduler..............................................................................................12962 Shared memory dumps................................................................................129

    Miscellaneous Topics .............................................................................. 13163 The interfaces file.........................................................................................13164

    Server programs..........................................................................................13165 Client programs............................................................................................133

    66 ASE environment variables..........................................................................13867 Running servers as Windows services.........................................................13968 Global variables ...........................................................................................139

    68.1 Session-specific global variables .............................................................13968.2 Server-wide & non-static global variables................................................14168.3 Server-wide & static global variables .......................................................142

    69 Logical keys .................................................................................................14370 Catalog stored procedures...........................................................................14371

    Issues with BCP-in.......................................................................................14472 Minimally logged operations.........................................................................144

    73 Monitor Server & Historical Server (pre-15.7)...............................................14474 ASE limits ....................................................................................................14575 ASE license manager & license options.......................................................146

    Index ........................................................................................................ 148

  • 8/9/2019 Guia de Sybase

    5/36

    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) orTable of Contents (p.3) if a topic is not listed here.On Windows, read sqlsrvr.exeinstead 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 licenseoptions Generate license keys & put in license file (p.146)

    Get a free version of ASE Developer/Express Ed., seewww.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-moption 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 servicemanager (p.139)

    Connect to an ASE server isqlutility (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 forSAP Business Suite

    @@sbssav (p.143) ordataserver --sbssav(p.132)

    Find the ASE edition sp_lmconfig(p.146)

    Find version of system procs sp_version(p.99) (=versionofinstallmasteretc.)

    Find the ASE server's IPaddress and port number

    In a running server, use sp_listener'status'(p.98); orlook in the interfacesfile (p.131)

    Add a user to ASE create loginor sp_addlogin(p.76) to allow access tothe ASE server; sp_adduser orsp_addalias(p.80) toallow access to an ASE database

    Change a login password sp_passwordor alter loginwith passwd(p.78)List all databases in an ASEserver

    sp_helpdb(p.69), without parameters

    List all tables/objects in anASE database

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

    Display free/used space inan ASE database

    sp_spaceused (p.33) without database namesp_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 storedprocs, views, triggers, etc.

    sp_showtext, sp_helptext (p.61)defncopyutility (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 databasefrom backups

    load database &load transaction(p.71), followed byonline database

    Information about databasedevices

    sp_helpdevice(p.67)

    Create an ASE database disk init (

    p.66) andcreate 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 configurationparameters

    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 andresource 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 forSybase TechSupport

    sybdiagutility (p.137)

    Find ASE limits p.145

  • 8/9/2019 Guia de Sybase

    6/36

  • 8/9/2019 Guia de Sybase

    7/36

  • 8/9/2019 Guia de Sybase

    8/36

    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. optionscan be: keylengthlength - key length in bits; for AES: 128(=default), 192or 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). Beforethe key can be used, set encryption passwd must be executed. NB: a lostpassword 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 twopasswords (for PCI compliance). Without with passwd, the key is protected bythe 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_controlis ignoredwhen a master or dual master key is created.

    Note: to index an encrypted column, init_vector NULLand pad NULLare 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] withpasswd 'key_passwd'alter encryption key[ dual] masterwithpasswd 'old_passwd'

    modify encryption withpasswd '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 passwdabove.With dual, creates a dual master key in the current database, which is used togetherwith the master key to encrypt encryption keys that are created with the dual_controloption 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 encryptionpasswd) before data can be encrypted/decrypted. When using unattended startupmode with the master key startup file, this is not needed. This requires running alterencryption keyfor automatic_startup (p.38) for the (dual) master key, andenabling the config setting 'automatic master key access'.Example: create encryption key master with passwd 'S3cret'

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

    drop encryption key key_nameDrops the specified encryption key, including all its key copies. No columns or keysmust be encrypted with the key.

    alter encryption key key_name remainder-of-commandModifies the specified encryption key or key copy. The remainder of the commandcan be as follows:

    as[ not] default- when marked as default, this key will be used for encryptedcolumns 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 keyfor exclusive use by the specified user. A key copy is identical to the originalkey, but is protected with a different password, and accessible only by the des-ignated user. orig_passwdis the key's original password, known only to the keyowner/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; noencrypted data can be accessed through it. The designated user should betrustworthy, modify the password, and keep it in a safe place. To find recoverykey copies, run sp_encryptionwith helpcolor helpuser, and key_copy.

    with passwd 'passwd' add encryption for user 'user_name' forlogin_association - creates a key copy for the specified user, encrypted withthe user's login password.passwdis the key's original password, known only tothe key owner/key custodian.

  • 8/9/2019 Guia de Sybase

    9/36

    50 The Complete Sybase ASE Quick Reference Guide

    raiserror error_nr [,value_list ]raiserror error_nr {'format_string'|@variable }][,value_list ][witherrordatalist ]With a comma following error_nr,the corresponding message in the session's currentlanguage will be retrieved, formatted using values in value_list, and printed. For sys-tem-defined messages (in master..sysmessages), error_nrmust be between 17000

    and 19999; for user-defined messages (in sysusermessages in the current data-base), error_nrmust be 20000.format_string or @variable are used to format and display a message. Without acomma 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 raiserrorcompletes, @@errorwill contain the value of error_nr. The clausewith errordatalist 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 thereturn value of the procedure or function. If the expression involves a query, this mustevaluate to a single integer value. For procedures, ASE uses negative return valuesto indicate certain types of errors; therefore, don't use these in your SQL code. Whenthe APclause is used, the parentheses ( '(' and ')' ) are mandatory. See the whilestatement for more information about this optionalAPclause.

    waitfor delay'hh:mm:ss[.cccuuu]' / waitfor delay@variablewaitfor time'hh:mm:ss' / waitfor time@variableWaits for a while. delaywaits for the specified interval (max. 24 hours); timewaitsuntil the specified time (max. 24 hours away). The number of concurrent waitforstatements is limited by config setting 'number of alarms' (dynamic); default=40.

    whilelogical_expression [AP ]T-SQL-statementIf logical_expression is true, executes T-SQL-statement in a loop until the expressionis no longer true, or until the loop is exited via a break, returnor gotostatement.Example: while @i < 100 begin exec my_proc select @i = @i + 1 end

    If the expression involves a query, APcan specify the abstract plan for this query asplan '(AP-language )'; p.127 for info on abstract plans.

    breakExits from a while-loop; execution continues at the first statement after the loop.

    continueReturns 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. usecannot be used in stored procedures ortriggers. The use of @character_variable is undocumented.Also note: system storedprocedures can access other databases without changing the current databasethough 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 andexecute cursor - defined on the client side and implemented

    though OpenClient (typically in a C-program) or Embedded SQL. These cursorscan 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] cursorforselect_statement [for{readonly|update[ofupdated_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). Withscroll, 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 thecursor; with insensitive (=behaviour in pre-15), such changes are not visible. Trace-

  • 8/9/2019 Guia de Sybase

    10/36

    ASE versions 15.0, 15.5 & 15.7 63

    the related classes are dropped as well, unless retainclassesis 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, likejdb(requires installing theJDK). See the ASE manual Java in Adaptive Server Enterprisefor details.

    26 XML (XPath/XQuery/SQLX) in ASE

    ASE processes XML natively, with support for XPath queries (p.65). For full detailson XML/XPath/SQLX, see the manualXML 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_XMLlicense option.

    selectrest of statementfor xml [schema |all ][returnsdatatype] [ option'sqlx_options'] }For a select statement only, specifying for xml converts the SQL result set to aSQLX-XML document. returnscan only be used when the selectis a subquery.for xml schema generates the XML schema describing the result set generated byfor xml, but not the result set data itself; for xml allgenerates 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'] returnsdatatype ] )Extracts elements from the XML document, based on the XPath query, returning ascalar value. xmlextract() can be used in expressions and predicates (also seexmltable()(below), which can be used in the fromclause).By default, the result is returned as an XML document; when /text()is appended, theoutermost XML tags are removed. By default, the result datatype is text, unlessspecified otherwise (as an ASE datatype or as java.lang.String) with returns. op-tionscan be xmlerrorand ncr(see sqlx_optionsbelow). In 15.7, local variables andparameters can be of type textor imagewhich 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 imagevalue. Parsed XML data can beaccessed 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 validatedagainst an embedded DTD. Example:

    create table my_tab (my_col int, xml_col image NULL)insert my_tab values (123, xmlparse('Hello')) -- parsed XMLinsert my_tab values (456, 'Bonjour') -- raw XML

    xmlrepresentation ( image_column)

    Determines if an imagecolumn 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' xmltestxml_doc[ option'options']xmltestevaluates to true or false (or NULL), after applying the XPath query againstthe XML document. This can be used like a logical expression, for example in awhereclause, caseexpression, ifstatement etc. To negate the result, use not.optionscan be xmlerror(messageand NULLonly); see sqlx_optionsbelow.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 orsubquery), returning a table that must be used as a derived table in the fromclause.xmltable() can be seen as providing a relational view onXML data.Also, itsimplifies

  • 8/9/2019 Guia de Sybase

    11/36

    ASE versions 15.0, 15.5 & 15.7 77

    login), enables (add) or disables (drop) that the roles are activated when the userlogs into ASE. Default=not activated. System roles are always activated. all = allroles. When multiple roles are listed, they must be comma-separated.

    (15.7)alter loginlogin_namedropattribute [attribute]

    Removes one or more attribute settings for an existing login, reverting to the defaultsetting. See alterloginmodifyfor attributes that can be modified.Example: alter login jsmith drop login script min passwd length

    (15.7)drop loginlist_of_login_names [with override]sp_droploginlogin_name [(15.7) ,1]Drops a login. drop login can drop multiple (comma-separated) logins. This failswhen a login is still mapped to a database user and/or owns objects; in this case, usethe stored proc sp_rv_helplogin (from www.sypron.nl/new_ssp.html) to help re-solve the problem; in 15.7, sp_helpuser, display_objectalso gives some info.

    drop loginwith override and sp_droplogin with 1 as 2nd parameter will drop alogin 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 canalso be set with sp_modifylogin). In 15.7, use create loginwhich has more options.

    sp_modifyloginlogin_name,attribute,'value'Modifies attributes of the specified login. In 15.7, use alter login instead. Possiblevalues forattributeare below; see the corresponding attributes for alter login/createloginas indicated with 'see'. Note that valuemust always be quoted. 'fullname' (seefullname), 'defdb'(see default database), 'deflanguage' (see

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

    For 'login script', see login script; also, specify value = NULL to drop thesetting, 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', seealter loginadd/drop autoactivated roles.

    When optionis '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 valueis '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 currentsession's login. In 15.0.2, the login name may contain wildcards; also, the login's suidnumber may be specified (as a quoted string). To display all existing logins, use thisquery: 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_logintriggeris 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 thecurrent session's login ID or login name.

    set proxylogin_nameset session authorizationlogin_nameChanges the current session's login name (suid) to login_name, inheriting all rolesand permissions granted to login_name. To return to the session's original loginname, specify the original login_name. The inherited roles can be restricted with grantset proxyrestrict role(p.83).Before set proxycan be used, a user with sso_rolemust execute grant set proxy in

  • 8/9/2019 Guia de Sybase

    12/36

    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 ASEserver, run sp_indsuspect to check for invalid indexes and sp_tab_suspectptn tocheck 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, thedefault 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_checknamesDisplays all identifiers in the current database that contain non-7-bit-ASCII characters.

    sp_helpsortDisplays 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 theserver sort order. Suspect indexes can be fixed by running dbcc reindex.

    set char_converton[with{error|no_error}]set char_convert offset char_convert character_set[with{error|no_error}]Defines conversion between the character sets of server and client. on (=default)enables character set conversion; offdisables it; character_set explicitly specifies theclient character set to convert to. with no_error specifies that no error message is

    raised forconversionerrors(ASE-to-clientonly);default=with error. @@char_convertindicates if character set conversion is currently in effect (1) or not (0).

    The global variables @@maxcharlen, @@ncharsize, @@client_csexpansion@@client_csname,@@client_csidare also related to character sets (p.140).

    40.1 UnicodeTo store Unicode data in [var]char or text data, configure ASE with the utf8characterset. Datatypes uni[var]char and unitext, which store UTF-16 values, and Unicodenotation (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', 'enablesurrogate processing'- all dynamic, and 0or 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 atposition 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 firstcharacter in the Unicode expression.

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

    41 Miscellaneous DBA commands & config parameters

    killspid [ with trace]killspidwith statusonlyKills the specified session. The undocumented option with traceprints a stacktracefor the killed session to the errorlog (this may not always work). killwith statusonlydoes not kill, but only reports progress while the session is performing a rollback.

  • 8/9/2019 Guia de Sybase

    13/36

    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 alsobe 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, providedthis is supported by the platform; starting with engine 0, engines are bound toCPU 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 itwon'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 fordevice 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/obatch size'(p.102).

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

    grant role sybase_ts_role to saset role sybase_ts_role on

    dbcc help(command )Displays syntax info for the specified dbcccommand.

    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 asmasks in dbcc bytes(address,printopt,structure_name). Specify -1 forprintopt.

    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 commandsfail 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(likea Backup Server).

  • 8/9/2019 Guia de Sybase

    14/36

  • 8/9/2019 Guia de Sybase

    15/36

    132 The Complete Sybase ASE Quick Reference Guide

    [-H] specified when using the High Availability feature (ASE_HA)[-Kkeytab_file] keytab filename (when using DCE)[-kprincipal_name ] (15.0.2) server's principal name (used with Kerberos)[-Nlic_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 ontheconsole) forthe specified login (which must have been granted sso_role)[-urole_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[-npermission] (15.7 ESD#2)list (max.10) unlocked logins with (granular)permission[-q] databases 'created'via quiesce database for externaldump

    remain offline (so log dumps can be loaded)[-X] start a diagnostic tool known as 'sybmon'[-bsizek|K|m|M|g|G|t|T] (build) size of masterdevice to create

    [-f[orcebuild]] (build) use with -b, -wand -zto override an existing situation[-w db_name] (build) rewrites specified database (only masteror model)[-zpage_sizek|K] (build) server page size (2k, 4k, 8k, or 16k)[-Dsizek|K|m|M|g|G] (build) default database size (for model and tempdb)[-Zsizek|K|m|M|g|G] (build) size of masterdatabase[-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 overwritesa 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 + masterdevice[--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 TechnicalSupport.

    (pre-15.7) monserver(Windows:monsrvr.exe) - Monitor Server-MMon_server_name name of the Monitor Server-SASE_server_name name of the ASE server to monitor-Ulogin_name login into the ASE server; also a login into Monitor Server[-Ppassword] password for login_name[-E] don't overwrite an exiting .mrgfile[-O] overwrite an exiting .mrgfile[-iinterfaces_file] interfaces file pathname (default=$SYBASE/interfaces)[-lerrorlog_file] Monitor Server errorlog (default=ms.log)

    [-Lconfig_file] Monitor Server configuration file[-msharedmem_dir] ASE server shared memory directory[-nmax_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-Dhome_directory directory containing control file and recorded data files[-SHist_server_name] name of the Historical Server[-Ulogin_name] Historical Server super-user login (to execute hs_commands)[-Ppassword] password for super-user login[-iinterfaces_file] interfacesfile pathname (default=$SYBASE/interfaces)[-lerrorlog_file] Historical Server errorlog (default=hs.log)[-nmax_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; locatedin $SYBASE/$SYBASE_ASE/install.[-fRUN_server_file] [-f ] file name of the RUN_servernamefile; multiple allowedExample: startserver -f RUN_PROD

  • 8/9/2019 Guia de Sybase

    16/36

    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 examplecheckdb, dbccrefers to dbcc checkdb, and showplan, setto set showplan.

    Keywords followed by (config) are server configuration options, settable withsp_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.......................................51in 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) ..........68abs() ....................................................22

  • 8/9/2019 Guia de Sybase

    17/36

    ASE versions 15.0, 15.5 & 15.7 149

    abstract plan (show) ............................58abstract plan cache (config)...............128abstract plan dump (config) ...............127abstract plan load (config)..................127abstract plan replace (config).............128

    abstract plans ....................................127abstract query plan .... See abstract plansaccess rules...................................45, 86acos() ..................................................23acronyms used in this book ...................6activeroles, sp_....................................82add_qpgroup, sp_..............................128add_resource_limit, sp_.....................122add_time_range, sp_.........................122addalias, sp_ .......................................81

    addauditrecord, sp_...........................124addaudittable, sp_ .............................124addengine, sp_....................................90addexeclass, sp_.................................90addextendedproc, sp_ .......................123addexternlogin, sp_ ...........................117addgroup, sp_......................................81additional network memory (config) .....97addlanguage, sp_................................94addlogin, sp_ .......................................77addmessage, sp_ ................................95addobjectdef, sp_ ..............................119addremotelogin, sp_ ..........................115addsegment, sp_.................................71addserver, sp_...........................115, 116addtempdb, dbcc...............................108addthreshold, sp_................................71addtype, sp_........................................10addumpdevice, sp_..............................67

    adduser, sp_........................................81aggregate functions .............................26all (opposite of distinct) (operator)........27all (subquery operator).........................29allocate max shared memory (config) ..87allocdump, dbcc.................................108allocinfo().............................................19allow nested triggers (config), ..............46allow nulls by default (DB option).........68allow procedure grouping (config)........47

    allow remote access (config) ....... 72, 115allow resource limits (config)..............122allow sendmsg (config) ........................21allow sql server async i/o (config) ......102allow updates to system tables (conf) ..97allow wide dol rows (DB option)...........68allow_dup_row.....................................40allpages (lock scheme)......................120allrows_dss (optgoal)...........................55allrows_mix (optgoal)...........................55allrows_oltp (optgoal)...........................55alter database

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

    alter encryption key..............................37add encryption..........................37, 38as default........................................37

    drop encryption...............................38modify encryption ...........................38modify owner ..................................37recover encryption ..........................38regenerate key................................38

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

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

    add (column).................................. 31add constraint .......................... 41, 42

    add partition ................................... 34decrypt ........................................... 38disable trigger ................................ 46drop................................................ 32drop constraint ............................... 42drop partition .................................. 34enable trigger ................................. 46encrypt ........................................... 38lock .............................................. 120merge partition ............................... 34

    modify ............................................ 32modify owner.................................. 98move partition ................................ 34partition .......................................... 34partition by ..................................... 33replace........................................... 42set dml_logging.............................. 32set transfer table ............................ 32split partition................................... 34unpartition ...................................... 34

    alter thread pool .................................. 89altermessage, sp_............................... 95alterws, sp_dbcc_ ............................. 100and (operator) ..................................... 12ANSI join............................................. 30ansi_permissions, set.......................... 54ansinull, set ......................................... 54any (subquery operator) ...................... 29AP, AQP.....................See abstract plans

    APL (allpages lock scheme).............. 120application context .............................. 17application tracing ......................... 20, 59archive databases................... 67, 69, 73arithabort arith_overflow, set ............... 54arithabort numeric_truncation, set ....... 54arithignore, set .................................... 54ascii() .................................................. 15ascinserts.................................... 43, 108ASE editions

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

    ASE environment variables............... 138ASE licensing.................................... 146ASE limits.......................................... 145ASE resources on the Internet .............. 9asecfg ............................................... 133asehostname() .................................... 18asin()................................................... 23aspects................................................ 12async log service (DB option).............. 68atan()................................................... 23atn2()................................................... 23AUDIT PROCESS thread.................. 124audit queue size (config) ................... 124audit, sp_ .......................................... 124

    audit_event_name() .................... 17, 126auditing ............................................. 123auditing (config)................................. 124auditinit.............................................. 133authentication method........17, 76, 78, 80authmech().......................................... 17auto identity (DB option)................ 36, 69auto_temptable_stats, set ................... 56

  • 8/9/2019 Guia de Sybase

    18/36

    150 The Complete Sybase ASE Quick Reference Guide

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

    B

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

    in ASE CE .................................... 104backups (dumps).................................71backupserver..................................... 131bcksrvr.exe........................................ 131

    bcp .................................................... 133bcp (fast/normal) ............................... 144bcp (identity columns).......................... 36begin transaction ................................. 52beginend..........................................48between (operator) .............................. 12biginttohex() ........................................11bind objects to cache, sp_bindcache... 88bindcache, sp_ .................................... 88bindefault, sp_.....................................45

    bindexeclass, sp_................................90bindmsg, sp_................................. 42, 95bindrule, sp_........................................45bintostr().............................................. 11bit operators ........................................13block device .................................. 18, 66break ................................................... 50buffer pools .........................................87buildmaster........................................ 131builtin date strings (config)................... 11builtin_date_strings, set.......................11bulk array size, set ............................ 119bulk batch size, set............................ 119Business Suite.. See SAP Business Suitebypass recovery ........................ 112, 114bytes, dbcc........................................ 108

    C

    cache overhead, with sp_helpcache.... 88cache partitions ................................... 88cache wizard (sp_sysmon) .................. 93cache_usage().....................................17cacheconfig, sp_ ........................... 87, 88cachedataremove, dbcc .................... 108cachelets.................Seecache partitionscacheremove, dbcc ...........................108caches.................................................87

    cachestrategy, sp_ .............................. 88caching query plans............................. 59capture missing statistics (config)........ 58case expression .................................. 48case-(in)sensitive identifiers ................ 11cast() ................................................... 11catalog stored procedures ................. 143CE.............................See Cluster Editionceiling()................................................ 22certificates, SSL .................................. 98

    chained, set................................. 53, 135change ownership

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

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

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

    install/change.................. 95, 134, 137charindex()...........................................15charset (utility)....................................134check (constraint)...........................41, 42check option, create viewwith...........43check password for digit (config)..........78checkalloc, dbcc.................................106checkcatalog, dbcc ............................106checkdb, dbcc....................................106checkindex, dbcc ...............................106

    checknames, sp_.................................96checkpoint............................................53checkreswords, sp_ .............................60checksource, sp_.................................61checkstorage, dbcc............................106checktable, dbcc ................................106checkverify, dbcc ...............................106chgattribute, sp_ ..25, 33, 35, 36, 41, 120ciphertext, set ......................................39cis bulk insert array size (config) ........119cis bulk insert batch size (config) .......119cis connect timeout (config) ...............116cis hafailover (server option) ..............117cis idle connection timeout (config) ....116cis packet size (config).......................119cis rpc handling (config) .............115, 119CIS RPCs ..........................................115CIS(Component Integration Services)116cis, dbcc.............................................108

    cis_rpc_handling, set .................115, 119cleanpwdchecks, sp_...........................79cleanup, dbcc tune.............................108clearpsexe, sp_....................................90clearstats, sp_......................................98client cursor .........................................50client password encrypt...97,116,117,133client programs ..................................133client_addr, sp_....................................60clientapplname, set ..............................58

    clienthostname, set ..............................58clientname, set.....................................58close ....................................................51close on endtran, set............................51Cluster Edition (CE) ...........................104cluster heartbeat interval (config) .......104cluster heartbeat retries (config).........104cluster vote timeout (config) ...............104cluster, sp_ ........................................104clustered ........................................40, 41cmdtext (auditing) ..............................124cmp_all_qplans, sp_ ..........................128cmp_qplans, sp_................................128coalesce() ............................................49col_length() ..........................................17col_name()...........................................17column default cache size (config) .......32Column encryption...............................36column_privileges, sp_.......................143

    columns, sp_......................................143combo (dbccdb exclusions)................100command.............................................87command_status_reporting, set.........107Comment delimiters.............................12comments ............................................12commit .................................................52common.loc (file)..................................14

  • 8/9/2019 Guia de Sybase

    19/36

    ASE versions 15.0, 15.5 & 15.7 151

    commonkey, sp_ ...............................143compare() ............................................15compatibility_mode, set .......................56compatmode, sp_................................56complete_xact, dbcc ..........................107

    Component Integration Services(CIS)116compression info pool size (config)......75compression memory size (config) ......69compression, data ...............................75compute (clause).................................29computed column ........................32, 134concurrency_opt_threshold..................42config_dump, sp_ ................................74config_rep_agent, sp_ .......................129configreport, sp_dbcc_ ......................100

    configuration file (config)......................86recreating .......................................86

    Configuration parametersabstract plan cache ......................128abstract plan dump.......................127abstract plan load .........................127abstract plan replace ....................128additional network memory.............97allocate max shared memory..........87allow nested triggers.......................46allow procedure grouping ...............47allow remote access ...............72, 115allow resource limits .....................122allow sendmsg................................21allow sql server async i/o..............102allow updates to system tables.......97audit queue size ...........................124auditing.........................................124automatic cluster takeover............104

    automatic master key access..........39builtin date strings...........................11capture missing statistics................58check password for digit .................78cis bulk insert array size ...............119cis bulk insert batch size...............119cis connect timeout.......................116cis idle connection timeout............116cis packet size ..............................119cis rpc handling..................... 115, 119

    cluster heartbeat interval ..............104cluster heartbeat retries................104cluster vote timeout ......................104column default cache size ..............32compression info pool size .............75compression memory size ..............69configuration file .............................86cost of a cpu unit ............................57cost of a logical io ...........................57cost of a physical io ........................57cpu grace time..............................102current audit table.........................124deadlock retries ............................120default character set id .............95, 96default database size......................67default exp_row_size percent .........43default fill factor percent..................43default language id .........................95default network packet size ............97

    default sortorder id....................95, 96default unicode sortorder ................96deferred name resolution................58disable character set conversion ....96disable disk mirroring......................67disable varbinary truncation............10disk i/o structures............................97displaying non-defaults...................86

    dump on conditions ...................... 130dynamic allocation on demand....... 87enable async database init............. 68enable backupserver HA........ 72, 104enable cis..................................... 116

    enable compatibility mode.............. 56enable compression ....................... 75enable concurrent dump tran.......... 74enable console logging................. 102enable dump history....................... 74enable encrypted columns ............. 36enable file access......................... 118enable functionality group .............. 59enable granular permissions .... 81, 85enable housekeeper GC ................ 94

    enable hp posix async i/o ............. 102enable i/o fencing......................... 104enable inline default sharing........... 45enable java..................................... 62enable literal autoparam................. 59enable logins during recovery......... 97enable merge join........................... 56enable metrics capture................. 129enable monitoring........................... 99enable pci....................................... 62enable permissive unicode............. 96enable plan sharing........................ 59enable predicated privileges........... 84enable rep agent threads ............. 129enable row level access ........... 85, 86enable semantic partitioning........... 33enable sort-merge joins and JTC ... 57enable sql debugger..................... 138enable ssl....................................... 97

    enable surrogate processing .......... 96enable unicode conversions........... 96enable unicode normalization......... 96enable xml...................................... 63enforce dump configuration............ 74extended cache size ...................... 88FIPS login password encryption..... 97global cache partition number ........ 88heap memory per user ................. 102histogram tuning factor................... 92

    housekeeper free write percent .... 102i/o batch size................................ 102i/o polling process count............... 102identity burning set factor ............... 36identity grab size ............................ 36identity reservation size.................. 36idle migration timeout ................... 104kernel mode ................................... 89kernel resource memory................. 89license information ....................... 147lock address spinlock ratio ........... 102lock hashtable size....................... 102lock scheme................................. 120lock shared memory..................... 102lock spinlock ratio......................... 102lock table spinlock ratio ................ 102lock wait period ............................ 120log audit logon failure................... 102log audit logon success................ 102

    max buffers per lava operator......... 55max cis remote connections......... 116max concurrently recovered db .... 126max memory .................................. 87max native threads per engine ....... 89max nesting level ........................... 97max network packet size................ 97max number network listeners........ 98

  • 8/9/2019 Guia de Sybase

    20/36

    152 The Complete Sybase ASE Quick Reference Guide

    max online engines ........................89max parallel degree......................103max query parallel degree............ 103max repartition degree ................... 57max resource granularity................ 57

    max scan parallel degree ............. 103max transfer history........................ 31maximum dump conditions...........130maximum failed logins.................... 78memory ..........................................87memory dump compression level . 130metrics elap max ..........................129metrics exec max .........................129metrics lio max ............................. 129metrics pio max ............................ 129

    min pages for parallel scan........... 103minimum password length.............. 78net password encryption reqd ........97network polling mode ..................... 89non-defaults ................................... 86number of alarms ...........................50number of aux scan descriptors...... 42number of backup connections....... 74number of checkpoint tasks..........126number of devices ..........................66number of disk tasks ......................89number of dump threads .............. 130number of engines at startup.......... 89number of histogram steps............. 92number of java sockets................... 62number of large i/o buffers.............. 97number of locks............................ 120number of mailboxes.................... 103number of messages.................... 103

    number of network tasks ................ 89number of open databases............. 87number of open indexes................. 87number of open objects.................. 87number of open partitions............... 87number of pre-allocated extents ... 144number of remote connections ..... 116number of remote logins...............116number of remote sites.................116number of sort buffers .................. 103

    number of user connections ...........97number of worker processes ........103o/s file descriptors ..........................97open index hash spinlock ratio ..... 102open index spinlock ratio.............. 102open object spinlock ratio............. 102optimization goal ............................55optimization timeout limit ................ 57optimizer level ................................ 55page lock promotion HWM ...........122page lock promotion LWM............ 122page lock promotion PCT............. 122partition spinlock ratio................... 102pci memory size .............................62print deadlock information ............ 120procedure cache percent................ 87procedure cache size ..................... 87procedure deferred compilation...... 55prod-consumer overlap factor....... 103

    quorum heartbeat interval............. 104quorum heartbeat retries .............. 104quoted identifier enhancements...... 12read committed with lock.............. 120remote server pre-read packets.... 116restricted decrypt permission.......... 40row lock promotion HWM ............. 122row lock promotion LWM.............. 122

    row lock promotion PCT................122runnable process search count .......89sampling percent.............................92select for update .............................55send doneinproc tokens................102

    session migration timeout .............105session tempdb log cache size .....102shared memory starting address...102size of auto identity column (config)36size of global fixed heap .................62size of process object heap.............62size of shared class heap................62sproc optimize timeout limit.............57sql server clock tick length ....102, 143stack guard size............................102

    stack size......................................102start xp server during boot ............123statement cache size ......................59streamlined dynamic SQL...............55suspend audit when device full .....124syb_sendmsg port number..............21sysstatistics flush interval................92systemwide password expiration.....78tcp no delay ..................................102text prefetch size.............................25time slice.......................................102total data cache size .......................87total logical memory........................87total memory...................................87total physical memory .....................87transfer utility memory size .............31update statistics hashing.................92user log cache size .......................102user log cache spinlock ratio.........102

    workload manager cache size.......105xp_cmdshell context .....................123

    Configuration parameters, advanced .102configure, sp_ ......................................86Configuring CIS..................................116Configuring parallel processing..........103Configuring RPCs..............................115connect to ..........................................118connection, reserved for DBA ..............97Constraints...........................................41

    continue ...............................................50convert()...............................................11convert(), for date/time formatting ........14copy_all_qplans, sp_ .........................128copy_qplan, sp_.................................128cores, using multiple ............................88corrupt, dbcc ......................................109cos().....................................................23cost factors, query plan........................57cost of a cpu unit (config).....................57cost of a logical io (config)....................57cost of a physical io (config).................57cot() .....................................................23count[_big]() (aggregate).....................26count[_big](*) (aggregate) ...................26countmetadata, sp_ .............................86cpu grace time (config).......................102cpuaffinity, dbcc tune .........................108cpuinfo (license manager)..................146

    CPUs, using multiple............................88create access rule..........................45, 86create database ...................................67

    for proxy_update...........................117in-memory (IMDB)...........................68RDDB .............................................68temporary database........................70

    create default .......................................45

  • 8/9/2019 Guia de Sybase

    21/36

    ASE versions 15.0, 15.5 & 15.7 153

    create encryption key...........................36dual control.....................................37master key................................37, 40

    create existing table...........................118create function.....................................48

    Java functions.................................62create index.........................................40create login..........................................76create login profile ...............................80create manifest file...............................75create materialized view ......................44create plan.........................................127create precomputed result set .............44create procedure .................................47

    Java procedures.............................62

    create procedure...as external name .123create proxy_table .............................118create role ...........................................82create rule ...........................................45create schema authorization....33, 44, 84create table..........................................31

    CIS ...............................................119create existing table......................118create proxy_table........................118encryption.......................................38RI constraints..................................41

    create temporary database..................70create thread pool................................89create trigger .......................................46create view ..........................................43create_locator() ...................................26createws, sp_dbcc_...........................100current audit table (config) .................124current_bigdatetime()...........................13

    current_bigtime() .................................13current_date() ......................................13current_time() ......................................13cursor rows, set ...................................51cursorinfo, sp_.....................................51cursors.................................................50cursors, update/delete .........................51curunreservedpgs()..............................17

    D

    data compression ................................75data transfer utility (DTU).....................31data_pages() .......................................17data_pgs() ...........................................17database devices.................................66database dump....................................72

    create .............................................72restore ............................................73

    Database optionsabort tran on log full ........................68allow nulls by default.......................68allow wide dol rows.........................68async log service ............................68auto identity ..............................36, 69dbo use only ...................................69ddl in tran........................................69deferred table allocation .................69delayed commit ........................31, 69enforce dump tran sequence..69, 144full logging for all..................... 69, 144full logging for alter table......... 69, 144full logging for reorg rebuild ....69, 144full logging for select into ........69, 144identity in nonunique index ....... 36, 69no chkpt on recovery ......................69

    no free space acctg........................ 69read only ........................................ 69select into/bulkcopy/pllsort ............. 69single user...................................... 69trunc log on chkpt........................... 69

    unique auto_identity index........ 36, 69database recovery............................. 126database timestamp.........Seetimestampdatabase users.................................... 80databases ........................................... 67databases, sp_.................................. 143datachange()................................. 17, 92datalength()......................................... 17data-only lock schemes..................... 120datapages (lock scheme) .................. 120

    datarows (lock scheme) .................... 120dataserver ......................................... 131datatype conversion functions............. 11datatype_info, sp_............................. 143datatypes ............................................ 10dateadd()............................................. 14datediff().............................................. 13datefirst, set......................................... 14dateformat, set .................................... 14datename().......................................... 13datepart() ............................................ 13day().................................................... 13db_attr() .............................................. 17db_id()................................................. 17db_instanceid()............................ 70, 105db_name()........................................... 17db_recovery_status()......................... 105DBA tasks ............................................. 9DBA t