msql command reference

866
Ingres ® 9.3 SQL Reference Guide ING-93-SQL-06

Upload: uttam-kesri

Post on 10-Apr-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Ingres 9.3

SQL Reference Guide

ING-93-SQL-06

This Documentation is for the end user's informational purposes only and may be subject to change or withdrawal by Ingres Corporation ("Ingres") at any time. This Documentation is the proprietary information of Ingres and is protected by the copyright laws of the United States and international treaties. It is not distributed under a GPL license. You may make printed or electronic copies of this Documentation provided that such copies are for your own internal use and all Ingres copyright notices and legends are affixed to each reproduced copy. You may publish or distribute this document, in whole or in part, so long as the document remains unchanged and is disseminated with the applicable Ingres software. Any such publication or distribution must be in the same manner and medium as that used by Ingres, e.g., electronic download via website with the software or on a CD ROM. Any other use, such as any dissemination of printed copies or use of this documentation, in whole or in part, in another publication, requires the prior written consent from an authorized representative of Ingres. To the extent permitted by applicable law, INGRES PROVIDES THIS DOCUMENTATION "AS IS" WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. IN NO EVENT WILL INGRES BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR DAMAGE, DIRECT OR INDIRECT, FROM THE USER OF THIS DOCUMENTATION, INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF INGRES IS EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE. The manufacturer of this Documentation is Ingres Corporation. For government users, the Documentation is delivered with "Restricted Rights" as set forth in 48 C.F.R. Section 12.212, 48 C.F.R. Sections 52.227-19(c)(1) and (2) or DFARS Section 252.227-7013 or applicable successor provisions. Copyright 2009 Ingres Corporation. All Rights Reserved. Ingres, OpenROAD, and EDBC are registered trademarks of Ingres Corporation. All other trademarks, trade names, service marks, and logos referenced herein belong to their respective companies.

Contents

Chapter 1: Introducing the SQL Reference Guide 29

In This Guide ...................................................................................................................... 29 Audience............................................................................................................................ 29 Enterprise Access Compatibility ............................................................................................. 29 System-specific Text in This Guide ......................................................................................... 30 Terminology Used in This Guide............................................................................................. 30 Syntax Conventions Used in This Guide .................................................................................. 31

Chapter 2: Introducing SQL

33

SQL Functionality ................................................................................................................ 33 Types of SQL Statements ..................................................................................................... 33 Interactive and Embedded SQL ............................................................................................. 34 Interactive SQL ............................................................................................................. 34 Embedded SQL .............................................................................................................. 34 SQL Naming and Statement Rules ......................................................................................... 37 Object Naming Rules ...................................................................................................... 37 Regular and Delimited Identifiers ..................................................................................... 39 Statement Terminators ................................................................................................... 43 Correlation Names............................................................................................................... 43 Correlation Name Rules .................................................................................................. 44 Database Procedures ........................................................................................................... 45 Determine Settings for a Database ................................................................................... 46 Object Management Extension .............................................................................................. 46 ANSI Compliance ................................................................................................................ 46 OpenSQL ........................................................................................................................... 46 Security Levels ................................................................................................................... 47

Chapter 3: Understanding SQL Data Types

49

SQL Data Types .................................................................................................................. 49 Character Data Types ..................................................................................................... 50 Unicode Data Types ....................................................................................................... 56 Numeric Data Types ....................................................................................................... 56 Date/Time Data Types .................................................................................................... 60 Abstract Data Types ....................................................................................................... 74 Binary Data Types.......................................................................................................... 78 Storage Formats of Data Types ............................................................................................. 82 Literals .............................................................................................................................. 84

Contents iii

String Literals................................................................................................................ 84 Numeric Literals ............................................................................................................ 86 Date/Time Literals ......................................................................................................... 87 SQL Constants .................................................................................................................... 90 Nulls ................................................................................................................................. 91 Nulls and Comparisons ................................................................................................... 91 Nulls and Aggregate Functions ......................................................................................... 92 Nulls and Integrity Constraints......................................................................................... 93

Chapter 4: Understanding the Elements of SQL Statements

95

