Informix Guide to SQL: Syntax - .Informix Guide to SQL Syntax Informix Extended Parallel Server,

  • View
    217

  • Download
    5

Embed Size (px)

Text of Informix Guide to SQL: Syntax - .Informix Guide to SQL Syntax Informix Extended Parallel Server,

  • Informix Guide to SQL

    Syntax

    Informix Extended Parallel Server, Version 8.3Informix Dynamic Server.2000, Version 9.2

    December 1999Part No. 000-6527

  • ii Informix Guide to SQL

    Published by Informix Press Informix Corporation4100 Bohannon DriveMenlo Park, CA 94025-1032

    1999 Informix Corporation. All rights reserved. The following are trademarks of Informix Corporationor its affiliates, one or more of which may be registered in the United States or other jurisdictions:

    Answers OnLineTM; C-ISAM; Client SDKTM; DataBlade; Data DirectorTM; Decision FrontierTM;Dynamic Scalable ArchitectureTM; Dynamic ServerTM; Dynamic ServerTM, Developer EditionTM;Dynamic ServerTM with Advanced Decision Support OptionTM; Dynamic ServerTM with ExtendedParallel OptionTM; Dynamic ServerTM with MetaCube; Dynamic ServerTM with Universal Data OptionTM;Dynamic ServerTM with Web Integration OptionTM; Dynamic ServerTM, Workgroup EditionTM;Dynamic Virtual MachineTM; Extended Parallel ServerTM; FormationTM; Formation ArchitectTM;Formation Flow EngineTM; Gold Mine Data Access; IIF.2000TM; i.ReachTM; i.SellTM; Illustra; Informix;Informix 4GL; Informix InquireSM; Informix Internet Foundation.2000TM; InformixLink;Informix Red Brick Decision ServerTM; Informix Session ProxyTM; Informix VistaTM; InfoShelfTM;InterforumTM; I-SpyTM; MediazationTM; MetaCube; NewEraTM; ON-BarTM; OnLine Dynamic ServerTM;OnLine/Secure Dynamic ServerTM; OpenCase; OrcaTM; PaVERTM; Red Brick and Design;Red Brick Data MineTM; Red Brick Mine BuilderTM; Red Brick DecisionscapeTM; Red Brick ReadyTM;Red Brick Systems; Regency Support; Rely on Red BrickSM; RISQL; Solution DesignSM; STARindexTM;STARjoinTM; SuperView; TARGETindexTM; TARGETjoinTM; The Data Warehouse Company;The one with the smartest data wins.TM; The world is being digitized. Were indexing it.SM;Universal Data Warehouse BlueprintTM; Universal Database ComponentsTM; Universal Web ConnectTM;ViewPoint; VisionaryTM; Web Integration SuiteTM. The Informix logo is registered with the United StatesPatent and Trademark Office. The DataBlade logo is registered with the United States Patent andTrademark Office.

    Documentation Team: Linda Briscoe, Evelyn Eldridge, Kathy Schaefer Francis, Mary Kraemer,Barbara Nomiyama, Tom Noronha, Elaina Von Haas, Richelle White

    GOVERNMENT LICENSE RIGHTS

    Software and documentation acquired by or for the US Government are provided with rights as follows:(1) if for civilian agency use, with rights as restricted by vendors standard license, as prescribed in FAR 12.212;(2) if for Dept. of Defense use, with rights as restricted by vendors standard license, unless superseded by anegotiated vendor license, as prescribed in DFARS 227.7202. Any whole or partial reproduction of software ordocumentation marked with this legend must reproduce this legend.

    : Syntax

  • Table of Contents

    Table ofContents

    IntroductionIn This Introduction . . . . . . . . . . . . . . . . . 3About This Manual . . . . . . . . . . . . . . . . . . 3

    Types of Users . . . . . . . . . . . . . . . . . . 3Software Dependencies . . . . . . . . . . . . . . . 4Assumptions About Your Locale. . . . . . . . . . . . 4Demonstration Databases . . . . . . . . . . . . . . 5

    New Features . . . . . . . . . . . . . . . . . . . . 6New Features in Version 8.3 . . . . . . . . . . . . . 6New Features in Version 9.2 . . . . . . . . . . . . . 8

    Documentation Conventions . . . . . . . . . . . . . . 10Typographical Conventions . . . . . . . . . . . . . 11Icon Conventions . . . . . . . . . . . . . . . . . 12Syntax Conventions . . . . . . . . . . . . . . . . 14Sample-Code Conventions . . . . . . . . . . . . . . 19

    Additional Documentation . . . . . . . . . . . . . . . 19On-Line Manuals . . . . . . . . . . . . . . . . . 20Printed Manuals . . . . . . . . . . . . . . . . . 20On-Line Help . . . . . . . . . . . . . . . . . . 20Error Message Documentation . . . . . . . . . . . . 20Documentation Notes, Release Notes, Machine Notes . . . . 21Related Reading . . . . . . . . . . . . . . . . . 22

    Compliance with Industry Standards . . . . . . . . . . . 22Informix Welcomes Your Comments . . . . . . . . . . . . 23

    Chapter 1 Overview of SQL SyntaxIn This Chapter . . . . . . . . . . . . . . . . . . . 1-3How to Enter SQL Statements . . . . . . . . . . . . . . 1-4How to Enter SQL Comments . . . . . . . . . . . . . . 1-6Categories of SQL Statements . . . . . . . . . . . . . . 1-9ANSI Compliance and Extensions . . . . . . . . . . . . 1-13

  • iv Inform

    Chapter 2 SQL StatementsIn This Chapter . . . . . . . . . . . . . . . . . . . 2-5

    ALLOCATE COLLECTION . . . . . . . . . . . . . 2-6ALLOCATE DESCRIPTOR . . . . . . . . . . . . . 2-8ALLOCATE ROW . . . . . . . . . . . . . . . . 2-10ALTER FRAGMENT . . . . . . . . . . . . . . . 2-12ALTER FUNCTION . . . . . . . . . . . . . . . . 2-41ALTER INDEX . . . . . . . . . . . . . . . . . 2-44ALTER PROCEDURE . . . . . . . . . . . . . . . 2-48ALTER ROUTINE . . . . . . . . . . . . . . . . 2-51ALTER TABLE . . . . . . . . . . . . . . . . . 2-55BEGIN WORK. . . . . . . . . . . . . . . . . . 2-91CLOSE . . . . . . . . . . . . . . . . . . . . 2-94CLOSE DATABASE . . . . . . . . . . . . . . . . 2-98COMMIT WORK. . . . . . . . . . . . . . . . . 2-100CONNECT . . . . . . . . . . . . . . . . . . . 2-103CREATE AGGREGATE . . . . . . . . . . . . . . 2-115CREATE CAST . . . . . . . . . . . . . . . . . 2-119CREATE DATABASE . . . . . . . . . . . . . . . 2-124CREATE DISTINCT TYPE . . . . . . . . . . . . . 2-127CREATE EXTERNAL TABLE . . . . . . . . . . . . 2-131CREATE FUNCTION . . . . . . . . . . . . . . . 2-146CREATE FUNCTION FROM. . . . . . . . . . . . . 2-155CREATE INDEX . . . . . . . . . . . . . . . . . 2-157CREATE OPAQUE TYPE . . . . . . . . . . . . . . 2-186CREATE OPCLASS . . . . . . . . . . . . . . . . 2-193CREATE PROCEDURE . . . . . . . . . . . . . . 2-199CREATE PROCEDURE FROM . . . . . . . . . . . . 2-209CREATE ROLE . . . . . . . . . . . . . . . . . 2-212CREATE ROUTINE FROM . . . . . . . . . . . . . 2-214CREATE ROW TYPE . . . . . . . . . . . . . . . 2-216CREATE SCHEMA . . . . . . . . . . . . . . . . 2-222CREATE SYNONYM . . . . . . . . . . . . . . . 2-226CREATE TABLE . . . . . . . . . . . . . . . . . 2-230CREATE Temporary TABLE . . . . . . . . . . . . . 2-286CREATE TRIGGER . . . . . . . . . . . . . . . . 2-296CREATE VIEW . . . . . . . . . . . . . . . . . 2-334DATABASE. . . . . . . . . . . . . . . . . . . 2-341DEALLOCATE COLLECTION . . . . . . . . . . . . 2-343DEALLOCATE DESCRIPTOR . . . . . . . . . . . . 2-345DEALLOCATE ROW . . . . . . . . . . . . . . . 2-347DECLARE . . . . . . . . . . . . . . . . . . . 2-349DELETE . . . . . . . . . . . . . . . . . . . . 2-373

    ix Guide to SQL: Syntax

  • DESCRIBE . . . . . . . . . . . . . . . . . . 2-382DISCONNECT . . . . . . . . . . . . . . . . . 2-389DROP AGGREGATE . . . . . . . . . . . . . . . 2-393DROP CAST . . . . . . . . . . . . . . . . . . 2-395DROP DATABASE. . . . . . . . . . . . . . . . 2-397DROP FUNCTION . . . . . . . . . . . . . . . 2-399DROP INDEX . . . . . . . . . . . . . . . . . 2-401DROP OPCLASS . . . . . . . . . . . . . . . . 2-403DROP PROCEDURE . . . . . . . . . . . . . . . 2-404DROP ROLE . . . . . . . . . . . . . . . . . . 2-407DROP ROUTINE . . . . . . . . . . . . . . . . 2-408DROP ROW TYPE . . . . . . . . . . . . . . . . 2-410DROP SYNONYM. . . . . . . . . . . . . . . . 2-412DROP TABLE . . . . . . . . . . . . . . . . . 2-413DROP TRIGGER . . . . . . . . . . . . . . . . 2-417DROP TYPE . . . . . . . . . . . . . . . . . . 2-418DROP VIEW . . . . . . . . . . . . . . . . . . 2-420EXECUTE. . . . . . . . . . . . . . . . . . . 2-422EXECUTE FUNCTION . . . . . . . . . . . . . . 2-434EXECUTE IMMEDIATE . . . . . . . . . . . . . . 2-441EXECUTE PROCEDURE . . . . . . . . . . . . . 2-444FETCH. . . . . . . . . . . . . . . . . . . . 2-455FLUSH. . . . . . . . . . . . . . . . . . . . 2-469FREE . . . . . . . . . . . . . . . . . . . . 2-472GET DESCRIPTOR . . . . . . . . . . . . . . . 2-475GET DIAGNOSTICS . . . . . . . . . . . . . . . 2-483GRANT . . . . . . . . . . . . . . . . . . . 2-500GRANT FRAGMENT . . . . . . . . . . . . . . 2-523INFO . . . . . . . . . . . . . . . . . . . . 2-532INSERT . . . . . . . . . . . . . . . . . . . 2-535LOAD . . . . . . . . . . . . . . . . . . . . 2-553LOCK TABLE . . . . . . . . . . . . . . . . . 2-563OPEN . . . . . . . . . . . . . . . . . . . . 2-566OUTPUT . . . . . . . . . . . . . . . . . . . 2-577PREPARE . . . . . . . . . . . . . . . . . . . 2-579PUT . . . . . . . . . . . . . . . . . . . . . 2-593RENAME COLUMN . . . . . . . . . . . . . . . 2-604RENAME DATABASE . . . . . . . . . . . . . . 2-606RENAME TABLE . . . . . . . . . . . . . . . . 2-607REVOKE . . . . . . . . . . . . . . . . . . . 2-610REVOKE FRAGMENT . . . . . . . . . . . . . . 2-628ROLLBACK WORK . . . . . . . . . . . . . . . 2-632

    Table of Contents v

  • vi Inform

    SELECT . . . . . . . . . . . . . . . . . . . . 2-634SET AUTOFREE . . . . . . . . . . . . . . . . . 2-691SET CONNECTION. . . . . . . . . . . . . . . . 2-694SET Database Object Mode . . . . . . . . . . . . . 2-700SET DATASKIP . . . . . . . . . . . . . . . . . 2-709SET DEBUG FILE TO . . . . . . . . . . . . . . . 2-712SET DEFERRED_PREPARE . . . . . . . . . . . . . 2-715SET DESCRIPTOR . . . . . . . . . . . . . . . . 2-719SET EXPLAIN . . . . . . . . . . . . . . . . . . 2-730SET ISOLATION . . . . . . . . . . . . . . . . . 2-736SET LOCK MODE . . . . . . . . . . . . . . . . 2-742SET LOG . . . . . . . . . . . . . . . . . . . 2-745SET OPTIMIZATION . . . . . . . . . . . . . . . 2-747SET PDQPRIORITY . . . . . . . . . . . . . . . . 2-751SET PLOAD FILE . . . . . . . . . . . . . . . . 2-755SET Residency. . . . . . . . . . . . . . . . . . 2-756SET ROLE . . . . . . . . . . . . . . . . . . . 2-758SET SCHEDULE LEVEL . . . . . . . . . . . . . . 2-760SET SESSION AUTHORIZATION . . . . . . . . . . . 2-761SET STAT