HPlogo ALLBASE/SQL Reference Manual: HP 9000 Computer Systems > Chapter 10 SQL Statements A - D

SQL Statement Summary

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

SQL statements fall into four groups. General-purpose statements are used programmatically, interactively, and in procedures. Application programming statements are used in application programs. Database administration statements are usually used interactively. Procedure, control flow, and status statements are used only in procedures. Within each of these groups, the SQL statements fall into categories, as shown in Table 10-1.

Table 10-1 SQL Statement Summary

GroupCategoryStatementStatement Use

General Purpose Statements

DBEnvironment session management

  CONNECTBegins a DBEnvironment session.
  DISCONNECTTerminates a connection to a DBEnvironment, or all connections.
  SET CONNECTIONSets the current connection within the currently connected set of DBEnvironments.
  SET MULTI TRANSACTIONSwitches between single-transaction mode and multi-transaction mode.
  RELEASETerminates a DBEnvironment session.
 Data definition
 DatabasesCREATE SCHEMADefines a database and associates it with an authorization name.
 IndexesCREATE INDEXDefines an index for a table based on one or more of its columns.
  DROP INDEXDeletes an index.
 TablesALTER TABLEAdds to a table new columns and constraints, or drops constraints from a table, and assigns a table to a partition or removes it from a partition.
  RENAME COLUMNDefines a new name for an existing column.
  RENAME TABLEDefines a new name for an existing table.
  CREATE TABLEDefines a table and assigns it to a partition.
  TRUNCATE TABLEDeletes all rows from a table.
  DROP TABLEDeletes a table and any authorities, indexes, rules, and views based on it.
 ViewsCREATE VIEWDefines a view based on a table, another view, or a combination of tables and views.
  DROP VIEWDeletes the definition of a view as well as authorities or views based on the view.
 RulesCREATE RULEDefines a rule for a table and associates it with INSERTS, UPDATES, and/or DELETES.
  DROP RULEDeletes a rule.
 Groups, DBEFileSet, DBEFilesRefer to the database administration statements. 
 ProceduresCREATE PROCEDUREDefines a procedure for storage in the DBEnvironment.
  DROP PROCEDUREDeletes a procedure.
 PartitionsCREATE PARTITIONDefines a partition for audit logging in the DBEnvironment.
  DROP PARTITIONDeletes a partition.

Data manipulation

  DELETEDeletes one or more rows from a single table or view.
  INSERTAdds a row to a single table or view.
  SELECTRetrieves data from one or more tables or views.
  UPDATEChanges the values of one or more columns in all rows of a specific table or view that satisfy a search condition.
  DROP MODULEDeletes a preprocessed module.
  EXECUTEExecutes dynamically preprocessed statements.
  EXECUTE IMMEDIATEDefines and executes dynamic statements.
  PREPAREDynamically preprocesses statements, storing them as a module if issued interactively.

Transaction management
  BEGIN WORKBegins a transaction and optionally sets its isolation level and priority.
  COMMIT WORKEnds a transaction and makes permanent any changes it made to the DBEnvironment.
  ROLLBACK WORKEnds a transaction and undoes changes made to the DBEnvironment during the whole transaction or back to a savepoint within the transaction.
  SAVEPOINTDefines a point within a transaction back to which you can roll back work.
  SET DML ATOMICITYSets the general error checking level.
  SET CONSTRAINTSSets the level of constraint error checking.
  SET SESSIONSets transaction attributes for a session.
  SET TRANSACTIONSets execution attributes for a transaction.
 Executing proceduresEXECUTE PROCEDUREInvokes a procedure.
 OtherRAISE ERRORCauses a user-defined error to occur and specifies the error number and text to be raised.

Concurrency

  CREATE TABLEDefines the automatic locking strategy and implicit authority grants used for a table.
  LOCK TABLELocks a table, explicitly overriding ALLBASE/SQL's automatic locking strategy.
  START DBEDefines the maximum number of transactions that can execute concurrently, when used with the TRANSACTION= parameter.

Module maintenance

  DROP MODULEDeletes a module from the system catalog, optionally retaining authorization information.
  GENPLANPlaces optimizer's access plan in SYSTEM.PLAN (from ISQL only).
  SETOPTModifies access optimization plan used by queries.
  VALIDATEValidates modules and procedures.

Application Programming Statements

Single row data manipulations

  FETCHRetrieves a single row from an active set associated with a cursor.
  INSERTInserts a single row into a table.
  SELECTRetrieves a single row not associated with a cursor.

Bulk manipulations

  BULK FETCHRetrieves multiple rows from an active set associated with a cursor. (See .)
  BULK INSERTInserts multiple rows into a single table. (See INSERT.)
  BULK SELECTRetrieves multiple rows not associated with a cursor. (See SELECT.)

Cursor management
  ADVANCEAdvances a procedure cursor.
  CLOSECloses a cursor currently in the open state.
  DECLARE CURSORAssociates a cursor with a specific SELECT or EXECUTE PROCEDURE statement.
  DELETE WHERE CURRENTDeletes the current row of an active set.
  FETCHAdvances the position of an open cursor to the next row of the active set and copies columns into host variables.
  REFETCHCopies columns from the current cursor position in the active set into host variables. Used with the RU and RC isolation levels to verify the continued existence of data and to obtain stronger locks prior to updating.
  OPENMakes an active set available to manipulation statements.
  UPDATE WHERE CURRENTChanges columns in the current row of the active set.