SQL Operators .................................................................................................................... 95 Arithmetic Operators ...................................................................................................... 96 Comparison Operators .................................................................................................... 96 Logical Operators........................................................................................................... 97 SQL Operations ................................................................................................................... 98 String Concatenation Operations ...................................................................................... 98 Assignment Operations ................................................................................................... 99 Arithmetic Operations................................................................................................... 104 SQL Functions................................................................................................................... 113 Scalar Functions .......................................................................................................... 113 Aggregate Functions..................................................................................................... 142 IFNULL Function .......................................................................................................... 147 Universal Unique Identifier (UUID) ................................................................................. 148 Expressions in SQL ............................................................................................................ 152 Case Expressions ......................................................................................................... 152 Cast Expressions.......................................................................................................... 153 Sequence Expressions .................................................................................................. 154 Predicates in SQL .............................................................................................................. 155 Comparison Predicate ................................................................................................... 155 Pattern-matching Predicates .......................................................................................... 156 BETWEEN Predicate...................................................................................................... 163 IN Predicate ................................................................................................................ 164 Any-or-All Predicate ..................................................................................................... 164 EXISTS Predicate ......................................................................................................... 166 IS NULL Predicate ........................................................................................................ 166 IS INTEGER Predicate ................................................................................................... 167 IS DECIMAL Predicate................................................................................................... 168 IS FLOAT Predicate ...................................................................................................... 169 Search Conditions in SQL Statements................................................................................... 169 Subqueries ....................................................................................................................... 170 Subqueries in the WHERE Clause.................................................................................... 171 Subqueries in the FROM Clause (Derived Tables) .............................................................. 172

iv SQL Reference Guide

Chapter 5: Working with Embedded SQL

175

Embedded SQL Statements................................................................................................. 175 How Embedded SQL Statements Are Processed ..................................................................... 175 General Syntax and Rules of an Embedded SQL Statement...................................................... 176 Syntax Conventions Used in this Chapter......................................................................... 176 Structure of an Embedded SQL Program ............................................................................... 177 Host Language Variables in Embedded SQL ........................................................................... 179 Variable Declaration ..................................................................................................... 180 Include Statement ....................................................................................................... 181 Variable Usage ............................................................................................................ 181 Variable Structures ...................................................................................................... 182 Dclgen UtilityGenerate Structure ................................................................................. 183 Indicator Variables ....................................................................................................... 183 Null Indicator Arrays and Host Structures ........................................................................ 187 Data Manipulation with Cursors ........................................................................................... 188 Example: Cursor Processing .......................................................................................... 189 Cursor Declaration ....................................................................................................... 190 Open Cursors .............................................................................................................. 190 Readonly Cursors......................................................................................................... 191 Open Cursors and Transaction Processing........................................................................ 191 Fetch Data From Cursor ................................................................................................ 192 Fetch Rows Inserted by Other Queries ............................................................................ 193 Using Cursors to Update Data ........................................................................................ 193 Cursor Position for Updates ........................................................................................... 194 Delete Data Using Cursors............................................................................................. 194 Closing Cursors ........................................................................................................... 196 Summary of Cursor Positioning ...................................................................................... 196 Cursors Versus Select Loops .......................................................................................... 199 Dynamic Programming ....................................................................................................... 200 SQLDA ....................................................................................................................... 200 Using Clause ............................................................................................................... 204 Dynamic SQL Statements.............................................................................................. 205 Execute a Dynamic Non-select Statement........................................................................ 208 Execute a Dynamic Select Statement .............................................................................. 211 Select Statement with Execute Immediate....................................................................... 220 Retrieve Results Using Cursors....................................................................................... 221 Data Handlers for Large Objects .......................................................................................... 223 Errors in Data Handlers................................................................................................. 224 Restrictions on Data Handlers ........................................................................................ 224 Large Objects in Dynamic SQL ....................................................................................... 224 Example: PUT DATA Handler ......................................................................................... 226 Example: GET DATA Handler ......................................................................................... 228

Contents v

Example: Dynamic SQL Data Handler ............................................................................. 230 Ingres 4GL Interface.......................................................................................................... 233

Chapter 6: Working with Transactions and Handling Errors

235

