Вы находитесь на странице: 1из 40

Sybase IQ Quick Reference

Sybase IQ Release 11.2.x Document ID: 36125-01-1121-02 Last Revised: September 19, 1997

Principal author: AIPD Technical Publications Document ID: 36125-01-1121 This publication pertains to Sybase IQ Release 11.2.x of the Sybase database management software and to any subsequent version until otherwise indicated in new editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished under a license agreement, and it may be used or copied only in accordance with the terms of that agreement.

Document Orders
To order additional documents, U.S. and Canadian customers should call Customer Fulllment at (800) 685-8225, fax (617) 229-9845. Customers in other countries with a U.S. license agreement may contact Customer Fulllment via the above fax number. All other international customers should contact their Sybase subsidiary or local distributor. Upgrades are provided only at regularly scheduled software release dates. Copyright 19891997 by Sybase, Inc. All rights reserved. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc.

Sybase Trademarks
Sybase, the Sybase logo, APT-FORMS, Certied SYBASE Professional, Data Workbench, First Impression, InfoMaker, PowerBuilder, Powersoft, Replication Server, S-Designor, SQL Advantage, SQL Debug, SQL SMART, SQL Solutions, Transact-SQL, Visual Components, VisualWriter, and VQL are registered trademarks of Sybase, Inc. Adaptable Windowing Environment, Adaptive Component Architecture, Adaptive Server, Adaptive Server Monitor, Adaptive Warehouse, ADA Workbench, AnswerBase, Application Manager, AppModeler, APT-Build, APT-Edit, APT-Execute, APT-Library, APT-Translator, APT Workbench, Backup Server, BayCam, Bit-Wise, ClearConnect, Client-Library, Client Services, CodeBank, Column Design, Connection Manager, DataArchitect, Database Analyzer, DataExpress, Data Pipeline, DataWindow, DB-Library, dbQueue, Developers Workbench, DirectConnect, Distribution Agent, Distribution Director, Dynamo, Embedded SQL, EMS, Enterprise Client/Server, Enterprise Connect, Enterprise Manager, Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise Work Designer, Enterprise Work Modeler, EWA, Formula One, Gateway Manager, GeoPoint, ImpactNow, InformationConnect, InstaHelp, InternetBuilder, iScript, Jaguar CTS, jConnect for JDBC, KnowledgeBase, Logical Memory Manager, MainframeConnect, Maintenance Express, MAP, MDI Access Server, MDI Database Gateway, media.splash, MetaBridge, MetaWorks, MethodSet, Net-Gateway, NetImpact, Net-Library, ObjectConnect, ObjectCycle, OmniConnect, OmniSQL Access Module, OmniSQL Toolkit, Open Client, Open ClientConnect, Open

Client/Server, Open Client/Server Interfaces, Open Gateway, Open Server, Open ServerConnect, Open Solutions, Optima++, PB-Gen, PC APT-Execute, PC DB-Net, PC Net Library, Power++, Power AMC, PowerBuilt, PowerBuilt with PowerBuilder, PowerDesigner, Power J, PowerScript, PowerSite, PowerSocket, Powersoft Portfolio, PowerStudio, Power Through Knowledge, PowerWare Desktop, PowerWare Enterprise, ProcessAnalyst, QuickStart DataMart, QuickStart ReportSmart, Replication Agent, Replication Driver, Replication Server Manager, Report-Execute, Report Workbench, Resource Manager, RW-DisplayLib, RW-Library, SAFE, SDF, Secure SQL Server, Secure SQL Toolset, Security Guardian, SKILS, smart.partners, smart.parts, smart.script, SQL Anywhere, SQL Code Checker, SQL Edit, SQL Edit/TPU, SQL Modeler, SQL Remote, SQL Server, SQL Server/CFT, SQL Server/DBM, SQL Server Manager, SQL Server SNMP SubAgent, SQL Station, SQL Toolset, Sybase Central, Sybase Client/Server Interfaces, Sybase Development Framework, Sybase Gateways, Sybase IQ, Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase Synergy Program, Sybase Virtual Server Architecture, Sybase User Workbench, SybaseWare, SyBooks, System 10, System 11, the System XI logo, SystemTools, Tabular Data Stream, The Architecture for Change, The Enterprise Client/Server Company, The Future is Wide Open, The Model for Client/Server Solutions, The Online Information Center, Translation Toolkit, Turning Imagination Into Reality, UNIBOM, Unilib, Uninull, Unisep, Unistring, URK Runtime Kit for UniCode, Viewer, VisualSpeller, WarehouseArchitect, Warehouse WORKS, Watcom, Watcom SQL, Watcom SQL Server, Web.PB, Web.SQL, WebSights, WebViewer, WorkGroup SQL Server, XA-Library, and XA-Server are trademarks of Sybase, Inc. 8/97 All other company and product names used herein may be trademarks or registered trademarks of their respective companies.

Restricted Rights
Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies. Sybase, Inc., 6475 Christie Avenue, Emeryville, CA 94608.

