HPlogo ALLBASE/SQL Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 10 SQL Statements

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 statementsDBEnvironment session managementCONNECTBegins 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 MULTITRANSACTIONSwitches 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,

  • DBEFileSets,

  • DBEFiles

Refer to the database administration statements. 
 ProceduresCREATE PROCEDUREDefines a procedure for storage in the DBEnvironment.
  DROP PROCEDURE Deletes a procedure.
 PartitionsCREATE PARTITIONDefines a partition for audit logging in the DBEnvironment.
  DROP PARTITION Deletes a partition.
 Data manipulationDELETEDeletes 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 managementBEGIN 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.
 ConcurrencyCREATE 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 maintenanceDROP MODULEDeletes a module from the system catalog, optionally retaining authorization information.
   GENPLAN Places optimizer's access plan in SYSTEM.PLAN (from ISQL only).
  SETOPTModifies access optimization plan used by queries.
   VALIDATEValidates modules and procedures.
Application programming statementsSingle row data manipulationsFETCHRetrieves 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 manipulationsBULK FETCHRetrieves multiple rows from an active set associated with a cursor. (See FETCH.)
  BULK INSERTInserts multiple rows into a single table. (See INSERT.)
  BULK SELECTRetrieves multiple rows not associated with a cursor. (See SELECT.)
 Cursor managementADVANCE Advances 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 directivesBEGIN 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 queriesDESCRIBEObtains 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 statementsAuthorizationGRANTGrants 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 groupsADD 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 useSTART 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 DBETerminates 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 settingsENABLE 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, optionally specifying a group name and volume.
  DROP DBEFILERemoves the definition of an empty DBEFile not associated with a DBEFileSet.
  REMOVE DBEFILEDisassociates a DBEFile from a DBEFileSet.
 DBEFileSetsCREATE DBEFILESETDefines a DBEFileSet.
 DBEFileSetsSET DEFAULT DBEFILESETSets a default DBEFileSet.
  DROP DBEFILESETRemoves the definition of a DBEFileSet from the system catalog.
 Temporary sort spaceCREATE TEMPSPACEDefines and creates a temporary storage space.
  DROP TEMPSPACERemoves the definition of a temporary storage space from the system catalog.
 Logging  
 
  • Recovery of log

  • space

BEGIN 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 RollbackSTART 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 ARCHIVECOMMIT ARCHIVECreates an archive record in the rollforward log(s) and initiates archive mode logging.
 DBEnvironment statisticsRESETResets 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 statementsGeneral statementsAssignment (=)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 statementsBEGINBegins 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