Transactions ..................................................................................................................... 235 How Transactions Work ................................................................................................ 235 How Consistency is Maintained During Transactions .......................................................... 235 Set Autocommit OnCommit Individual Statement........................................................... 236 Statements Used to Control Transactions ........................................................................ 236 How Effects of a Transaction Are Controlled ..................................................................... 237 Savepoints on Multi-statement Transactions .................................................................... 238 How the Transaction Processing System Handles Interrupts ............................................... 239 Abort Policy for Transactions and Statements................................................................... 240 Two Phase Commit ............................................................................................................ 241 Statements that Support Two Phase Commit ................................................................... 242 Coordinator Applications for a Two Phase Commit............................................................. 243 Manual Termination of a Distributed Transaction .............................................................. 244 Example: Using Two-Phase Commit................................................................................ 245 Ways to Obtain Status Information ...................................................................................... 249 SESSION_PRIV FunctionDetermine If Session Has a Privilege .......................................... 250 DBMSINFO FunctionReturn Information About the Current Session ................................... 251 INQUIRE_SQL Function................................................................................................. 260 SQL Communications Area (SQLCA)................................................................................ 261 SQLCODE and SQLSTATE .............................................................................................. 263 Error Handling .................................................................................................................. 265 Types of Error Codes .................................................................................................... 265 Error Message Format .................................................................................................. 266 Display of Error Messages ............................................................................................. 266 Error Handling in Embedded Applications......................................................................... 267 Set_Sql(Programquit)Specify Whether to Abort on Error ................................................. 273 Handling of Deadlocks .................................................................................................. 273

Chapter 7: Understanding Database Procedures, Sessions, and Events

279

How Database Procedures Are Created, Invoked, and Executed................................................ 279 Benefits of Database Procedures .................................................................................... 280 Contents of Database Procedures ................................................................................... 280 Permissions on Database Procedures .............................................................................. 281 Methods of Executing Procedures ................................................................................... 282 How Parameters Are Passed in Database Procedures ......................................................... 283 Row-Producing Procedures ............................................................................................ 283 Table Procedure........................................................................................................... 286

vi SQL Reference Guide

Effects of Errors in Database Procedures ......................................................................... 292 Messages from Database Procedures .............................................................................. 295 Rules............................................................................................................................... 297 Examples: Database Procedures and Rules............................................................................ 298 AFTER Rule Example: The Audit Procedure and Rule ......................................................... 299 BEFORE Rule Example: The Audit Procedure and Rule ....................................................... 301 Multiple Session Connections .............................................................................................. 302 Multiple Sessions ......................................................................................................... 302 Session Identification ................................................................................................... 302 Session Switching ........................................................................................................ 303 Disconnection of Sessions ............................................................................................. 303 Status Information in Multiple Sessions ........................................................................... 304 What You Should Know When Creating Multiple Sessions ................................................... 304 Example: Two Open Sessions ........................................................................................ 305 Examples: Session Switching......................................................................................... 306 Database Events ............................................................................................................... 307 Example: Database Events in Conjunction with Rules ........................................................ 308 Database Event Statements .......................................................................................... 310

Chapter 8: SQL Statements

321

SQL Release ..................................................................................................................... 323 Context for SQL Statements................................................................................................ 323 Statements for Ingres Star ................................................................................................. 324 Alter Group ...................................................................................................................... 324 Syntax ....................................................................................................................... 325 Embedded Usage ......................................................................................................... 325 Permissions................................................................................................................. 326 Locking ...................................................................................................................... 326 Related Statements...................................................................................................... 326 Examples: Alter Group.................................................................................................. 326 Alter Location ................................................................................................................... 326 Syntax ....................................................................................................................... 327 Embedded Usage ......................................................................................................... 327 Permissions................................................................................................................. 327 Locking ...................................................................................................................... 327 Related Statements...................................................................................................... 328 Examples: Alter Location............................................................................................... 328 Alter Profile ...................................................................................................................... 328 Syntax ....................................................................................................................... 329 Embedded Usage ......................................................................................................... 332 Permissions................................................................................................................. 332 Locking ...................................................................................................................... 332

Contents vii