Table of Contents
Commands
CASE Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 FROM Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 GROUP BY Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 HAVING Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 IQ ADD SEGMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 IQ ALTER INDEXSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 IQ BACKUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 IQ CLOSE INDEXSPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 IQ CREATE INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 IQ CREATE INDEXSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 IQ CREATE INDEXSPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 IQ CREATE INDEXSPACE TEMPLATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 IQ CREATE JOINED INDEXSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 IQ DBCC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 IQ DELETE FROM INDEXSET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 IQ DROP INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 IQ DROP INDEXSET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 IQ DROP INDEXSPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 IQ DROP JOINED INDEXSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 IQ DROP SEGMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 IQ INSERT INTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 IQ INSERT INTO JOINED INDEXSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 IQ PASS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 IQ RESTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 IQ SET (Administration) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 IQ SET (Query Processing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 IQ SHOW INDEXSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 IQ SHOW INDEXSET INDEXES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 IQ SHOW INDEXSET JOINED INDEXSETS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 IQ SHOW INDEXSPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 IQ SHOW INDEXSPACE INDEXES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 IQ SHOW INDEXSPACE JOINED INDEXSETS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 IQ SHOW SET VALUES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 IQ SHOW...SIZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Sybase IQ Quick Reference

Sybase IQ Release 11.2.x

IQ STATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ORDER BY Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Query Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Search Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SELECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SHUTDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . USE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WHERE Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

16 16 17 17 17 18 18 18

Stored Procedures
sp_IQAddLogin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQAddLogins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQDropBadSegment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQDropLogin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQDropLoginAnyUser. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQDropLogins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQDropLoginsAnyDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQEstJoin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQEstSegments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQEstSpace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQRenameIndexSpace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQRenamePath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQRestartHungIndexSpace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQSetSharedMemory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowBadLogins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowFileFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowFileFormatSp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowFileFormatSys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowHungIndexSpaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowIndexSegments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowIndexSpaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowLogins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sp_IQShowUsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 19 19 19 20 20 20 20 21 21 21 21 22 22 22 22 23 23 23 23 23 24 24

Functions
AVG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 CAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 CONVERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

vi

Table of Contents

Sybase IQ Release 11.2.x

COUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . COUNT(*) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DATEADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DATEDIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DATEPART. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIFFERENCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LEFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LENGTH or DATALENGTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LOWER or LCASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RIGHT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ROUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SIMILAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SOUNDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STRING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SUBSTRING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SUSER_ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SUSER_NAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . UPPER or UCASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

25 26 26 26 26 27 27 27 27 28 28 28 28 29 29 29 29 30 30 30 30 31 31 31

Sybase IQ Quick Reference

vii

Sybase IQ Release 11.2.x

viii

Table of Contents

Commands
CASE Expression

0.

A conditional expression that can be used in IQ DELETE, IQ INSERT, or SELECT statements. The CASE expression allows you to determine one of many results based on a search condition or specic value you specify. Syntax
CASE WHEN logical-expression THEN result [WHEN logical-expression THEN result]... [ELSE result] END CASE expression WHEN expression THEN result [WHEN expression THEN result]... [ELSE result] END NULLIF(expression, expression) COALESCE(expression, expression [, expression]...)

FROM Clause
Indicates the indexsets from which you want to get data. The FROM clause is always required in a SELECT statement or query expression. Syntax
FROM [[[indexspace].][owner].]indexset_name [[AS] correlation_name] [, [[[indexspace].][owner].]indexset_name [AS] correlation_name]...

GROUP BY Clause
Sorts the output of a SELECT statement WHERE or FROM clause into groups whose rows have the same value for the specied column, and returns a single row of information for each group.

Sybase IQ Quick Reference

HAVING Clause

Sybase IQ Release 11.2.x

You can group a indexset by a single column or by a list of columns. If aggregate functions are included in the select list, GROUP BY also nds a summary value(s) for each group. These summary values appear as new columns in the results. Syntax
[GROUP BY [[indexspace].][[owner].][indexset_name.] column_name [, [[indexspace].][[owner].][indexset_name.] column_name]...

HAVING Clause
Restricts the groups you retrieve in the GROUP BY clause based on the specied search condition. Syntax
[HAVING search_condition]

IQ ADD SEGMENT
Creates additional segments across multiple operating system les or partitions for either an existing Sybase IQ indexspace or the transaction image data to add more free space and allow for multivolume support. Syntax
IQ ADD SEGMENT FOR indexspace_name, PATHNAME = "path_name" [, {INDEXSPACE | TRANSACTIONIMAGE [, {PREALLOCATE | AUTOALLOCATE}]}] [, {RAW | FILE [, SIZE = #_of_blocks]}]

IQ ALTER INDEXSET
Adds columns to or drops a column from an existing indexset. The changes are propagated to all joined indexsets that include that indexset.

Commands

Sybase IQ Release 11.2.x

IQ BACKUP

Syntax
IQ ALTER INDEXSET FOR [[[indexspace].][owner].]indexset_name {ADD column_name datatype [{NULL | NOT NULL}] [, column_name datatype [{NULL | NOT NULL}]]... | DROP column_name}

IQ BACKUP
Backs up a Sybase IQ indexspace on either raw partitions (UNIX only) or operating system les. You must be either the Database Owner or have 'sa' role to back up an indexspace. You must run IQ BACKUP interactively from the command line. You cannot run it in a batch script, because it requires you to mount the archive media when prompted. Each backup requires at least three different archive media: one (or more) for the indexspace les (segments and Free List les), one for the Backup Server archive (the catalog tables), and one for the IQ MASTER archive (header les that describe the indexspace backed up). IQ BACKUP prompts you to mount the indexspace archive(s) rst, then the Backup Server archive, and nally, the IQ MASTER archive. For information about supported archive media for your platform, see Sybase IQ Administration Guide. Syntax
IQ BACKUP INDEXSPACE indexspace_name [NOOVERWRITE] [CRC] [BLOCKINGFACTOR = blockfactor_#] TO archive_device [CAPACITY = #_of_KB] [TO archive_device [CAPACITY = #_of_KB]]... [COMMENT = string]

IQ CLOSE INDEXSPACE
Closes, or exits, from the indexspace you are using without exiting Sybase IQ. Syntax
IQ CLOSE INDEXSPACE

Sybase IQ Quick Reference

IQ CREATE INDEX

Sybase IQ Release 11.2.x

IQ CREATE INDEX
Adds an index to a column in an indexset of the given index type. Syntax
IQ CREATE [UNIQUE] INDEX [[[indexspace].][owner].]index_name ON [[[indexspace].][owner].]indexset_name (column_name) index_type [[WITH] [insert_load_option] [, insert_load_option]...] [CREATE [UNIQUE] INDEX [[[indexspace].][owner].]index_name ON [[[indexspace].][owner].]indexset_name (column_name) index_type [[WITH] [insert_load_option] [, insert_load_option]...]]...

IQ CREATE INDEXSET
Creates a Sybase IQ indexset and denes all the columns that are part of that indexset. This indexset must have an underlying database table of the same name. The Sybase IQ indexset can have fewer columns than the underlying table, but it cannot have any columns that are unknown to the underlying table. When you create a Sybase IQ indexset, Sybase IQ automatically creates an IQ_ROWID column in the indexset to be used for record number reference. Syntax
IQ CREATE INDEXSET FOR [[[indexspace].][owner].]indexset_name (column_name datatype [{NULL | NOT NULL}] [, column_name datatype [{NULL | NOT NULL}]]...)

IQ CREATE INDEXSPACE
Creates a new Sybase IQ indexspace, which contains the data denitions and data for Sybase IQ indexes. An underlying database

Commands

Sybase IQ Release 11.2.x

IQ CREATE INDEXSPACE TEMPLATE

of the same name must already exist for this command for it to be executed successfully. There are two classes of indexspace: Main indexspace Private indexspace (personal read/write indexspace) The IQ CREATE INDEXSPACE command creates a preallocated indexspace that can be used as a main or private indexspace. Syntax
IQ CREATE INDEXSPACE FOR indexspace_name, PATHNAME="path_name" [, {RAW [, SIZE=#_of_blocks] | [FILE,] SIZE=#_of_blocks}] [, BLOCKSIZE = power_of_2_from_512_to_32K] [, MAXCOMPRESSION = power_of_2_from_2_to_16] [, FLPATHNAME = "path_name"] [, LOGPATHNAME = "path_name"] {[, TIPATHNAME = "path_name" [, TIRAW]] | [, TIPATHNAME = path_name] [, TIFILE] [, {TIAUTOALLOCATE | TIPREALLOCATE}] [, TISIZE = #]} [, SHMEMMB = #_of_MB_in_main_buffer_cache] [, TEMPSHMEMMB = #_of_MB_in_private_buffer_cache]

IQ CREATE INDEXSPACE TEMPLATE


Builds a script that can be used to create a new Sybase IQ indexspace which contains the indexsets, column indexes, and data denitions for Sybase IQ indexes, based on an underlying database of the same name. This script builds an indexspace to match the underlying database. This script can be modied and used as input to the Sybase IQ command line. Syntax
IQ CREATE INDEXSPACE TEMPLATE [FOR [[[database].][owner].]table_name], PATHNAME=filename [, APPEND]

Sybase IQ Quick Reference

IQ CREATE JOINED INDEXSET

Sybase IQ Release 11.2.x

IQ CREATE JOINED INDEXSET


Creates a Sybase IQ joined indexset, a group of indexsets that are prejoined, to improve performance on queries against multiple indexsets in the same indexspace. Syntax
IQ CREATE JOINED INDEXSET [[[indexspace].][owner].]joined_indexset_name FOR [[[indexspace].][owner].]indexset_name (join_field [, join_field]...]) = [[[indexspace].][owner].]indexset_name(join_field [, join_field]...]) join_relationship [, [[[indexspace].][owner].]indexset_name (join_field [, join_field]...]) = [[[indexspace].][owner].]indexset_name(join_field [, join_field]...]) join_relationship ...

IQ DBCC
Checks every block in the indexspace and saves the information in the current session until the next IQ DBCC CHECKDB command is issued. The information can be displayed by using IQ SHOW INDEXSPACE STATS. Syntax
IQ DBCC [{MAIN | PRIVATE}] CHECKDB

IQ DELETE FROM INDEXSET


Deletes rows from a single indexset. Syntax
IQ DELETE FROM INDEXSET FOR [[[indexspace].][owner].]indexset_name [WITH delete_load_option [, delete_load_option]...] [WHERE search_condition]

IQ DROP INDEX
Drops a column index from the indexspace.

Commands

Sybase IQ Release 11.2.x

IQ DROP INDEXSET

Syntax
IQ DROP INDEX [[[indexspace].][owner].]index_name [, [[[indexspace].][owner].]index_name]...

IQ DROP INDEXSET
Deletes an indexset and its column indexes. Syntax
IQ DROP INDEXSET FOR [[[indexspace].][owner].]indexset_name

IQ DROP INDEXSPACE
Deletes an indexspace and its contents. Removes les for the indexspace and modies the sysIQ_* tables. Syntax
IQ DROP INDEXSPACE FOR indexspace_name

IQ DROP JOINED INDEXSET


Deletes a joined indexset from the indexspace. Syntax
IQ DROP JOINED INDEXSET [[[indexspace].][owner].]joined_indexset_name

IQ DROP SEGMENT
Drops the last segment of a Sybase IQ indexspace. Syntax
IQ DROP SEGMENT FOR indexspace_name [, {INDEXSPACE | TRANSACTIONIMAGE}]

Sybase IQ Quick Reference

IQ INSERT INTO

Sybase IQ Release 11.2.x

IQ INSERT INTO
Inserts new data into Sybase IQ indexset columns. When you insert data into a column in a Sybase IQ indexset, Sybase IQ inserts data into all the column indexes that exist for that column of the indexset. You can insert data from four sources: Direct input, indicating specic values row by row Other Sybase IQ indexed data in the main indexspace or associated preallocated private indexspaces A table in an underlying database One or more at les For large volume loads, the last two sources are recommended. Syntax
IQ INSERT INTO INDEXSET FOR [[[indexspace].][owner].]indexset_name ({column_name [insert_conversion_option [, insert_conversion_option]...] | FILLER(field_descriptor)} [, {column_name [insert_conversion_option [, insert_conversion_option]...] | FILLER(field_descriptor)}]...) [[WITH] insert_load_option [, insert_load_option]...] {row-value-clause | table-or-indexset-clause | flat-file-clause}

insert_conversion_option = {ASCII (field_descriptor) | DATE ('input_date_format') | DATETIME ('input_date/time_format') | NULLS ({BLANKS | ZEROS | 'literal' [, 'literal']...})} field_descriptor = {input_width | PREFIX1 | PREFIX2 | PREFIX4 | 'delimiter_string'}

Commands

Sybase IQ Release 11.2.x

IQ INSERT INTO JOINED INDEXSET

insert_load_option = {BLOCKFACTOR = # | BLOCKSIZE = # | BYTEORDER = {NATIVE | HIGHORDER | LOWORDER} | LIMIT = max_#_of_records_to_read | MBSORT = #_of_MB_memory_for_sort | NOTIFY = notify_every_#_of_rows | ONFILEERROR = {ROLLBACK | COMMIT | CONTINUE} | PREVIEW | ROWTERMINATOR = 'delimiter_string' | SKIP = #_of_rows_to_skip | STARTRECID = #} row-value-clause = VALUES (value [, value]...) table-or-indexset-clause = [USING ATTACHED [{DATABASE | DB}]] SELECT-statement flat-file-clause = USING 'input_file' [, 'input_file']...

IQ INSERT INTO JOINED INDEXSET


Inserts data into a Sybase IQ joined indexset. You insert data into a joined indexset for all the indexsets in the join relationship. With the IQ INSERT INTO JOINED INDEXSET command, you can insert data into a joined indexset from three sources: Other Sybase IQ indexed data in the main indexspace or associated preallocated private indexspaces A table in an underlying database One or more at les Use a separate IQ INSERT INTO JOINED INDEXSET statement for each indexset, except for the indexset at the top of the join hierarchy, which automatically uses the data from its indexset column indexes. (Sybase IQ tells you which is the top indexset in the join hierarchy when you create the joined indexset; see the discussion later in this command and in the IQ CREATE JOINED INDEXSET command for more information.)

Sybase IQ Quick Reference

IQ INSERT INTO JOINED INDEXSET

Sybase IQ Release 11.2.x

Syntax
IQ INSERT INTO JOINED INDEXSET [[[indexspace].][owner].]joined_indexset_name FOR [[[indexspace].][owner].]indexset_name [[WITH] insert_load_option [, insert_load_option]...] {table-or-indexset-clause | flat-file-clause}

insert_load_option = {BLOCKFACTOR = # | BLOCKSIZE = # | BYTEORDER = {NATIVE | HIGHORDER | LOWORDER} | LIMIT = max_#_of_records_to_read | MBSORT = #_of_MB_memory_for_sort | NOTIFY = notify_every_#_of_rows | ONFILEERROR = {ROLLBACK | COMMIT | CONTINUE} | PREVIEW | ROWTERMINATOR = 'delimiter_string' | SKIP = #_of_rows_to_skip | STARTRECID = #} table-or-indexset-clause = [USING ATTACHED [{DATABASE | DB}]] SELECT-statement flat-file-clause = USING 'input_file' [, 'input_file']... ({column_name [insert_conversion_option [, insert_conversion_option]...] | FILLER(field_descriptor)} [, {column_name [insert_conversion_option [, insert_conversion_option]...] | FILLER(field_descriptor)}]...) [[WITH] insert_load_option [, insert_load_option]...] insert_conversion_option = {ASCII (field_descriptor) | DATE ('input_date_format') | DATETIME ('input_date/time_format') | NULLS ({BLANKS | ZEROS | 'literal' [, 'literal']...})} field_descriptor = {input_width | PREFIX1 | PREFIX2 | PREFIX4 | 'delimiter_string'}

10

Commands

Sybase IQ Release 11.2.x

IQ PASS

IQ PASS
Sybase IQ ignores the string that follows the PASS keyword and passes it through to SQL Server for processing. Syntax
IQ PASS rest_of_line

IQ RESTORE
Restores a Sybase IQ indexspace and associated catalog information (full restore) or the indexspace only (partial restore). You can also use this command to display the header information for the indexspace without performing any restore operation. You must be either the Database Owner or have 'sa' role to use this statement. Each backup set includes at least three different archive media (tapes, for example): One or more for indexspace les (segments and Free List les) One or more for the Backup Server archive (the catalog tables) One for the IQ MASTER archive (header les that describe the indexspace backed up) A full restore prompts you to mount the IQ MASTER archive rst, then the Backup Server archive, followed by archive(s) containing indexspace data in any order. A partial restore prompts you to mount the IQ MASTER archive rst, then the archive(s) containing indexspace data in any order. Syntax
IQ RESTORE INDEXSPACE indexspace_name FROM {archive_device HEADERONLY | archive_device [FROM archive_device]... [FILE oldpath [TO newpath]]...}

IQ SET (Administration)
Used to reset Sybase IQ default settings. For some options, you can specify the SERVERDEFAULT keyword with the IQ SET command, which saves the value in the SQL Server table 11sysIQ_control as a persistent, server-wide default value. When no keyword or the

Sybase IQ Quick Reference

11

IQ SET (Administration)

Sybase IQ Release 11.2.x

SESSION keyword is given, the IQ SET command only affects the

current session. All IQ SET options have a security level (choices are System Administrator, Database Owner, and PUBLIC) assigned with them. For example, you must have the System Administrator role to specify a SERVERDEFAULT option. Syntax
IQ SET {[SERVERDEFAULT | SESSION] server_session_options | [SESSION] session_only_options}

server_session_options = {DATEFORMATOUTPUT date_format | DATETIMEFORMATOUTPUT datetime_format | DDLINFO {ON | OFF} | DISKSTRIPING {ON | OFF | RAWDETECT} | INFOMESSAGES {ON | OFF} | KEEPOPENIQLOG {ON | OFF} | MBSORT #_of_MB_mem_for_sort | OPTIMIZEFORTHISMANYUSERS #_of_users | OUTOFDISKMSGREPEAT repeat_msg_every_seconds | OUTOFDISKWAITTIME seconds_to_wait | QUERYINFO {ON | OFF} | REMOVEINDEXSPACELOG {ON | OFF} | SHMEMMB #_MB_for_main_buffer_cache | STRIPINGDENSITY #_of_stripes | SYSTEMSHMMAX #_of_MB | SYSTEMSHMSEG max_segments | TEMPSHMEMMB #_MB_for_private_buffer_cache | TRACKEXCESSREADS {ON | OFF}} USERETRYMSGREPEAT #_of_times | USERETRYWAITTIME #_of_seconds}

12

Commands

Sybase IQ Release 11.2.x

IQ SET (Query Processing)

session_only_options = {BLOCKFACTOR #_of_records_per_block | BLOCKSIZE #_of_bytes_per_block | COMMIT #_of_commits_for_delete | ESTIMATEDRECORDCOUNT #_of_records | INSERTNUMMTBUFFERS #_of_buffers | INSERTNUMROWSPERBUFFER #_of_rows | IQ {ON | OFF | ONLY} | LIMIT max_#_of_records_to_read | MAXWARNINGS max_#_of_warnings | NOTIFY notify_every_#_of_rows | PREVIEW | SHOWELAPSEDTIME {ON | OFF} | SKIP #_of_rows_to_skip | STARTRECID row_record_id_# | SUPPORTALL8BITCHAR {ON | OFF}}

IQ SET (Query Processing)


Sets query processing options for Sybase IQ and/or SQL Server for the duration of the work session. Can be used to set some options inside a trigger or stored procedure. Those options that require system privileges are described in IQ SET (Administration) on page -11. Syntax
IQ SET {[SERVERDEFAULT | SESSION] server_session_options | [SESSION] session_only_options}

server_session_options = {AGGREGATIONCUTOFF precision_# | {INFOMESSAGES {ON | OFF} JOINOPTIMIZATION {ON | OFF} | JOINORDERLEFTDEEP {ON | OFF} | KEEPOPENIQLOG {ON | OFF} | MAXCARTESIANRESULT #_of_rows | SHOWIQROWID {ON | OFF}} session_only_options = {ANSINULL {ON | OFF} | ARITHABORT [{ARITH_OVERFLOW | NUMERIC_TRUNCATION}] {ON | OFF} | ARITHIGNORE [ARITH_OVERFLOW] {ON | OFF} | NOEXEC {ON | OFF} | ROWCOUNT #_of_rows}

Sybase IQ Quick Reference

13

IQ SHOW INDEXSET

Sybase IQ Release 11.2.x

IQ SHOW INDEXSET
Displays information about the named indexset. The information includes the column names, the datatypes, the column length, precision, scale, whether or not the column allows NULLs, and so on. Syntax
IQ SHOW INDEXSET FOR [[[indexspace].][owner].]indexset_name

IQ SHOW INDEXSET INDEXES


Displays information about indexes on the columns in the specied indexset. The information includes the index names, type of index, column names, and uniqueness setting. Syntax
IQ SHOW INDEXSET {INDEXES | INDICES} FOR [[[indexspace].][owner].]indexset_name

IQ SHOW INDEXSET JOINED INDEXSETS


Displays information about the joined indexsets associated with the specied indexset. The information includes the name and join relationships of each joined indexset. Syntax
IQ SHOW INDEXSET JOINED INDEXSETS FOR [[[indexspace].][owner].]indexset_name

IQ SHOW INDEXSPACE
Displays information about the indexspace you are using. The information includes the name of the indexspace and a listing of the indexsets that are part of that indexspace. The table listing includes the creation and last update time of and the number of columns in each indexset.

14

Commands

Sybase IQ Release 11.2.x

IQ SHOW INDEXSPACE INDEXES

Syntax
IQ SHOW [{PRIVATE | MAIN}] {INDEXSETS | INDEXSPACE [STATS | STATISTICS]}

IQ SHOW INDEXSPACE INDEXES


Displays information about the column indexes associated with the Sybase IQ indexspace you are using. The information includes the name and type of each index, the indexsets and columns from which they are derived, and other data such as uniqueness. Syntax
IQ SHOW [{PRIVATE | MAIN}] [{INDEXSPACE | INDEXSETS}] {INDEXES | INDICES} [[[[indexspace].][owner].]indexset_name]

IQ SHOW INDEXSPACE JOINED INDEXSETS


Displays information about the joined indexsets associated with the Sybase IQ indexspace you are using. The information includes the name and join relationships of each joined indexset. Syntax
IQ SHOW [{PRIVATE | MAIN}] [{INDEXSPACE | INDEXSETS}] JOINED {INDEXSET | INDEXSETS} [[[[indexspace].][owner].]joined_indexset_name]

IQ SHOW SET VALUES


Displays an alphabetized list of the IQ SET command options and their values. Syntax
IQ SHOW SET VALUES

Sybase IQ Quick Reference

15

IQ SHOW...SIZE

Sybase IQ Release 11.2.x

IQ SHOW...SIZE
Displays the size, in blocks, of the specied indexspace object. The object can be a column index, a joined indexset, an indexset, or an indexspace. Syntax
IQ SHOW INDEX SIZE index_name

IQ SHOW INDEXSET SIZE FOR [[[indexspace].][owner].]indexset_name

IQ SHOW JOINED INDEXSET SIZE [[[indexspace].][owner].]join_index_name

IQ SHOW [{PRIVATE | MAIN}] INDEXSPACE SIZE

IQ STATUS
Shows information about the current indexspace (for any you open with the USE command), including the release of Sybase IQ invoked, the indexspace name, creation date, blocksize, number of blocks used, buffers used, number of segments, private indexspace name, transaction image les (if the indexspace is open RW), and the maximum TI block usage. Syntax
IQ STATUS

ORDER BY Clause
Sorts the result table output from a SELECT statement by column.

16

Commands

Sybase IQ Release 11.2.x

Query Expression

Syntax
[ORDER BY {[[[indexspace].][owner].indexset_name.]column_name | select_list_number} [ASC | DESC] [, {[[[indexspace].][owner].indexset_name.] column_name] | select_list_number} [ASC | DESC]]...

Query Expression
An expression (consisting of one or more query specications) that can be used in IQ DELETE, IQ INSERT, or SELECT statements. The query expression creates a virtual table to be retrieved from or stored in the indexspace. The query expression differs from the SELECT statement in that it cannot be used by itself and it is allowed to return more than one row. Syntax
{query_expression | (SELECT_statement)} [UNION [ALL] {query_expression | (SELECT_statement)}]... [ORDER BY clause]

Search Conditions
Combines predicates used with the logical operators (AND, OR and NOT) to lter the rows or groups returned by the corresponding WHERE, GROUP BY, or HAVING clause. Search conditions help dene SELECT statement criteria. Syntax
predicate = {[NOT] search_condition | search_condition AND search_condition | search_condition OR search_condition}

SELECT
Retrieves rows and columns from indexsets in the indexspace. Use the SELECT command to perform queries in interactive Sybase IQ.

Sybase IQ Quick Reference

17

SHUTDOWN

Sybase IQ Release 11.2.x

Syntax
SELECT [ALL | DISTINCT] select_list FROM clause [WHERE clause] [GROUP BY clause] [HAVING clause] [ORDER BY clause]

SHUTDOWN
Exit Sybase IQ and pass the shutdown command to the SQL Server. This command can only be issued by a System Administrator. Syntax
SHUTDOWN [with {wait | nowait}]

USE
Opens the attached indexspace and corresponding Sybase IQ indexspace, if one exists, for use. The attached database is opened for read/write use by default. Parameters read from the sysIQ_logins table control how the Sybase IQ indexspace will be opened. Syntax
USE indexspace_name

WHERE Clause
Sets the conditions for the rows that are retrieved by a SELECT statement. Syntax
[WHERE search_condition]

18

Commands

Stored Procedures
sp_IQAddLogin

0.

Adds or modies an entry in the IQmaster..sysIQ_logins table. This procedure grants usage permissions to a user login for a particular indexspace. Syntax
sp_IQAddLogin name, dbname, rwdbname, nbuffers, ntmpbuffers, logfile, attacheddb, attacheddbserver, attacheddbservertype, accessmode

sp_IQAddLogins
Adds or modies an entry in the IQmaster..sysIQ_logins table for a particular main indexspace and group(s) of users. Syntax
sp_IQAddLogins grpname, dbname, rwdbname, nbuffers, ntmpbuffers, logfile, attacheddb, attacheddbserver, attacheddbservertype, accessmode

sp_IQDropBadSegment
Removes the highest numbered segment from the specied indexspace, if the segment is corrupted. Syntax
sp_IQDropBadSegment dbname

sp_IQDropLogin
Removes an entry in the IQmaster..sysIQ_logins table for a user on a particular indexspace. Syntax
sp_IQDropLogin name, dbname

Sybase IQ Quick Reference

19

sp_IQDropLoginAnyUser

Sybase IQ Release 11.2.x

sp_IQDropLoginAnyUser
Removes entries in the IQmaster..sysIQ_logins table for all users of a particular indexspace. Syntax
sp_IQDropLoginAnyUser dbname

sp_IQDropLogins
Removes entries in the IQmaster..sysIQ_logins table for all users of the specied indexspace who have the group identier. Syntax
sp_IQDropLogins grpname, dbname

sp_IQDropLoginsAnyDB
Removes entries in the IQmaster..sysIQ_logins table for the specied user. Syntax
sp_IQDropLoginsAnyDB name

sp_IQEstJoin
Estimates the amount of space a joined table will use, based on the tables being joined. Syntax
sp_IQEstJoin tab1, tab1_row, tab2, tab2_row, relation [, block_size]

20

Stored Procedures

Sybase IQ Release 11.2.x

sp_IQEstSegments

sp_IQEstSegments
Estimates the number of segments to create for the initial build of the indexspace, and the size of each segment, based on the size of the underlying database and specied restrictions on segment size. Syntax
sp_IQEstSegments idx_size [, block_size [, min_size [, max_size]]]

sp_IQEstSpace
Estimates the amount of space that an index will require, based on the number of rows in the tables in the underlying database. This command includes some of the same information shown by
sp_IQEstSegment.

Syntax
sp_IQEstSpace tabname, num_rows [, block_size]

sp_IQRenameIndexSpace
Renames an IQ object by updating _DBName with the new object name in all Sybase IQ tables. Syntax
sp_IQRenameIndexSpace oldname, newname

sp_IQRenamePath
Renames a partial substring or an absolute path name to allow the system catalog to point to Sybase IQ les (such as indexspace and .TI les) that you have moved. Syntax
sp_IQRenamePath indexspace_name, "oldpath", "newpath"

Sybase IQ Quick Reference

21

sp_IQRestartHungIndexSpace

Sybase IQ Release 11.2.x

sp_IQRestartHungIndexSpace
Restarts an indexspace that is hung because it was out of disk space Use this procedure after disk space has been provided. Syntax
sp_IQRestartHungIndexSpace dbname

sp_IQSetSharedMemory
Alters the buffer cache shared memory settings for an existing Sybase IQ indexspace. The new settings take effect the next time a shared segment is created. It will not affect current users of the indexspace. Syntax
sp_IQSetSharedMemory indexspacename, shmemmb_value, tempshmemmb_value

sp_IQShowBadLogins
Shows entries in IQmaster..sysIQ_logins that are unusable. Unusable entries might result, for example, if the indexspace or user no longer exists. Syntax
sp_IQShowBadLogins

sp_IQShowFileFormat
Shows current le format (revision level) of Sybase IQ les. Syntax
sp_IQShowFileFormat

22

Stored Procedures

Sybase IQ Release 11.2.x

sp_IQShowFileFormatSp

sp_IQShowFileFormatSp
Shows current le format (revision level) of Sybase IQ stored procedures. Syntax
sp_IQShowFileFormatSp

sp_IQShowFileFormatSys
Shows current le format (revision level) of Sybase IQ system tables. Syntax
sp_IQShowFileFormatSys

sp_IQShowHungIndexSpaces
Shows the names of indexspaces that are hung because they are out of disk space. Syntax
sp_IQShowHungIndexSpaces

sp_IQShowIndexSegments
Shows all segments for a particular indexspace. Syntax
sp_IQShowIndexSegments dbname

sp_IQShowIndexSpaces
Shows all indexspaces in the catalog and their in use status, including whether they are hung. Syntax
sp_IQShowIndexSpaces

Sybase IQ Quick Reference

23

sp_IQShowLogins

Sybase IQ Release 11.2.x

sp_IQShowLogins
Shows all active login records for existing indexspaces. Syntax
sp_IQShowLogins

sp_IQShowUsers
Shows all active users of Sybase IQ which indexspaces they are using, lock mode, and where they are connected from. Syntax
sp_IQShowUsers

24

Stored Procedures

Functions
AVG
Returns the average value of argument. NULL values are not included. AVG is valid for integer and oating point datatypes. Syntax
AVG([ALL | DISTINCT] argument)

0.

CAST
Used in the WHERE clause or select list of a SELECT statement to convert one datatype to another. It can also be used to obtain a variety of date/time formats if you convert DATE or DATETIME columns to CHAR or V ARCHAR. Syntax
CAST (<value expression> AS <data_type>[,"datestyle"])

CONVERT
This function can change expressions from one datatype to another and specify new display formats for date/time information. It can be used in the select list, in the where clause, and anywhere else an expression is allowed. Syntax
CONVERT (datatype [(length) | (precision[, scale])], expression[, style])

COUNT
Returns the number of rows that satises the query. Rows with NULL values in the specied column are not included. Syntax
COUNT([ALL | DISTINCT] argument)

Sybase IQ Quick Reference

25

COUNT(*)

Sybase IQ Release 11.2.x

COUNT(*)
Returns the number of rows that satises the query, including nulls and duplicates. Syntax
COUNT(*)

DATEADD
Adds an interval to a specied date and returns a datetime value equal to the date plus the number of date parts. Syntax
DATEADD(datepart, integer_expression, date_expression)

DATEDIFF
Returns the number of date parts between two specied dates. Syntax
DATEDIFF(datepart, date_expression 1, date_expression 2)

DATEPART
Returns an integer value for the specied date part (the rst argument) of the specied DATE or DATETIME value (the second argument). Syntax
DATEPART(datepart, value_expression)

26

Functions

Sybase IQ Release 11.2.x

DIFFERENCE

DIFFERENCE
Returns an integer representing the difference between two SOUNDEX values. Syntax
DIFFERENCE(char_expr1, char_expr2)

LEFT
Returns the leftmost number of characters (dened by integer_expr) from a character expression (dened by char_expr). Return value has the same datatype as the character expression. Syntax
LEFT(char_expr, integer_expr)

LENGTH or DATALENGTH
Returns the length in bytes of the character expression. Syntax
LENGTH(char_expr) DATALENGTH(char_expr)

LOWER or LCASE
Converts uppercase to lowercase, returning a character value. Syntax
LOWER(char_expr) LCASE(char_expr)

Sybase IQ Quick Reference

27

LTRIM

Sybase IQ Release 11.2.x

LTRIM
Removes leading blanks from the character expression. Only values equivalent to the space character in the current character set are removed. Syntax
LTRIM(char_expr)

MAX
Returns the maximum value of argument. NULL values are not included. MAX is valid for integer and number type elds, character, oating point, and date/time columns. With character columns, MAX nds the highest value in the sort sequence. The DISTINCT option is not used with MAX, because it is not meaningful in this context. Syntax
MAX(argument)

MIN
Returns the minimum value of argument. NULL values are not included. MIN is valid for integer and number type elds, character, oating point, and date/time columns. With character columns, MIN nds the lowest value in the sort sequence. The DISTINCT option is not used with MIN, because it is not meaningful in this context. Syntax
MIN(argument)

RIGHT
Returns the rightmost number of characters (dened by integer_expr) from a character expression (dened by char_expr). Return value has the same datatype as the character expression. Syntax
RIGHT(char_expr, integer_expr)

28

Functions

Sybase IQ Release 11.2.x

ROUND

ROUND
Rounds a numeric expression (up or down) so that it has the specied integer_expression number of signicant digits. Syntax
ROUND(numval_expression, integer_expression)

RTRIM
Removes trailing blanks. Only values equivalent to the space character in the current character set are removed. Syntax
RTRIM(char_expr)

SIMILAR
Returns an integer between 0 and 100 representing (in percentage) the similarity between the two strings. Syntax
SIMILAR(char_expr1, char_expr2)

SOUNDEX
Returns a four-character soundex code for character strings that are composed of a contiguous sequence of valid single-byte roman letters. Syntax
SOUNDEX(char_expr)

Sybase IQ Quick Reference

29

STRING

Sybase IQ Release 11.2.x

STRING
Concatenates two or more string expressions into a single string. If a string_expr contains numeric data, Sybase IQ converts the data to a character string before any concatenation. The total string length cannot exceed 255 characters. Syntax
STRING(string_expr1 [, string_expr2, ... string_exprN])

SUBSTRING
Returns part of a character string. start species the character position at which the substring begins. length species the number of characters in the substring. Syntax
SUBSTRING(char_expr, start, length)

SUM
Returns the sum of the values in argument. NULL values are not included. SUM is valid for integer and oating point columns. Syntax
SUM([ALL | DISTINCT] argument)

SUSER_ID
Used in the select list or WHERE clause of a SELECT statement to return the ID number and login name of the server user from syslogins. Syntax
SUSER_ID ([server_user_name])

30

Functions

Sybase IQ Release 11.2.x

SUSER_NAME

SUSER_NAME
Used in the select list or WHERE clause of a SELECT statement to return the ID number and login name of the server user from syslogins. Syntax
SUSER_NAME ([server_user_id])

TRIM
Removes leading and trailing blanks. Only values equivalent to the space character in the current character set are removed Syntax
TRIM(char_expr)

UPPER or UCASE
Converts lowercase to uppercase, returning a character value. Syntax
UPPER(char_expr) UCASE(char_expr)

Sybase IQ Quick Reference

31

UPPER or UCASE

Sybase IQ Release 11.2.x

32

Functions

Вам также может понравиться