3630
3630
INFORMIX-Universal
Server
Version 2.0
December 1996
Part No. 000-3630
Published by INFORMIX Press Informix Software, Inc.
4100 Bohannon Drive
Menlo Park, CA 94025
Copyright 1981-1996 by Informix Software, Inc.; provided, portions may be copyright in third parties, as set
forth in documentation. All rights reserved.
The following are worldwide trademarks of Informix Software, Inc., or its subsidiaries, registered in the
United States of America as indicated by “,” and in numerous other countries worldwide:
INFORMIX
The following are worldwide trademarks of the indicated owners or their subsidiaries, registered in theUnited
States of America as indicated by “,” and in numerous other countries worldwide:
To the extent that this software allows the user to store, display, and otherwise manipulate various forms of
data, including, without limitation, multimedia content such as photographs, movies, music and other binary
large objects (blobs), use of any single blob may potentially infringe upon numerous different third-party
intellectual and/or proprietary rights. It is the user's responsibility to avoid infringements of any such third-
party rights.
Software and documentation acquired with US Government funds are provided with rights as follows: (1) if
for civilian agency use, with Restricted Rights as defined in FAR 52.227-19; (2) if for Dept. of Defense use, with
rights as restricted by vendor's standard license, unless superseded by negotiated vendor license as prescribed
in DFAR 227.7202. Any whole or partial reproduction of software or documentation marked with this legend
must reproduce the legend.
Table of Contents
Introduction
About This Manual . . . . . . . . . . . . . . . . . . 3
Organization of This Manual . . . . . . . . . . . . . 4
Documentation Conventions . . . . . . . . . . . . . . 4
Typographical Conventions . . . . . . . . . . . . . 5
Icon Conventions . . . . . . . . . . . . . . . . . 6
Command-Line Conventions . . . . . . . . . . . . . 6
Screen-Illustration Conventions . . . . . . . . . . . . 9
Additional Documentation . . . . . . . . . . . . . . . 9
Printed Documentation . . . . . . . . . . . . . . . 10
On-Line Documentation . . . . . . . . . . . . . . 10
Informix Welcomes Your Comments . . . . . . . . . . . . 12
Index
Introduction
Documentation Conventions . . . . . . . . . . . . . . . 4
Typographical Conventions . . . . . . . . . . . . . . 5
Icon Conventions . . . . . . . . . . . . . . . . . . 6
Command-Line Conventions . . . . . . . . . . . . . . 6
Screen-Illustration Conventions . . . . . . . . . . . . . 9
Additional Documentation . . . . . . . . . . . . . . . . 9
Printed Documentation . . . . . . . . . . . . . . . . 10
On-Line Documentation. . . . . . . . . . . . . . . . 10
On-Line Manuals . . . . . . . . . . . . . . . . . 11
On-Line Help . . . . . . . . . . . . . . . . . . 11
Release Notes, Documentation Notes, Machine Notes . . . . 11
Informix Welcomes Your Comments . . . . . . . . . . . . . 12
2 Using the SQL Editor
W elcome to the SQL Editor, the graphical product that enables you
to execute SQL statements within your windowing environment. The SQL
Editor provides an interface that makes it easy to create, edit, and save SQL
documents; check and execute SQL statements; and optimize query
performance.
Introduction 3
Organization of This Manual
Documentation Conventions
This section describes the conventions that this manual uses. These conven-
tions make it easier to gather information from this and other volumes in the
documentation set.
■ Typographical conventions
■ Icon conventions
■ Command-line conventions
■ Screen-illustration conventions
Typographical Conventions
This manual uses the following standard set of conventions to introduce new
terms, illustrate screen displays, describe command syntax, and so forth.
Convention Meaning
italics Within text, new terms and emphasized words appear in italics.
Within syntax diagrams, values that you are to specify appear in
italics.
monospace Information that the product displays and information that you
enter appear in a monospace typeface.
Introduction 5
Icon Conventions
Icon Conventions
Throughout the documentation, you will find text that is identified by several
different types of icons.
Command-Line Conventions
The Using the SQL Editor manual describes how to launch the SQL Editor
using command-line options. This manual also describes the dbschema
utility.
Element Description
' ' Single quotation marks are literal symbols that you must
enter as shown.
Privileges
A reference in a box represents a subdiagram on the
p. 5-17 same page (if no page is supplied) or another page.
Imagine that the subdiagram is spliced into the main
Privileges diagram at this point.
(1 of 2)
Introduction 7
Command-Line Conventions
Element Description
mkmsg in-file
-v -Ddefines out-file
To construct the command correctly, start at the top left with the command
mkmsg. Then follow the diagram to the right, including the elements that
you want. The elements in the diagram are case sensitive.
Screen-Illustration Conventions
The illustrations in this manual represent a generic rendition of various
windowing environments. The windowing environment details of dialog
boxes, controls, and windows have been deleted or redesigned to provide
this generic look. Therefore, the illustrations in this manual depict the SQL
Editor a little differently than the way it might appear on your screen.
Additional Documentation
The Using the SQL Editor manual is included with other printed manuals, on-
line manuals, and on-line help.
■ Printed documentation
■ On-line documentation
■ Vendor-specific documentation
■ Related reading
Introduction 9
Printed Documentation
Printed Documentation
The following manuals are shipped with the INFORMIX-Universal Server
documentation set. These Informix manuals complement the information in
Using the SQL Editor:
Informix Error Messages might also be useful if you do not want to look up
your error SQL messages on-line.
On-Line Documentation
Several different types of on-line documentation are available:
■ On-line manuals
■ On-line help
■ On-line error messages
■ Release notes, documentation notes, and machine notes
On-Line Manuals
The Using the SQL Editor manual is provided on a CD so that you can view
and search for information on-line. For searches, you can specify a word or
phrase and specify which manuals you want to search. You can also place
electronic annotations and bookmarks on pages that are of particular interest
to you. Pages you view and print from the on-line manuals have the same
layout and design as the printed manuals.
On-Line Help
The SQL Editor on-line help facility provides a detailed, context-sensitive
explanation of program functions. Use the help file to access information
about each menu item. To invoke the on-line help, press F1.
Documentation Describes features that are not covered in the manuals or that
notes have been modified since publication. These notes are named
for the manual that is described.
Machine notes Describes any special actions that are required to configure and
use Informix products on your computer. Machine notes are
named for the product that is described.
Introduction 11
Informix Welcomes Your Comments
Send your comments to us, along with the manual title and version number,
using one of the following methods. Make sure you include your name,
address, and telephone number (or email address) with your comments.
Informix Server:
HostName:
Use these controls to identify a database server;
Protocolname:
the host machine on which the database server
Service Name: resides; and the network protocol and service
used by the database server.
Make Default Server
Delete Server
3. In the Informix Server list box, type a database server name or select
one from the list.
4. In the HostName list box, type the name of the host on which the
database server resides or select one from the list.
5. Select the protocol that you want to use for network communication
from the Protocolname list box.
If a protocol is listed by default, it is the protocol that was selected for
the database server when the database server was installed on the
host machine. For more information about protocols, refer to the
Administrator’s Guide for your database server.
6. In the Service Name text box, type the service name that the
database server uses to listen to incoming requests.
If a service is provided by default, it is the service that was selected
when the database server was installed on the host machine. For
more information about services, refer to the Installation Guide for
your database server.
7. Click Apply to update the settings for the database server.
Repeat steps 2 through 7 for each database server that you need to
define.
8. Specify connection information for each host machine.
2. In the Current Host list box, type a host machine name or select one
from the list.
3. In the User Name text box, type the user name that you use to
connect to the host machine specified in step 2.
4. In the Password Option list box, choose a password-handling mode.
If you select the Password option, type the host machine password
in the Password text box.
The following table describes the password-handling options.
Option Action
Ask password at Each time the user (specified in the User Name text box)
run time attempts to connect to a database server on the host
machine, the user is prompted to enter a password.
Password Each time the user (specified in the User Name text box)
attempts to connect to a database server on the host
machine, the password entered in the Password text box is
checked against the password on the host machine. If the
passwords do not match, the user is not connected and an
error message is displayed.
5. Click Apply.
Repeat steps 2 through 5 for every host machine to which you cannot
connect, regardless of whether the same user name and password is
used to connect to every host machine.
6. Click OK to save the changes and exit the Setnet32 utility.
The information is saved for future connections to each specified
host machine.
Important: The settings you specify in the Setnet32 utility will not take effect until
you re-launch the SQL Editor.
Tip: If you want to view more than one document simultaneously, launch another
instance of the SQL Editor.
Windows NT To launch the SQL Editor using Windows NT, version 3.51
Additionally, you can prevent the display of the splash box that is shown
when the SQL Editor is launched, minimize the SQL Editor window, and close
the SQL Editor after completing all other command-line options.
Figure 1-4
sqleditor
SQL Editor
/ns /min Server SQL File /output outfile /exit Command
and Line
Database
Syntax
Server
and
Database
/s server
/d dbname /u user
/pw password
SQL File
filename
/exec
/ns Prevents the display of the SQL Editor splash box that
is shown when the SQL Editor is launched.
When you execute the sqleditor command with the /s, /u, or /pw options,
database server access permissions are validated. If your user name or
password are not known, the User Login dialog box is displayed. Enter your
user name and password for the selected database server in the appropriate
text boxes.
When you check the Save for Future Sessions check box in the User Login
dialog box, the user name and password you specified are validated and then
saved for future connections to that database server. If the user name or
password cannot be validated, that information is not saved and a connection
error is displayed.
For more infor- If you cannot connect to a database server, it is recommended that you use
mation about the Setnet32 utility to verify or specify the appropriate database server
the Setnet32 settings.
utility, refer to
“Defining a Con- Example
nection to a Data-
base Server.” sqleditor /s mars /d mydb /u alex /pw mypasswd trigger3.sql
/exec /output mydata.txt /exit
The sqleditor command connects to the mars database server, opens the
stores9 database, and executes the trigger3.sql file in the SQL Editor. Then,
the returned data and summary information about executed SQL statements
is sent to the mydata.txt file and the SQL Editor is exited.
Obtaining Help
The SQL Editor provides two types of help information: Help Topics and
What’s This? help. Help Topics include task help and reference help. Task
help provides information about a specific task. Reference help explains
concepts or provides general information about a feature. What’s This? help
provides context-sensitive help for elements on the screen.
When you highlight a menu item, the status bar defines the action that the
menu item performs. When you position the pointer over a toolbar button,
the name of the button is displayed in a tooltip.
Once you launch the SQL Editor, the SQL Editor window appears, as shown
in Figure 2-1. An SQL document is displayed within the window. The
following sections describe the different elements of the SQL Editor window.
Tip: If you want to view more than one document simultaneously, launch another
instance of the SQL Editor.
Figure 2-1
SQL Editor - Untitled.sql
File Edit SQL View Help
A menu bar and toolbar
provide access to all
tasks performed in this
SQL editor.
Server/Database: mars_us Server/Database
list box
SQL Statements
text box
SQL Result
History text box
■ File menu commands allow you to create, open, and save text files
and data. You can view and open the last four files that were opened
using the SQL Editor. You can also exit the SQL Editor from the File
menu.
■ Edit menu commands enable you to select text; locate and replace
text; and cut, copy, and paste text in the SQL Statements text box of
the SQL page. These commands also allow you to copy and select
text in the output pages of the Returned Rows grid. You can also
reverse the last editing operation that you performed.
■ SQL menu commands allow you to check selected SQL statements or
check all SQL statements for errors, execute selected SQL statements
or execute all SQL statements, produce a file that provides infor-
mation about how a query is performed, and interrupt execution of
SQL statements that return data.
■ View menu commands enable you to show or hide the toolbar, status
bar, and the SQL Result History text box. You can also toggle the
display of the Cell Viewer window.
■ Help menu commands enable you to access on-line help for the SQL
Editor.
Click the Open toolbar button to display an existing text file in the
SQL document window.
Click the Save toolbar button to save the contents of the SQL
Statements text box.
Click the Cut toolbar button to remove the selected text and place
it on the clipboard.
Click the Copy toolbar button to copy the selected text to the
clipboard.
(1 of 2)
Click the Find Again toolbar button to search for the next occur-
rence of the last located text in the SQL Statements text box.
Click the Check All Syntax toolbar button to check the SQL state-
ments in the SQL Statements text box.
Click the Execute Selected Syntax toolbar button to run only the
selected statements in the SQL Statements text box.
Click the Execute All SQL toolbar button to submit the SQL state-
ments in the SQL Statements text box to the specified database
server.
Click the What’s This? toolbar button to access contextual help for
a screen element that you select in the SQL Editor.
(2 of 2)
You can move the toolbar to another area on your desktop by positioning the
mouse on the toolbar and dragging it to the desired position.
To create a document
1. Choose File➞Open and use the resulting Open dialog box to display
a text file in the SQL Statements text box of the SQL page.
You can open any text file in the SQL Editor. However, if the file
contains unexecutable text that is not enclosed in braces or preceded
by two hyphens, syntax errors will occur when you attempt to
execute the contents of the SQL Statements text box.
2. Make the necessary changes to the statements.
To locate text
Type the text that you Type the text that replaces
want to locate. the located text.
2. In the Find what text box, type the text that you want to locate.
3. Check the Match whole word only check box to search for the
specified text as an entire word.
Unselect this check box to search for any character string that
contains the text that you specified in the Find What text box.
4. Check the Match case check box to limit the search to the exact case
entered in the Find what text box.
5. Click Find Next.
6. To locate subsequent occurrences of the text that you typed in the
Find what text box, click the Find Again toolbar button.
Find Again
button
....... mars_us
......
..................................
database1
....... database2
....... database3
....... database4
....... database5
....... database6
When you select or expand a database server, database server access permis-
sions are validated. If your user name or password are not known, the User
Login dialog box is displayed. Enter your user name and password for the
selected database server in the appropriate text boxes.
When you check the Save for Future Sessions check box in the User Login
dialog box, the user name and password you specified are validated and then
saved for future connections to that database server. If the user name or
password cannot be validated, that information is not saved and a connection
error is displayed.
For more infor- If you cannot connect to a database server, use the Setnet32 utility to verify
mation about or specify the appropriate database server settings.
the Setnet32
utility, refer to To disconnect from the database server or database, use the DISCONNECT
Chapter 1, “Intro- CURRENT statement. You can also click on the Server/Database list box and
ducing the SQL select another database or database server, or the Network icon.
Editor.”
Stopping Execution
You can use the SQL Editor to cancel a SELECT or EXECUTE routine that is
currently retrieving rows. To cancel, click the Stop Execution toolbar button.
Stop Execution
button
Query
SELECT lname, fname, zipcode
FROM customer The Query text box displays the SQL
statement that produced the output in
the Returned Rows grid.
lname fname zipcode
1 Pauli Ludwig 94086
2 Sadler Carole 94117 The Returned Rows grid displays the
data returned by the SQL statement
3 Currie Phillip 94303
shown in the Query text box.
4 Higgins Anthony 94026
5 Vector Raymond 94022
Output pages are Output pages are created each time that data is returned from executed SQL
not created when statements. For example, if the SQL Statements text box contains three
you check SELECT statements that return data, Output1, Output2, and Output3 pages
statements. are created. If you delete one of the SELECT statements from the SQL State-
ments text box and execute the statements again, the original three output
pages are deleted and two new output pages are created.
When you open another document, all existing output pages are deleted.
New output pages are created when you execute the next set of SQL state-
ments that return data.
Use the row headings to select all data in each grid row.
Once data is returned and displayed in the Returned Rows grid, you can
select the data, copy it, and paste the data into a text editor or spreadsheet.
You can also resize and hide columns in the Returned Rows grid. Resizing
and hiding columns allows you to customize your view of the returned data.
For additional To resize columns
information about
column headings, 1. Position the mouse on the right edge of the column heading for the
refer to column that you want to resize.
Figure 2-5.
2. Drag to the desired width.
The column width shifts to the left or right to adjust to the resized
column.
To hide columns
1. Position the mouse on the right edge of the column heading for the
column that you want to hide.
2. Drag to the left until the column disappears.
When data defined from a row type is returned, the grid might display
primary headings and secondary headings. Primary headings appear at the top
level when one or more secondary headings are displayed. For example, a
primary heading for address might contain secondary headings for street, city,
state/province, and postal code. Figure 2-6 shows an example of a Returned
Rows grid when row type data is displayed.
Figure 2-6
fname lname birth_date sex address
Primary headings
street city state_prov postal
Secondary headings
1 Pauli Ludwig 11-30-66 F 213 Erstwild Court San Francisco CA 94086
2 Carole Sadler 12-21-65 F 785 Geary St San Francisco CA 94117
3 Philip Currie 09-8-65 M 654 Poplar Palo Alto CA 94303 Row type data
You can select the rows and columns of data using the mouse. Click primary
headings, secondary headings, or row headings to select data. Generally,
clicking a heading selects any heading or data below the heading that you
clicked. Clicking a row heading selects the entire row. The following list
provides example data selections.
■ In Figure 2-6, click the address primary heading to select the street,
city, state_prov, and postal columns. The associated data is also
selected.
■ In Figure 2-6, click the street secondary heading to select the data in
the street column.
■ In Figure 2-6, click row heading 5 to select the entire row for George
Watson.
Generally, if you click and drag across headings, the area across those
respective headings is selected. Refer to Figure 2-7 and Figure 2-8 for
additional information about using click and drag.
As shown in Figure 2-7, if you click birth_date, and drag to San Francisco, the
birth_date, sex, and address primary headings are selected, as well as the street,
city, state_prov, and postal secondary headings. The data in the associated
columns is also selected.
As shown in Figure 2-8, if you click the empty cell below birth_date and drag
to city, the birth_date, sex, street, and city columns are selected.
Figure 2-8
fname lname birth_date sex address
Clicking and
street city state_prov postal Dragging Between
1 Pauli Ludwig 11-30-66 F 213 Erstwild Court San Francisco CA 94086 Secondary
Headings
2 Carole Sadler 12-21-65 F 785 Geary St San Francisco CA 94117
When data defined from a collection type is returned, the cells in the
Returned Rows grid display the name of the collection type, the number of
entries that it contains, and the data type for which the collection type is
based.
Figure 2-9
fname lname birth_date sex addresses
Double-click this cell
1 Jane Miller 11-30-66 F list(2) of street_addr
to view the collection
2 Carole Sadler 12-21-65 F list(4) of street_addr type data in the Cell
3 Phillip Currie 01-01-52 F list(5) of street_addr Viewer.
4 Fred Jewell 04-28-63 F list(3) of street_addr
Figure 2-10 shows an example of the Cell Viewer window with the collection
type data displayed.
For additional You can select data and resize the columns in the Cell Contents grid in the
information about same manner as in the Returned Rows grid. The Cell Viewer window
how to select data contains five toolbar buttons. Click a toolbar button to perform the tasks
and resize rows described in the following table.
and columns,
refer to
“Returning Toolbar Button Description
Complex Type
Data.” Click the Save As Data toolbar button to save the contents of the
Cell Contents grid or the textual data to a file.
Click the Copy toolbar button to copy the selected contents of the
Cell Contents grid or the textual data to the clipboard.
Click the Zoom Out toolbar button to move to the previous grid
in the history list.
Click the What’s This? toolbar button to access contextual help for
a screen element that you select in the Cell Viewer window.
If a cell is displaying the name of a collection type, the number of entries that
it contains, and the data type for which the collection type is based, you can
zoom in on the cell to view the cell contents.
Click the Zoom To zoom in on a cell
Out toolbar
button to move to 1. Locate the cell that references the collection type data.
the previous grid 2. Double-click the cell.
in the history list.
The Cell Contents grid is refreshed and the data is displayed.
If you choose to save the current document, the contents of the current
document are saved, the SQL Statements text box is cleared, and all output
pages are deleted. Then, the next document is displayed in the SQL State-
ments text box. If you choose not to save the current document, its contents
are overwritten with the contents of the next document and all output pages
are deleted.
1. Click the Output tab that contains the data that you want to save.
2. Choose File➞Save As Data to display the Save dialog box.
3. Enter a directory path and a filename.
Use a .txt file extension in the filename to indicate that the file
contains unexecutable text.
4. Click Save.
1. Click the Output tab that contains the data that you want to save.
2. To select a row of data in the Returned Rows grid, click the row
heading cell of the grid row that you want to save.
To select multiple grid rows, press SHIFT while clicking the grid row
headings.
3. Choose Edit➞Copy to copy the selected text to the clipboard.
4. Open a text editor or spreadsheet and paste the text into that
application.
Windows 95 If a file is saved using an extension other than the default, the applicable
extension (.txt for output pages or .sql for SQL pages) is appended to the
Windows NT supplied extension. To modify the extension, enclose the entire filename in
4.0 quotation marks. ♦
Data definition Defines the data in the database. This type of statement
alters, creates, drops, or renames database objects.
(1 of 2)
Data manipulation Manipulates the data in the database. This type of statement
deletes, inserts, selects, or updates database data.
If you cannot connect to the database server using this statement, verify the
settings in your connectivity product. For more information about your
connectivity product, refer to the section “Defining a Connection to a
Database Server” in Chapter 1, “Introducing the SQL Editor.”
Use the DATABASE statement to select any database on your database server.
To close the current database, execute CLOSE DATABASE.
Use the SET SESSION AUTHORIZATION statement to change the user name for
the current session. When you execute this statement, the new user assumes
the privileges of the previously specified user.
Database Privileges
There are three types of database privileges that control who can access a
database: Connect, Resource, and Database Administrator (DBA).
The highest database privilege is DBA privilege. A user who is granted this
privilege can perform the following functions:
Table Privileges
Table privileges apply to views, synonyms, and tables. The owner of a table
can grant or revoke the following privileges independently.
Index To create and alter indexes on a table. The user must also
have Resource privileges at the database level.
You can further restrict access to tables by specifying column names in the
GRANT statement. These privileges permit a user to view and update
columns and create constraints on the columns.
Partition Privileges
You can grant Insert, Update, and Delete privileges on individual partitions
of a partitioned table, using the GRANT FRAGMENT statement. The privileges
you grant can apply to one or more users. This statement is only available for
tables that are partitioned based on an expression.
Type Privileges
When a user-defined data type is created, only the owner and users with DBA
privileges can reference the user-defined data type. You can provide further
access to the user-defined data type using the Usage privilege. This privilege
enables a user or role to reference your user-defined data type.
Routine Privileges
You grant Execute privileges on a routine to permit a user to execute that
routine. If you create a routine using the DBA option in the CREATE
PROCEDURE or CREATE FUNCTION statement, it is known as a DBA-privi-
leged routine. If you create a routine without the DBA option, it is known as
an owner-privileged routine.
A DBA-privileged routine can be created by any user who has DBA privileges.
The database server implicitly grants Execute privileges to all users who
have DBA privileges. Use the GRANT statement to explicitly permit a specific
user to execute the routine.
Use the CREATE ROLE statement to specify the role name. The role name acts
as an alias for a group of users. Then use the GRANT statement to:
Each user in a role can exercise the privileges assigned to that role by
executing the SET ROLE statement. The role that the user specifies in the SET
ROLE statement is the one that is enabled. Only one role can be enabled at a
time. If a user executes a SET ROLE statement after a role is already enabled,
the new role replaces the existing role.
Locking Data
You can control the locks the server places on data. When data is locked, data
corruption cannot occur if multiple users simultaneously access the same
data. The following table lists the statements that control data locking.
Statement Description
SET TRANSACTION Defines the isolation levels and the access mode of the
transaction. The isolation levels can be read uncommitted,
read committed, repeatable read, and serializable. The
access modes can be either read-only or read-write.
Use a combination of these statements to set the level of locking required for
your data.
Creating Databases
For additional Before you execute the CREATE DATABASE statement, make sure that you
information select the correct database server in the Server/Database list box. When you
about the enter the CREATE DATABASE statement, you create a database on the current
Server/Database database server.
list box, refer
to the section The database you create becomes the current database. Once you create a
“Using the
database, you can define database objects, such as tables, indexes, synonyms,
Server/Database
List Box” in triggers, views, casts, and domains.
Chapter 2, “Using
Note that the new database is inaccessible to others until you grant database
SQL Documents.”
privileges. For information about granting privileges, refer to the section
“Database Privileges.”
Statement Description
CREATE TABLE Creates the tables in a database. This statement defines the
columns of a table and places data integrity constraints on
the columns in a table.
You must have Resource privileges for a database before
you can create a table. For more information about privi-
leges, refer to the section “Assigning Privileges to Users.”
Statement Description
CREATE DISTINCT TYPE Creates a new data type based on a built-in type, an
existing OPAQUE type, or a complex type.
Data of the new DISTINCT type is stored on disk in the
same way as data of the source type.
The data cannot be compared to data of the source type
unless you explicitly cast from one type to another.
CREATE OPAQUE TYPE Creates a user-defined data type that can be used in the
same way as built-in data types.
Use the DROP statement to remove the user-defined type, DISTINCT type, or
OPAQUE type. Do not remove built-in or predefined types.
Defining Domains
Use the CREATE DOMAIN statement to define a new domain in the current
database. A domain is a data type alias. Domains enable you to easily share
a data type among many columns.
To change a domain definition, you must drop the existing domain and re-
create the domain with the CREATE DOMAIN statement.
To remove a domain from the database, use the DROP DOMAIN statement.
When you drop a domain, the database server replaces every reference of the
domain in any column definition. Note that you must own the domain or
have DBA privileges to drop the domain.
Modifying Databases
You can modify existing tables, indexes, and partitions using the ALTER
keyword. For example, use ALTER FRAGMENT to dynamically alter or create
an existing table or index partition.
Use the RENAME keyword to rename existing columns, tables, and local
databases. You can remove any existing database, table, index, view, or
synonym using the DROP keyword.
Creating Schemas
Use the CREATE SCHEMA statement to issue a block of CREATE and GRANT
statements as a group. This statement enables you to specify the owner of all
the objects created in the block of statements.
Another type of data integrity checking actually locks data to restrict access.
For more information about this type of data integrity, refer to the section
“Locking Data.”
Using Transactions
A transaction is a sequence of statements that is guaranteed to either be
completely and perfectly performed or not performed at all. If there is any
reason why the sequence of statements cannot be performed completely and
perfectly, the database is restored to the state it was in before the transaction
began. Thus, transactions protect you against possible failures by preventing
a partial acceptance of the sequence of statements.
Statement Action
SET LOG This statement changes the logging method for transactions.
The logging method determines how each change is made
within a transaction. Without transaction logging, you
cannot roll back transactions.
You can execute the STOP VIOLATIONS TABLE statement to cancel the
recording of the violation and diagnostic table information. Although the
violations and diagnostics tables remain intact, they will no longer receive
information from the associated table.
Modifying Data
When data in a database is modified, the contents of the tables in the database
are changed. Use the DELETE, INSERT, and UPDATE statements to modify the
data in tables. The following table describes the statements that modify data.
Statement Description
Retrieving Data
Use the SELECT statement to retrieve data from the current database. You can
retrieve all data in the database or a subset of the data that meets a specific
criteria. This statement enables you to set the conditions that the selected
rows must meet and specify a sort order. You can also combine groups of
rows into summary rows and set conditions on the summary rows.
You can also execute all the SQL statements by clicking the Execute All SQL
toolbar button or choosing SQL➞Execute All SQL. For more information
about the data returned in the output pages, refer to “Viewing Returned
Database Data” in Chapter 2.
The SET EXPLAIN output file contains the following query performance
information:
For detailed information about the SET EXPLAIN statement and the output
file, refer to the Informix Guide to SQL: Syntax.
You can set the optimization level to HIGH, which uses a sophisticated, cost-
based strategy that examines all reasonable choices and selects the best
overall alternative. However, this evaluation process can be time-consuming.
You invoke a less sophisticated, but faster, optimization algorithm when you
set the optimization level to LOW.
Routine Statements
A routine is a named block of statements that can optionally accept
arguments. You can use a routine to improve performance when executing
frequently repeated tasks. Executing a routine, rather than repeatedly
executing the same set of SQL statements, saves time and resources by
bypassing redundant parsing, validity checking, and query optimization.
Routine Statements
ALTER FUNCTION DROP ACCESS_METHOD
AL TER PROCEDURE DROP AGGREGATE
ALTER ROUTINE DROP FUNCTION
ALTER ACCESS_METHOD DROP PROCEDURE
CREATE ACCESS_METHOD DROP OPCLASS
CREATE AGGREGATE DROP ROUTINE
CREATE FUNCTION EXECUTE FUNCTION
CREATE PROCEDURE EXECUTE PROCEDURE
CREATE OPCLASS SET DEBUG
There are two types of routines. Routines that can accept arguments, but do
not return information are called procedures. Routines that can accept
arguments and return values are called functions.
You can write routines using the Stored Procedure Language (SPL) or an
external programming language (like C) that is supported by the database
server.
Creating Procedures
Procedures can be categorized into two types. Stored procedures are written
using the Stored Procedure Language (SPL). External procedures are written in
an external programming language (like C) that is supported by the database
server.
To change anything about the definition of a stored procedure, use the DROP
PROCEDURE statement to delete the stored procedure and then re-create it
using the CREATE PROCEDURE statement.
Creating Functions
Write a user-defined function when you want to create a routine that returns
one or more values and can be used in an expression.
There are two types of user-defined functions. Stored functions are written
using the Stored Procedure Language (SPL). These functions can return one
or more values. External functions are written in an external programming
language (like C) that is supported by the database server. These functions
can only return a single value.
To change anything about the definition of a stored function, use the DROP
FUNCTION statement to delete the stored function and then re-create it using
the CREATE FUNCTION statement.
The compiled code is used when the external routine is executed. Note that
the database server does not store the external code directly in the database,
as it does for stored routines. Instead, only the pathname to the compiled file
containing the routine is stored.
After the routine is defined, you can change the attributes of the routine but
not the definition of the routine. Use the ALTER statement to change the
attributes of a routine. The only way to simulate changing the definition of a
routine is to remove the routine using the appropriate DROP statement and
re-create the routine with the CREATE statement.
Since you cannot change a procedure or function, you must drop it using the
DROP statement and then re-create it using the CREATE statement.
You can also remove the routine by executing the DROP SPECIFIC
PROCEDURE or DROP SPECIFIC FUNCTION statement using its specific
identifier. A specific identifier for a routine is a unique name (unique within
the database) that identifies this particular routine.
The DROP statement removes the text and executable versions of a routine.
Using Aggregates
You can create an aggregate that performs calculations over sets of rows. The
aggregate is based on a built-in or complex data type. Use the CREATE
AGGREGATE statement to create the aggregate. This statement requires you
to specify the functions that set the initial conditions, combine the data you
want to aggregate, and optionally perform actions required after the data is
combined. Use DROP AGGREGATE to remove the aggregate.
Supporting Global
Languages A
For more infor- This appendix introduces you to Global Language Support
mation about the (GLS). The GLS feature allows the SQL Editor to easily handle
GLS feature, refer different languages, cultural conventions, and code sets for
to the Guide to Asian, European, and Latin American countries.
GLS Functionality.
Important: When a character length limit is stated in this manual, the
term character actually refers to the number of bytes. In some
languages, a character might require two or more bytes of storage.
Term Definition
Code set Code sets are encodings of character sets, that is, the
one-to-one relationship between the characters and the
bit patterns that the system uses to identify characters.
Character classification The classification of the characters of the code set that
the locale uses. For example, specifications for which
characters the locale classifies as spaces, blanks, control
characters, digits, uppercase letters, lowercase letters,
and punctuation.
End-user formats The format in which data appears within a client appli-
cation when it is in literal strings or character variables.
Informix products use U.S. English as the default locale; therefore, if you are
creating or accessing a database that uses U.S. English only, you do not have
to set GLS-related environment variables.
Character loss may also occur in data that is returned from the database
server. If the CLIENT_LOCALE cannot interpret a character, the character is
displayed as a symbol that represents character loss. The actual symbol that
is displayed is defined by the locale.
If character loss occurs, a warning is displayed in the SQL Result History text
box which is located in the SQL Editor window. To correct this problem,
change the characters used in the string to valid characters for the locale of
the database.
Error Messages
B
This appendix presents information about error messages that
are displayed by the database server and the SQL Editor. This
information is described in the following sections:
Element Definition
number Lists the SQL error message number. Supply this number
in the Informix Find Error utility.
The following error message is displayed if a syntax error occurs while in the
stores9 database.
[Informix] [Universal Server] [stores9] SQL Error (-201):A syntax error has
occurred.
For written information about errors returned by the database server, refer to
your Informix Error Messages manual.
The selected gateway is not supported by the SQL Editor at this time.
An unknown format or incorrect version was detected for the locale or conversion
file filename. Check the appropriate gls subdirectory to ensure that it contains the
correct files.
A locale or conversion file is not in the expected format. The file could be
corrupt or compiled incorrectly. Re-install SQL Editor to copy new versions of
these files.
Cannot prepare SQL statement because a connection to a database server has not
been established.
Specify the text you want to locate before you click Find. If this error occurs,
type the text you want to locate, and then click Find Next.
The invalid environment setting string was detected during processing. Ensure
that all Global Language Support (GLS)-related environment settings are valid.
The selected or specified database server is not supported by the SQL Editor
at this time. Before proceeding, select or specify a different database server.
Unable to locate the locale or conversion file filename. Check the file system to
ensure that the locale or conversion file resides in the appropriate gls
subdirectory.
The necessary locale or conversion GLS file needed to perform the character
conversion procedure could not be read from the file system. The file may
have been moved, renamed, corrupted, or otherwise altered. You may need
to reinstall SQL Editor to ensure that the appropriate files reside in the gls
directory.
Use the /s option to specify the database server for the database dbname.
Index
Index 3
Selecting the current database 3-7 START VIOLATIONS TABLE 3-19 Undoing last editing action 2-6
Server/Database list box, using 2-5 Stop execution 2-7, 2-13 UNLOCK TABLE 3-7, 3-12
SET 3-19 Stop Execution toolbar button 2-7 UPDATE 3-8, 3-20
SET DATASKIP 3-19 STOP VIOLATIONS TABLE 3-19 Update privilege 3-9
SET DEBUG 3-23 Syntax checking 2-7, 2-12 UPDATE STATISTICS 3-23
SET EXPLAIN 3-21 User-defined data types,
Set Explain feature 2-19, 3-21 creating 3-15
SET ISOLATION 3-7, 3-12 T Users
SET LOCK MODE 3-7, 3-12 assigning privileges to 3-7 to 3-11
Table synonyms
SET LOG 3-19 connecting to servers 1-5, 1-11,
creating 3-14
SET OPTIMIZATION 3-22 2-11
granting privileges for 3-9
SET PDQPRIORITY 3-22 defining roles for 3-11
Tables
SET ROLE 3-7, 3-11 permitting object access for 3-7
creating 3-14
SET SESSION
creating triggers for 3-14
AUTHORIZATION 3-8
granting privileges for 3-9
SET TRANSACTION 3-7, 3-12
synonyms for 3-14
V
Setnet32 utility, using 1-3 to 1-8
Text View menu 2-6
Showing
editing in SQL Editor 2-6, 2-9 View synonyms
status bar 2-6
locating in SQL Editor 2-7 creating 3-14
toolbar 2-6
replacing in SQL Editor 2-7 granting privileges for 3-9
Splash box, hiding the 1-10
Text files, opening in SQL Viewing returned data 2-13 to 2-19
SQL
Editor 2-6 Views
directing output from files 1-10
Toolbar button creating 3-14
executing 1-10, 2-7
Check All Syntax 2-7 granting privileges for 3-9
statements
Check Selected Syntax 2-7 synonyms for 3-14
checking for errors in 2-12
Copy 2-6, 2-18 Violations tables, using 3-19
executing 2-12
Cut 2-6
summary of executed 2-5
Execute All SQL 2-7
supported 3-5
SQL Editor
Execute Selected SQL 2-7 W
Find Again 2-7
exiting 1-10 What’s This? toolbar button 1-12,
Find/Replace 2-7
launching 1-8 2-7, 2-18
New 2-6
locating text in 2-9 Window, minimizing 1-10
Open 2-6
menu bar 2-5
Paste 2-6
toolbar 2-6
Save 2-6, 2-18
window 2-3 to 2-5
Stop Execution 2-7
Z
SQL menu 2-5
Undo 2-6 Zoom In toolbar button 2-18
SQL Result History text box,
What’s This? 1-12, 2-7, 2-18 Zoom Out toolbar button 2-18
using 2-5
Zoom In 2-18
SQL statement categories
Zoom Out 2-18
client/server connection 3-6
Transactions, using 3-18
data access 3-5, 3-7 to 3-12
Triggers
data definition 3-5, 3-13
creating 3-14
data integrity 3-6, 3-18
setting modes of 3-19
data manipulation 3-6, 3-20
query optimization 3-6, 3-21
routines 3-6, 3-23 to 3-28
SQL Statements text box, using 2-4
U
sqleditor command 1-9 to 1-11 Undo toolbar button 2-6