Related Statements...................................................................................................... 332 Examples: Alter Profile ................................................................................................. 333 Alter Role ......................................................................................................................... 333 Syntax ....................................................................................................................... 334 Embedded Usage ......................................................................................................... 335 Permissions................................................................................................................. 335 Locking ...................................................................................................................... 335 Related Statements...................................................................................................... 335 Examples: Alter Role .................................................................................................... 336 Alter Security_Audit........................................................................................................... 336 Syntax ....................................................................................................................... 337 Embedded Usage ......................................................................................................... 337 Permissions................................................................................................................. 338 Related Statements...................................................................................................... 338 Examples: Alter Security_Audit ...................................................................................... 338 Alter Sequence ................................................................................................................. 338 Syntax ....................................................................................................................... 339 Permissions................................................................................................................. 339 Locking and Sequences................................................................................................. 339 Related Statements...................................................................................................... 339 Examples: Alter Sequence............................................................................................. 339 Alter Table ....................................................................................................................... 340 Syntax ....................................................................................................................... 341 Constraint Specifications ............................................................................................... 343 Embedded Usage ......................................................................................................... 347 Permissions................................................................................................................. 347 Locking ...................................................................................................................... 347 Related Statements...................................................................................................... 348 Examples: Alter Table................................................................................................... 348 Alter User......................................................................................................................... 349 Syntax ....................................................................................................................... 350 Embedded Usage ......................................................................................................... 352 Permissions................................................................................................................. 352 Locking ...................................................................................................................... 352 Related Statements...................................................................................................... 352 Examples: Alter User.................................................................................................... 353 Begin Declare ................................................................................................................... 353 Syntax ....................................................................................................................... 354 Description ................................................................................................................. 354 Permissions................................................................................................................. 354 Related Statements...................................................................................................... 354 Example: Begin Declare ................................................................................................ 354 Call ................................................................................................................................. 355

viii SQL Reference Guide

Syntax ....................................................................................................................... 355 Call Description ........................................................................................................... 356 Permissions................................................................................................................. 356 Examples: Call ............................................................................................................ 357 Close ............................................................................................................................... 357 Syntax ....................................................................................................................... 357 Description ................................................................................................................. 357 Embedded Usage ......................................................................................................... 358 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 358 Permissions................................................................................................................. 358 Locking ...................................................................................................................... 358 Related Statements...................................................................................................... 358 Example: Close ........................................................................................................... 358 Comment On .................................................................................................................... 359 Syntax ....................................................................................................................... 359 Description ................................................................................................................. 359 Embedded Usage ......................................................................................................... 359 Permissions................................................................................................................. 359 Locking ...................................................................................................................... 360 Related Statements...................................................................................................... 360 Examples: Comment On ............................................................................................... 360 Commit ........................................................................................................................... 360 Syntax ....................................................................................................................... 360 Description ................................................................................................................. 361 Embedded Usage ......................................................................................................... 361 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 361 Permissions................................................................................................................. 361 Locking ...................................................................................................................... 362 Performance ............................................................................................................... 362 Related Statements...................................................................................................... 362 Example: Commit ........................................................................................................ 362 Connect ........................................................................................................................... 362 Syntax ....................................................................................................................... 363 Description ................................................................................................................. 364 Connecting with Distributed Transactions ........................................................................ 365 Creating Multiple Sessions............................................................................................. 365 Permissions................................................................................................................. 366 Locking ...................................................................................................................... 366 Related Statements...................................................................................................... 366 Examples: Connect ...................................................................................................... 367 Copy ............................................................................................................................... 369 Syntax ....................................................................................................................... 369 Binary Copying ............................................................................................................ 370

Contents ix

Column Formats for COPY ............................................................................................. 372 Filename Specification for COPY ..................................................................................... 379 With Clause Options for COPY ........................................................................................ 380 Permissions................................................................................................................. 382 Locking ...................................................................................................................... 382 Restrictions and Considerations...................................................................................... 383 Related Statements...................................................................................................... 383 Example: Copy ............................................................................................................ 384 Copy From | Into Program .................................................................................................. 386 Syntax ....................................................................................................................... 387 Bulk Copying............................................................................................................... 388 Row Formats ............................................................................................................... 389 Fixed-length Formats.................................................................................................... 389 Variable-length Formats................................................................................................ 390 COPY Arguments ......................................................................................................... 390 Handler Code Examples ................................................................................................ 392 Create Dbevent................................................................................................................. 398 Syntax ....................................................................................................................... 398 Description ................................................................................................................. 399 Embedded Usage ......................................................................................................... 399 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 399 Permissions................................................................................................................. 399 Locking ...................................................................................................................... 399 Related Statements...................................................................................................... 399 Create Group .................................................................................................................... 400 Syntax ....................................................................................................................... 400 Embedded Usage ......................................................................................................... 400 Permissions................................................................................................................. 401 Locking ...................................................................................................................... 401 Related Statements...................................................................................................... 401 Examples: Create Group ............................................................................................... 401 Create Index .................................................................................................................... 401 Syntax ....................................................................................................................... 402 Description ................................................................................................................. 405 Index Storage Structure ............................................................................................... 406 Unique Indexes ........................................................................................................... 406 Effect of the Unique_Scope Option on Updates ................................................................. 406 Index Location............................................................................................................. 407 Parallel Index Building .................................................................................................. 407 Embedded Usage ......................................................................................................... 407 Permissions................................................................................................................. 407 Locking ...................................................................................................................... 408 Related Statements...................................................................................................... 408