Preprocessor directives
  BEGIN DECLARE SECTIONIndicates the beginning of the host variable declarations in an application program.
  END DECLARE SECTIONIndicates the end of the host variable declarations in an application program.
  INCLUDEIncludes declarations for structures used to pass information between ALLBASE/SQL and a program.
  WHENEVERSpecifies an action to be taken depending on the outcome of an SQL statement.

Dynamically preprocessed queries

  DESCRIBEObtains information about the results of a dynamic statement.
  EXECUTE EXECUTE IMMEDIATE PREPARERefer to general-purpose statements.
 Status messagesSQLEXPLAINRetrieves a message describing the status of SQL statement execution.

Database Administration Statements

Authorization

  GRANTGrants authorities to all users, specific users, or groups.
  REVOKERevokes authorities from all users, specific users, or groups.
  TRANSFER OWNERSHIPMakes a different user or authorization group the owner of a table, view, authorization group, or procedure.

Authorization groups
  ADD TO GROUPAdds one or more users or groups to an authorization group.
  CREATE GROUPDefines an authorization group.
  DROP GROUPRemoves the definition of an authorization group from the system catalog.
  REMOVE FROM GROUPRemoves one or more users or groups from an authorization group.

DBEnvironment configuration and use

  START DBE NEWConfigures a new DBEnvironment.
  START DBEMakes a DBEnvironment available in a mode different from that defined in the DBECon file; also starts up a DBEnvironment when the autostart flag is off.

STOP DBE

  Terminates all DBE sessions and causes a checkpoint to be taken, recovering log file space if nonarchive logging is in effect. 
  TERMINATE QUERYTerminates a running Query.
  TERMINATE TRANSACTIONStops the transaction.
  TERMINATE USERStops the DBE session for a specific user.

DBEnvironment settings

  ENABLE RULESTurns rule checking on for the current DBEnvironment session.
  DISABLE RULESTurns rule checking off for the current DBEnvironment session.
  SET PRINTRULESSpecifies whether rule names and statement types are to be issued as messages when the rules are fired during a DBEnvironment session.
  SET USER TIMEOUTSpecifies the amount of time the user waits if requested database resource is unavailable.
 Space Management
 DBEFilesADD DBEFILEAssociates a DBEFile with a DBEFileSet.
  ALTER DBEFILEChanges the type attribute of a DBEFile.
  CREATE DBEFILEDefines and creates a DBEFile.
  DROP DBEFILERemoves the definition of an empty DBEFile not associated with a DBEFileSet.
  REMOVE DBEFILEDisassociates a DBEFile from a DBEFileSet.
 DBEFileSetsCREATE DBEFILESETDefines a DBEFileSet.
 SET DEFAULT DBEFILESETSets a default DBEFileSet.
  DROP DBEFILESETRemoves the definition of a DBEFileSet from the system catalog.

Temporary sort space

  CREATE TEMPSPACEDefines and creates a temporary storage space.
  DROP TEMPSPACERemoves the definition of a temporary storage space from the system catalog.
 Logging
 Recovery of log spaceBEGIN ARCHIVE COMMIT ARCHIVEStarts a new archive log file before a DBEnvironment is back up.
  CHECKPOINTCauses an ALLBASE/SQL system checkpoint to be taken. A system checkpoint causes data and log buffers to be written to disk and makes old log space, occupied by completed transactions, available for reuse if nonarchive logging is in effect. Returns values in host variable.
  START DBE NEWLOGReinitializes log file(s) when you need to change the size. Makes audit logging effective when used with AUDIT LOG option.
  START DBEInitiates the first DBE session if the DBE is not in autostart mode and causes a checkpoint to be taken, recovering log file space if nonarchive logging is in effect.
  STOP DBETerminates all DBE sessions and causes a checkpoint to be taken, recovering log file space if nonarchive logging is in effect.
 Dual loggingSTART DBE NEWCauses ALLBASE/SQL to maintain two separate, identical logs, when used with the DUAL LOG option. Makes audit logging effective when used with AUDIT LOG option.
 Audit loggingDISABLE AUDIT LOGGINGDisables current audit logging for a session.
 Log commentLOG COMMENTEnters a user comment in the log file.
  ENABLE AUDIT LOGGINGEnables audit logging for a session after being disabled.

Recovery Rollback

  START DBERolls back transactions that were incomplete the last time the DBEnvironment was shut down.
  TERMINATE USEREnds a user's transactions, backing out any work not committed.
  STOP DBETerminates all DBE sessions and causes a checkpoint to be taken,
 RollforwardBEGIN ARCHIVE COMMIT ARCHIVECreates an archive record in the rollforward log(s) and initiates archive mode logging.

DBEnvironment statistics

  RESETResets ALLBASE/SQL accounting and statistical data activity management.
  UPDATE STATISTICSUpdates system catalog information used to optimize data access operations on a per table basis.

Procedure Statements

General statements

  Assignment (=)Assigns a value to a local variable or parameter in a procedure.
  DECLARE VariableDefines a local variable within a procedure.
  PRINTStores information to be displayed by ISQL or an application program.

Control flow statements

  BEGINBegins a single statement or group of statements within a procedure.
  GOTOPermits a jump to a labeled statement within a procedure.
  LabelLabels a statement in a procedure.
  IFAllows conditional execution of one or more statements within a procedure.
  RETURNPermits an exit from a procedure with an optional return code.
  WHILEAllows looping within a procedure.

 

Feedback to webmaster