Introduction to NonStop SQL/MP

2 How to Use NonStop SQL/MP
113425 Tandem Computers Incorporated 2–1
This section describes the basic tools for querying a NonStop SQL/MP database. It
shows how the relational model makes it easy to retrieve data by letting you use joins
and views. Finally, it discusses how to modify data and maintain data integrity and
consistency by using NonStop SQL/MP locking mechanisms and transaction
management statements.
Querying the Database The NonStop SQL/MP relational structure is simple and flexible. Data appears in the
familiar form of tables with rows and columns. To retrieve data, you can select
columns and rows from one or more tables.
The SQL language includes simple statements, called Data Manipulation Language
(DML) statements, that you use for querying the database. In NonStop SQL/MP, a
query can modify data as well as retrieve it.
Sources of Queries There are several ways to send a query to the NonStop SQL/MP subsystem. Many
PC-based or workstation-based query tools can easily build and export SQL queries to
a back-end server using popular interfaces such as ODBC or SQL Server. A business
professional can build a query simply by clicking icons and menu items in this type of
packaged client application. The application will automatically translate the request
into an SQL query and send it to the necessary interface such as the NonStop ODBC
Server, which delivers the query to NonStop SQL/MP. Thus, this user can access the
database without knowing anything about the SQL language.
A database administrator (DBA) or programmer can submit a query directly to
NonStop SQL/MP by using the SQL Conversational Interface (SQLCI).
These two types of queries are likely to use dynamic SQL. NonStop SQL/MP
compiles and executes a dynamic SQL statement as soon as it is submitted.
A programmer can also embed SQL statements in an application program written in a
high-level language such as C or COBOL. This method, called static SQL, allows
NonStop SQL/MP to store the compiled query with the compiled program object file.
The compiled query can be executed quickly, multiple times, with no overhead for
compilation. Static SQL is ideal for large business applications such as high-volume
OLTP.
The rest of this section describes how to write queries to retrieve and modify data. It
focuses on the logical functions of SQL statements, without regard to the method you
use to access NonStop SQL/MP or the format of the returned data. (Where and how
the returned data is displayed, printed, or manipulated depends on the application.)
Writing Queries You write a query by using a SELECT statement in which you specify columns and
rows in a particular table or tables. To do this, you need to know the logical structure
of the database—the way information is distributed in tables and the relationships
among the tables. Generally, a database administrator (DBA) creates and manages the
tables and other SQL objects, which are cataloged in the data dictionary. The DBA
furnishes the logical picture of the database.