x SQL Reference Guide

Examples: Create Index................................................................................................ 408 Create Integrity ................................................................................................................ 409 Syntax ....................................................................................................................... 410 Locking ...................................................................................................................... 410 Performance ............................................................................................................... 410 Embedded Usage ......................................................................................................... 411 Permissions................................................................................................................. 411 Related Statements...................................................................................................... 411 Examples: Create Integrity............................................................................................ 411 Create Location................................................................................................................. 411 Syntax ....................................................................................................................... 412 Embedded Usage ......................................................................................................... 412 Permissions................................................................................................................. 413 Locking ...................................................................................................................... 413 Related Statements...................................................................................................... 413 Examples: Create Location ............................................................................................ 414 Create Procedure .............................................................................................................. 414 Syntax ....................................................................................................................... 415 Description ................................................................................................................. 417 Parameter Modes ......................................................................................................... 419 Nullability and Default Values for Parameters ................................................................... 420 SET OF Parameters ...................................................................................................... 421 Embedded Usage ......................................................................................................... 422 Permissions................................................................................................................. 422 Related Statements...................................................................................................... 423 Examples: Create Procedure.......................................................................................... 423 Create Profile.................................................................................................................... 425 Syntax ....................................................................................................................... 426 Description ................................................................................................................. 428 Embedded Usage ......................................................................................................... 428 Permissions................................................................................................................. 428 Locking ...................................................................................................................... 428 Related Statements...................................................................................................... 429 Examples: Create Profile ............................................................................................... 429 Create Role ...................................................................................................................... 429 Syntax ....................................................................................................................... 430 Embedded Usage ......................................................................................................... 431 Permissions................................................................................................................. 431 Locking ...................................................................................................................... 432 Related Statements...................................................................................................... 432 Examples: Create Role.................................................................................................. 432 Create Rule ...................................................................................................................... 433 Syntax ....................................................................................................................... 434

Contents xi

Row and Statement Level Rules ..................................................................................... 435 Table_Condition........................................................................................................... 437 Embedded Usage ......................................................................................................... 439 Permissions................................................................................................................. 439 Locking ...................................................................................................................... 439 Related Statements...................................................................................................... 439 Examples: Create Rule ................................................................................................. 440 Create Schema ................................................................................................................. 441 Syntax ....................................................................................................................... 441 Description ................................................................................................................. 442 Embedded Usage ......................................................................................................... 443 Permissions................................................................................................................. 443 Locking ...................................................................................................................... 443 Related Statements...................................................................................................... 443 Example: Create Schema .............................................................................................. 444 Create Security_Alarm ....................................................................................................... 444 Syntax ....................................................................................................................... 445 Embedded Usage ......................................................................................................... 445 Permissions................................................................................................................. 446 Locking ...................................................................................................................... 446 Related Statements...................................................................................................... 446 Examples: Create Security_Alarm .................................................................................. 446 Create Sequence ............................................................................................................... 447 Syntax ....................................................................................................................... 447 Permissions................................................................................................................. 450 Locking and Sequences................................................................................................. 450 Related Statements...................................................................................................... 450 Examples: Create Sequence .......................................................................................... 451 Create Synonym ............................................................................................................... 451 Syntax ....................................................................................................................... 451 Embedded Usage ......................................................................................................... 452 Permissions................................................................................................................. 452 Locking ...................................................................................................................... 452 Related Statements...................................................................................................... 452 Examples: Create Synonym........................................................................................... 452 Create Table ..................................................................................................................... 452 Syntax ....................................................................................................................... 453 Description ................................................................................................................. 454 Column SpecificationDefine Column Characteristics ........................................................ 457 Using Create Table...As Select ....................................................................................... 465 Constraints ................................................................................................................. 467 Constraint With_ClauseDefine Constraint Index Options .................................................. 475 Constraints and Integrities ............................................................................................ 477

xii SQL Reference Guide

With_Clause for Create Table......................................................................................... 478 With_Clause for Create Table...As Select ......................................................................... 482 Partitioned Tables ........................................................................................................ 483 Embedded Usage ......................................................................................................... 488 Permissions................................................................................................................. 488 Locking ...................................................................................................................... 488 Related Statements...................................................................................................... 488 Examples: Create Table ................................................................................................ 489 Create User ...................................................................................................................... 494 Syntax ....................................................................................................................... 495 Embedded Usage ......................................................................................................... 497 Permissions................................................................................................................. 497 Locking ...................................................................................................................... 497 Related Statements...................................................................................................... 498 Examples: Create User ................................................................................................. 499 Create View...................................................................................................................... 499 Syntax ....................................................................................................................... 500 Description ................................................................................................................. 500 With Check Option Clause ............................................................................................. 501 Embedded Usage ......................................................................................................... 501 Permissions................................................................................................................. 501 Locking ...................................................................................................................... 501 Related Statements...................................................................................................... 502 Examples: Create View ................................................................................................. 502 Declare ............................................................................................................................ 503 Syntax ....................................................................................................................... 504 Permissions................................................................................................................. 504 Related Statements...................................................................................................... 504 Example: Declare......................................................................................................... 504 Declare Cursor .................................................................................................................. 505 Syntax ....................................................................................................................... 505 Description ................................................................................................................. 506 Cursor Updates............................................................................................................ 507 Cursor Modes .............................................................................................................. 509 Embedded Usage ......................................................................................................... 510 Usage in OpenAPI ........................................................................................................ 511 Permissions................................................................................................................. 511 Locking ...................................................................................................................... 511 Related Statements...................................................................................................... 511 Examples: Declare Cursor ............................................................................................. 512 Declare Global Temporary Table .......................................................................................... 515 Syntax ....................................................................................................................... 516 Description ................................................................................................................. 518

Contents xiii

SESSION Schema Qualifier............................................................................................ 519 Embedded Usage ......................................................................................................... 519 Permissions................................................................................................................. 519 Restrictions................................................................................................................. 520 Related Statements...................................................................................................... 521 Examples: Declare Global Temporary Table ..................................................................... 521 Declare Statement............................................................................................................. 522 Syntax ....................................................................................................................... 522 Related Statements...................................................................................................... 522 Example: Declare Statement ......................................................................................... 522 Declare Table.................................................................................................................... 523 Syntax ....................................................................................................................... 523 Description ................................................................................................................. 523 Permissions................................................................................................................. 523 Example: Declare Table ................................................................................................ 524 Delete ............................................................................................................................. 524 Syntax ....................................................................................................................... 525 Embedded Usage ......................................................................................................... 525 Permissions................................................................................................................. 528 Locking ...................................................................................................................... 528 Related Statements...................................................................................................... 528 Example: Delete .......................................................................................................... 528 Describe .......................................................................................................................... 528 Syntax ....................................................................................................................... 529 Description ................................................................................................................. 529 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 530 Permissions................................................................................................................. 530 Related Statements...................................................................................................... 530 Describe Input .................................................................................................................. 530 Syntax ....................................................................................................................... 531 Disable Security_Audit ....................................................................................................... 531 Syntax ....................................................................................................................... 532 Embedded Usage ......................................................................................................... 533 Permissions................................................................................................................. 533 Locking ...................................................................................................................... 533 Related Statements...................................................................................................... 533 Example: Disable Security_Audit .................................................................................... 534 Disconnect ....................................................................................................................... 534 Syntax ....................................................................................................................... 534 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 535 Permissions................................................................................................................. 535 Locking ...................................................................................................................... 535 Related Statements...................................................................................................... 535

xiv SQL Reference Guide

Examples: Disconnect .................................................................................................. 535 Drop................................................................................................................................ 536 Syntax ....................................................................................................................... 536 Description ................................................................................................................. 537 Embedded Usage ......................................................................................................... 537 Permissions................................................................................................................. 537 Locking ...................................................................................................................... 537 Related Statements...................................................................................................... 538 Examples: Drop ........................................................................................................... 538 Drop Dbevent ................................................................................................................... 538 Syntax ....................................................................................................................... 538 Embedded Usage ......................................................................................................... 538 Permissions................................................................................................................. 539 Related Statements...................................................................................................... 539 Example: Drop Location ................................................................................................ 539 Drop Group ...................................................................................................................... 539 Syntax ....................................................................................................................... 540 Embedded Usage ......................................................................................................... 540 Permissions................................................................................................................. 540 Locking ...................................................................................................................... 540 Related Statements...................................................................................................... 540 Examples: Drop Group ................................................................................................. 540 Drop Integrity................................................................................................................... 541 Syntax ....................................................................................................................... 541 Embedded Usage ......................................................................................................... 541 Permissions................................................................................................................. 541 Related Statements...................................................................................................... 542 Examples: Drop Integrity .............................................................................................. 542 Drop Location ................................................................................................................... 542 Syntax ....................................................................................................................... 542 Embedded Usage ......................................................................................................... 542 Permissions................................................................................................................. 542 Locking ...................................................................................................................... 543 Related Statements: Drop Location ................................................................................ 543 Drop Procedure ................................................................................................................. 543 Syntax ....................................................................................................................... 543 Embedded Usage ......................................................................................................... 543 Permissions................................................................................................................. 543 Related Statements...................................................................................................... 544 Example: Drop Procedure.............................................................................................. 544 Drop Profile ...................................................................................................................... 544 Syntax ....................................................................................................................... 544 Permissions................................................................................................................. 545

Contents xv

Locking ...................................................................................................................... 545 Related Statements...................................................................................................... 545 Example: Drop Profile................................................................................................... 545 Drop Role......................................................................................................................... 545 Syntax ....................................................................................................................... 545 Embedded Usage ......................................................................................................... 546 Permissions................................................................................................................. 546 Locking ...................................................................................................................... 546 Related Statements...................................................................................................... 546 Example: Drop Role ..................................................................................................... 546 Drop Rule......................................................................................................................... 546 Syntax ....................................................................................................................... 546 Embedded Usage ......................................................................................................... 547 Permissions................................................................................................................. 547 Related Statements...................................................................................................... 547 Example: Drop Rule ..................................................................................................... 547 Drop Security_Alarm.......................................................................................................... 547 Syntax ....................................................................................................................... 548 Embedded Usage ......................................................................................................... 548 Permissions................................................................................................................. 548 Locking ...................................................................................................................... 548 Related Statements...................................................................................................... 548 Examples: Drop Security_Alarm..................................................................................... 549 Drop Sequence ................................................................................................................. 549 Syntax ....................................................................................................................... 549 Permissions................................................................................................................. 549 Locking and Sequences................................................................................................. 549 Related Statements...................................................................................................... 550 Examples: Drop Sequence............................................................................................. 550 Drop Synonym.................................................................................................................. 550 Syntax ....................................................................................................................... 550 Embedded Usage ......................................................................................................... 550 Permissions................................................................................................................. 550 Locking ...................................................................................................................... 551 Related Statements...................................................................................................... 551 Example: Drop Synonym .............................................................................................. 551 Drop User ........................................................................................................................ 551 Syntax ....................................................................................................................... 551 Embedded Usage ......................................................................................................... 551 Locking ...................................................................................................................... 552 Related Statements...................................................................................................... 552 Example: Drop User ..................................................................................................... 552 Enable Security_Audit ........................................................................................................ 552

xvi SQL Reference Guide

Syntax ....................................................................................................................... 553 Embedded Usage ......................................................................................................... 554 Permissions................................................................................................................. 554 Locking ...................................................................................................................... 554 Related Statements...................................................................................................... 554 Example: Enable Security_Audit..................................................................................... 555 Enddata ........................................................................................................................... 555 Syntax ....................................................................................................................... 555 Permissions................................................................................................................. 555 Examples: Enddata ...................................................................................................... 555 End Declare Section........................................................................................................... 555 Syntax ....................................................................................................................... 555 Permissions................................................................................................................. 556 Related Statements...................................................................................................... 556 Endselect ......................................................................................................................... 556 Syntax ....................................................................................................................... 556 Description ................................................................................................................. 556 Permissions................................................................................................................. 557 Locking ...................................................................................................................... 557 Related Statements...................................................................................................... 557 Example: Endselect...................................................................................................... 557 Execute ........................................................................................................................... 557 Syntax ....................................................................................................................... 558 Description ................................................................................................................. 559 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 560 Permissions................................................................................................................. 561 Locking ...................................................................................................................... 561 Related Statements...................................................................................................... 561 Examples: Execute....................................................................................................... 562 Execute Immediate............................................................................................................ 562 Syntax ....................................................................................................................... 563 Description ................................................................................................................. 563 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 565 Permissions................................................................................................................. 565 Locking ...................................................................................................................... 566 Related Statements...................................................................................................... 566 Examples: Execute Immediate....................................................................................... 566 Execute Procedure............................................................................................................. 567 Syntax ....................................................................................................................... 567 Description ................................................................................................................. 568 Passing Parameters - Non-Dynamic Version ..................................................................... 568 Passing Parameters - Dynamic Version............................................................................ 569 Positional Parameters Sample Syntax ............................................................................. 571

Contents xvii

Temporary Table Parameter .......................................................................................... 571 Execute Procedure Loops .............................................................................................. 572 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 573 Permissions................................................................................................................. 573 Locking ...................................................................................................................... 573 Performance ............................................................................................................... 573 Related Statements...................................................................................................... 573 Examples: Execute Procedure ........................................................................................ 574 Fetch ............................................................................................................................... 575 Syntax ....................................................................................................................... 576 Description ................................................................................................................. 577 Readonly Cursors and Performance ................................................................................ 577 Usage in OpenAPI, ODBC, JDBC, .NET............................................................................. 577 Permissions................................................................................................................. 578 Related Statements...................................................................................................... 578 Examples: Fetch .......................................................................................................... 579 For-EndFor ....................................................................................................................... 579 Syntax ....................................................................................................................... 580 Description ................................................................................................................. 580 Permissions................................................................................................................. 581 Example: For-EndFor.................................................................................................... 582 Get Data .......................................................................................................................... 582 Syntax ....................................................................................................................... 583 Permissions................................................................................................................. 583 Related Statements...................................................................................................... 583 Get Dbevent ..................................................................................................................... 584 Syntax ....................................................................................................................... 584 Usage in OpenAPI ........................................................................................................ 584 Permissions................................................................................................................. 584 Related Statements...................................................................................................... 585 Grant (privilege) ............................................................................................................... 585 Syntax ....................................................................................................................... 586 Types of Privileges ....................................................................................................... 587 Privilege Defaults ......................................................................................................... 594 Grant All Privileges Option............................................................................................. 595 Grant Option Clause ..................................................................................................... 598 Embedded Usage ......................................................................................................... 598 Permissions................................................................................................................. 599 Locking ...................................................................................................................... 599 Related Statements...................................................................................................... 599 Examples: Grant (privilege)........................................................................................... 600 Grant (role) ...................................................................................................................... 601 Syntax ....................................................................................................................... 601

xviii SQL Reference Guide

Permissions................................................................................................................. 601 Related Statements...................................................................................................... 601 Example: Grant (role) .................................................................................................. 601 Help ................................................................................................................................ 602 Syntax ....................................................................................................................... 603 Wildcards in Help Statement.......................................................................................... 605 Permissions................................................................................................................. 606 Locking ...................................................................................................................... 606 Related Statements...................................................................................................... 606 Examples: Help ........................................................................................................... 607 If-Then-Else ..................................................................................................................... 607 Syntax ....................................................................................................................... 607 Description ................................................................................................................. 608 Permissions................................................................................................................. 610 Example: If-Then-Else .................................................................................................. 610 Include ............................................................................................................................ 611 Syntax ....................................................................................................................... 611 Description ................................................................................................................. 612 Permissions................................................................................................................. 612 Related Statements...................................................................................................... 612 Examples: Include ...........................................................