HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide manual

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

Go to page of

A good user manual

The rules should oblige the seller to give the purchaser an operating instrucion of HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide, along with an item. The lack of an instruction or false information given to customer shall constitute grounds to apply for a complaint because of nonconformity of goods with the contract. In accordance with the law, a customer can receive an instruction in non-paper form; lately graphic and electronic forms of the manuals, as well as instructional videos have been majorly used. A necessary precondition for this is the unmistakable, legible character of an instruction.

What is an instruction?

The term originates from the Latin word „instructio”, which means organizing. Therefore, in an instruction of HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide one could find a process description. An instruction's purpose is to teach, to ease the start-up and an item's use or performance of certain activities. An instruction is a compilation of information about an item/a service, it is a clue.

Unfortunately, only a few customers devote their time to read an instruction of HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide. A good user manual introduces us to a number of additional functionalities of the purchased item, and also helps us to avoid the formation of most of the defects.

What should a perfect user manual contain?

First and foremost, an user manual of HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide should contain:
- informations concerning technical data of HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide
- name of the manufacturer and a year of construction of the HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide item
- rules of operation, control and maintenance of the HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide item
- safety signs and mark certificates which confirm compatibility with appropriate standards

Why don't we read the manuals?

Usually it results from the lack of time and certainty about functionalities of purchased items. Unfortunately, networking and start-up of HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide alone are not enough. An instruction contains a number of clues concerning respective functionalities, safety rules, maintenance methods (what means should be used), eventual defects of HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide, and methods of problem resolution. Eventually, when one still can't find the answer to his problems, he will be directed to the HP (Hewlett-Packard) service. Lately animated manuals and instructional videos are quite popular among customers. These kinds of user manuals are effective; they assure that a customer will familiarize himself with the whole material, and won't skip complicated, technical information of HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide.

Why one should read the manuals?

It is mostly in the manuals where we will find the details concerning construction and possibility of the HP (Hewlett-Packard) c-tree-SQL ISQL and Tool reference Guide item, and its use of respective accessory, as well as information concerning all the functions and facilities.

After a successful purchase of an item one should find a moment and get to know with every part of an instruction. Currently the manuals are carefully prearranged and translated, so they could be fully understood by its users. The manuals will serve as an informational aid.

Table of contents for the manual

  • Page 1

    ISQL and T ools Reference Guide For use with c-treeSQL Server This manual provides refe rence material for the IS QL interactive SQL utility and other administrative tool s provided in th e c-treeSQL enviro nment. It also includes a tutorial describi ng how to use the ISQL utility .[...]

  • Page 2

    Copyright © 1992-2004 FairCo m Corporation All rights reserved. Portions © 1987-2004 Dharma Systems, Inc. All rights reserved. Eleventh Edition, First printing: September 2003 Information in th is document is subject to change without notice. No part of this publication may be stor ed in a retrieval system, or transmitted in any form or by any me[...]

  • Page 3

    Fa ir Co m Co rp or at io n i T able of Content s Documentation Overvi ew Purpose of This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [...]

  • Page 4

    ii FairCom Corporation 3.5 The HELP and TABLE Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11 3.6 Transaction Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11 3.7 ISQL Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . [...]

  • Page 5

    Fa i r Co m C o rp o ra t i on ii i 5.4 Data File Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5- 2 5.5 The Commands File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 5.5.1 The DEFINE RECORD Statement . . . . . .[...]

  • Page 6

    iv FairCom Corporation[...]

  • Page 7

    FairCom Corporation v Document ation Overview PURPOSE OF THIS MANUAL This manual provides reference material for th e ISQL interactive SQL utility as well as the dbload , dbdump , and dbschema administrative tools provided in the c-treeSQ L environment. It also includes a tutorial describing how to us e the ISQL utility . AUDIENCE The reader of thi[...]

  • Page 8

    ISQL and Tools vi FairCom Corporation RELATED DOCUMENT ATION Refer to the following docum ents fo r more information: lowercase Lowercase type deno tes either user-suppl ied elements or names of othe r syntax diagrams. User-supplied elements include names of tables, host- language variables, e xpressions, and literals. Syntax diagrams can refer to [...]

  • Page 9

    FairCom Corporation 1-1 Chapter 1 Introduction 1.1 OVERVIEW Interactive SQL (often referred to throughou t this manual as ISQL) is a utility supp lied wi th c- treeSQL that lets you issue SQL statements directly from a term inal and see results displ ayed at the terminal. Y ou can use interactive SQL to: • Learn how SQL statements work • T est [...]

  • Page 10

    ISQL and Tools 1-2 FairCom Corpora tion[...]

  • Page 11

    FairCom Corporation 2-1 Chapter 2 Quick T our 2.1 INTRODUCTORY T UTORIAL iSQL_Tutorial1.sql This introductory tutorial will rapidly tak e you throug h the basic use of the powerful interactive SQL (iSQL) database interface. iSQL is a full featured command lin e client side query tool usef ul for submitting ad hoc SQL statemen ts to a Server . Likew[...]

  • Page 12

    ISQL and Tools 2-2 FairCom Corpora tion 2.1.2 Define In this case define consists of the CREA TE T ABLE statement. This is done in a single iSQL st atement in which specific fields are defined. Upon successfu l cr eation of the table, the changes made to the database by this tr ansaction are made permanent by executing the COMMIT WORK stat ement. T[...]

  • Page 13

    Quick Tour FairCom Corporation 2-3 VALUES ('1001', '61434', 'CT', '1', 'Michael Jordan', '13 Main', 'Harford'); ISQL> INSERT INTO CUSTMAST VALUES ('1002', '73677', 'GA', '1', 'Joshua Brown', '4356 Cambridge', 'At[...]

  • Page 14

    ISQL and Tools 2-4 FairCom Corpora tion 2.2 RELATIONAL MODE L AND INDEXING TU T O R I A L iSQL_Tutorial2.sql This intermediate tutorial will ad vance the concepts introduced in the first tutorial by expanding the nu mber of tables and building a relational model. This tutorial wi ll wal k you th rough defining an index for each table, demonstrating[...]

  • Page 15

    Quick Tour FairCom Corporation 2-5 OrderList - A table of records consisting of a list of orders. OrderItem - A table of records consisting of sp ecific items associated with an order . ItemMaster - A table of records consisting of information about item s. CustomerMaster - A table of records consisting of sp ecific info related to each customer . [...]

  • Page 16

    ISQL and Tools 2-6 FairCom Corpora tion ISQL> CREATE INDEX itemnum ON itemmast (im_itemnum); ISQL> CREATE TABLE custmast ( cm_custnum VARCHAR(5), cm_zip VARCHAR(10), cm_state VARCHAR(3), cm_rating VARCHAR(2), cm_name VARCHAR(48), cm_address VARCHAR(48), cm_city VARCHAR(48)); ISQL> CREATE INDEX custnum ON custmast (cm_custnum); ISQL> COM[...]

  • Page 17

    Quick Tour FairCom Corporation 2-7 INSERT INTO custmast VALUES ('1000', '92867', 'CA', '1', 'Bryan Williams', '2999 Regency', 'Orange'); INSERT INTO custmast VALUES ('1001', '61434', 'CT', '1', 'Michael Jordan', '13 Main&apos[...]

  • Page 18

    ISQL and Tools 2-8 FairCom Corpora tion 2.2.5 Complete Relational Model and Indexing T utorial Source Code Complete source code for the relatio nal mo del and indexing tuto- rial can be found in Appendi x A " T utorial Source Code " .[...]

  • Page 19

    Quick Tour FairCom Corporation 2-9 2.3 LOCKING T UTORIAL iSQL_Tutorial3.sql This tutorial will introduce the co ncept of locking. The fu nction- ality for this tutorial focuses on adding records, then updati ng a single record to th e customer master table. From the iSQL utili ty the script will be parsed and passe d to the server . The script c om[...]

  • Page 20

    ISQL and Tools 2-10 FairCom Corporation 2.3.2 Define In this case define consists of the CREA TE T ABLE statement. This is done in a single iSQL st atement in which specific fields are defined. Upon successfu l cr eation of the table, the changes made to the database by this tr ansaction are made permanent by executing the COMMIT WORK stat ement. T[...]

  • Page 21

    Quick Tour FairCom Corporation 2-11 The first process has the record associated with customer number 1003 locked. Meanwhile the second process has attempted to delete the conten ts of the customer master table and has been blocked when attempting to lock the table. At th is point both processes are effectively blocked. The first process is holding [...]

  • Page 22

    ISQL and Tools 2-12 FairCom Corporation 2.3.5 Complete Locking T utorial Source Code Complete source code for the lock ing tutorial can be found in Appendix A " Tutorial Source Code " .[...]

  • Page 23

    Quick Tour FairCom Corporation 2-13 2.4 T RANSACTION PROCESSING T U TORIAL iSQL_Tutorial4.sql This tutorial will introduce the concept of trans action processing , based on the relational model of the previous tu torial. Records will be added to tables orderlist and orderitems as a single transac- tion. T ransaction processing in iSQ L is hand led [...]

  • Page 24

    ISQL and Tools 2-14 FairCom Corporation T ransaction These tables consist of a Customer Master tabl e and an Item Master table that su pport prima- rily static info rmation regarding a com pany's product lin e and cust om er demographics. The orderlist and orderitems tables co nsist of dynam ic information pertinent to day to day sales. This d[...]

  • Page 25

    Quick Tour FairCom Corporation 2-15 2.4.3 Manage This step provides data managem ent functionality for th e applica- tion. In this exampl e we will ad d records to the itemmast and cust- mast tables, intended as static data. Then, sales ord e rs will be processed as a transaction and "commited" or "rolled back" depending on the [...]

  • Page 26

    ISQL and Tools 2-16 FairCom Corporation SELECT orderlist.ol_custnum, custmast.cm_custnum FROM orderlist, custmast WHERE orderlist.ol_custnum = custmast.cm_custnum; ROLLBACK WORK; 2.4.4 Done When a client application has completed operations with the server , it mu st release resources by disconnect ing from the data- base. iSQL is an application th[...]

  • Page 27

    FairCom Corporation 3-1 Chapter 3 ISQL S t atement s 3.1 OVERVIEW This chapter describes only those statem ents that are specific to ISQL. See the c-tr eeSQL Ref- er ence Guide for detailed reference information on stand a rd SQL statements that can be issued in other environments. 3.2 S T ARTING INTERACTIVE SQL Start ISQL by issuing the isql comma[...]

  • Page 28

    ISQL and Tools 3-2 FairCom Corpora tion The file name must be enclosed in doubles quotes, such as: isql -s "test script.sql" testdb -u user_name The user name c-treeSQL uses to conn ect to the database specified in the connect_string . c- treeSQL verifies the user name against a co rrespo ndi ng password befo re it connects to the databas[...]

  • Page 29

    ISQL Statements FairCom Corporation 3-3 3.4 FORMATTING OUTPUT OF ISQL QUERIES Formatting of d atabase query results m akes the outp ut of a databa se qu ery m ore presentable and understandable. The formatted output of an ISQL database query can be either displayed on the screen, written to a file, or spooled to a printer to produce a hardcopy of t[...]

  • Page 30

    ISQL and Tools 3-4 FairCom Corpora tion ISQL includes several statements that provid e simple formatting of SQL queries. The follow- ing table summarizes the ISQL query-fo rmatti ng statements. The rest of this section provides an extended ex ample that illustrates how to use the statements together to impro ve formatting. T able 3-2: ISQL S tateme[...]

  • Page 31

    ISQL Statements FairCom Corporation 3-5 All the examples use the same ISQL query . The query retrieves data on outstanding customer orders. The query joins two tables, customers and or ders . The example s for the T ABLE state- ment on Section 3.7.13 " H OST or SH or ! " on page 3-31 show the columns and data typ es for these sample tab l[...]

  • Page 32

    ISQL and Tools 3-6 FairCom Corpora tion 3.4.1 Formatting Column Displ ay with the COLUMN St atement Y ou can specify the width of the display for ch aracter columns with th e COLUMN statement's "An" format string. Specify the form at str ing in the FORMA T clause of the COLUMN state- ment. Y ou need to issue separate COLUMN stat emen[...]

  • Page 33

    ISQL Statements FairCom Corporation 3-7 Example 3-3: Customizing Format of Nu meric Co lumn Displays ISQL> column order_value format "$99,999,999.99" ISQL> column; -- Show all the COLUMN statements now in effect: column CUSTOMER_NAME format "A19" heading "CUSTOMER_NAME" column CUSTOMER_CITY format "A19"[...]

  • Page 34

    ISQL and Tools 3-8 FairCom Corpora tion whenever the value in the customer_name column changes. In other words, we need to specify a column break on the customer_nam e column. Approach this task in two steps. First, devi se a DISPLA Y statement to display the customer name and confirm that it is displayi ng correct ly . Then, issue COMPUTE statemen[...]

  • Page 35

    ISQL Statements FairCom Corporation 3-9 The following example also issues two more DI SPLA Y statements to display the variable val- ues. As before, the DISPLA Y statements must specify the customer_name break. They also indent their display farther to indicate the relationship with the previo usly issued DISPLA Y . As before, this example uses the[...]

  • Page 36

    ISQL and Tools 3-10 FairCom Corporation The TITLE statement lets you sp ecify text that ISQL displays before (TITLE TOP) or after (TITLE BOTT OM) the query results. The title can also be horizontally positioned by specifyin g the keyw ords LEFT , CENTER, or RIGHT ; or by specifying the actual column number corresp onding to the required positioning[...]

  • Page 37

    ISQL Statements FairCom Corporation 3-11 End of Orders Summary Report 23 records selected ISQL> 3.5 THE HELP AND T A BLE S T ATEMENTS ISQL supports an on-line help facility that can be invoked by usi ng the HELP statem ent . T yp - ing HELP at the ISQL prompt will display a help file which will list the options accepted by the HELP statement. Th[...]

  • Page 38

    ISQL and Tools 3-12 FairCom Corporation <SQL statement> ROLLBACK WORK ; An SQL statement starting immediately af ter a COMMIT WORK or ROLLBACK WORK statement starts a new transaction. 3.7 ISQL REFERENCE This section provides reference materi al for statements specific to ISQL. This section does not include description s of stan dard SQL state[...]

  • Page 39

    ISQL Statements FairCom Corporation 3-13 insert into stores values (1001,chassis); insert into stores values (1002,chips); select * from stores where item_no > 1001; set echo off ; T o execute the above statements stored in a file named cmdfile , enter: ISQL> @cmdfile 3.7.2 BREAK Synt ax BREAK [ ON break_spec [ SKIP n ] ] ; break_spec:: { col[...]

  • Page 40

    ISQL and Tools 3-14 FairCom Corporation SKIP n The optional SKIP clause can be used to skip th e specified number of li nes when the specified break occurs and before processing o f any associated DISPLA Y statements. Examples The following examples illustrate how various break set tin gs and correspond ing DISPLA Y statements affect the disp l a y[...]

  • Page 41

    ISQL Statements FairCom Corporation 3-15 ISQL> select customer_name from customers; CUSTOMER_NAME ------------- Sports Cars Inc. Break on every row! Mighty Bulldozer Inc. Break on every row! Ship Shapers Inc. Break on every row! . . . ISQL> break on page ISQL> select customer_name from customers; CUSTOMER_NAME ------------- Break on page ([...]

  • Page 42

    ISQL and Tools 3-16 FairCom Corporation | BREAK | COLUMN | COMPUTE | DISPLAY | TITLE Description The CLEAR statement removes settings made b y the ISQL statement corresp onding to option. Argument option Which ISQL statement' s settings to clear: • CLEAR HISTOR Y - Clears the IS Q L statement history buffer . • CLEAR BREAK - Clears the bre[...]

  • Page 43

    ISQL Statements FairCom Corporation 3-17 Description The COLUMN statement controls how ISQL displays a column's values (the FORMA T clause) and specifies alternative column-h eading text (the HEADING clause). The COLUMN statement without any arguments displays the current column specifications. Argument s column_nam e The name of the column af[...]

  • Page 44

    ISQL and Tools 3-18 FairCom Corporation (a) Format S tring Details T able 3-3: Numeric Format Strings for the COLUMN St atement Character Example Description 9 99999 Number of 9's specifies width. If the column val ue is too large to display in the specified format, ISQL displays # characters in place of the value. 0 09999 Display leading zero[...]

  • Page 45

    ISQL Statements FairCom Corporation 3-19 Examples The following examples are based on a table, or ders , wit h columns defined as follows: ISQL> table orders COLNAME NULL ? TYPE LENGTH ------- ------ ---- ------ order_id NOT NULL INT 4 customer_id INT 4 steel_type CHAR 20 W The week of month as a 1-digit number (in the range 1-5). DDD The day of[...]

  • Page 46

    ISQL and Tools 3-20 FairCom Corporation order_info CHAR 200 order_weight INT 4 order_value INT 4 order_state CHAR 20 ISQL displays the order_info co lumn, at 200 characters, with lo ts of blank space preceding the values: ISQL> select order_info from orders where order_value < 1000000 ORDER_INFO ---------- Solid Rods 5 in. diameter 1 record s[...]

  • Page 47

    ISQL Statements FairCom Corporation 3-21 Thursday 1 record selected ISQL> column sysdate format "Month" ISQL> select sysdate from syscalctable SYSDATE ------- May 1 record selected ISQL> column sysdate format "DDth" ISQL> select sysdate from syscalctable SYSDATE ------- 7th 1 record selected Note: If the select-list [...]

  • Page 48

    ISQL and Tools 3-22 FairCom Corporation COMPUTE statements have no ef fect until you issue a BREAK statement with the same br eak_spec . Issuing the COMPUTE statement without any arguments displays the currently-set COM- PUTE specifications, if any . Argument s A VG | MAX | MIN | SUM | COUNT The function to apply to values of column_name . The func[...]

  • Page 49

    ISQL Statements FairCom Corporation 3-23 3.7.6 DEFINE Synt ax DEFINE [ variable_name = value ] ; Description The DEFINE statement defines a variable and assigns an ASCII strin g value to it. When you refer to the defined variable in DISPLA Y statements, ISQL prints the value. The DEFINE statement is usefu l if you have scripts wit h many DISPLA Y s[...]

  • Page 50

    ISQL and Tools 3-24 FairCom Corporation Issuing the DISPLA Y statemen t wit hout any arguments displays the currently-set DISPLA Y specifications, if any . Argument s col_position An optional argument that specifies the horizontal positioning of the associated display value. There are two forms for the ar gument: If the DISPLA Y statement omits co [...]

  • Page 51

    ISQL Statements FairCom Corporation 3-25 ISQL> display col 5 "Number of orders placed by", customer_name, "=" , n_ord on customer_name ISQL> compute count of order_id in n_ord on customer_name; ISQL> select c.customer_name, o.order_id from customers c, orders o where o.customer_id = c.customer_id; CUSTOMER_NAME ORDER_ID[...]

  • Page 52

    ISQL and Tools 3-26 FairCom Corporation edited. When you exit the editor , ISQL writes the buf fer contents as the last statement in the history buffer . By default, ISQL invokes the vi editor on UNIX and the MS-DOS editor on NT . Y ou can change the default by setting the EDITOR environment variable: • On UNIX, set the environment variab le at t[...]

  • Page 53

    ISQL Statements FairCom Corporation 3-27 3.7.10 GET Synt ax G[ET] filename; Description The GET statement reads the fi rst SQL statement stored in the specified script file. Argument s filename The name of the script file. IS QL reads the file unti l it encounters a semico lon ( ; ) statement terminator . It ap pends the statement to the history bu[...]

  • Page 54

    ISQL and Tools 3-28 FairCom Corporation ( orders.order_id = lots.order_id ) and ( ( customers.customer_name = 'Ship Shapers Inc.' ) AND ( lot_staging.start_date is not NULL ) AND ( lot_staging.end_date is NULL ) ) ISQL> RUN SELECT customers.customer_name, orders.order_info, orders.order_state, lot_staging.lot_location, lot_staging.star[...]

  • Page 55

    ISQL Statements FairCom Corporation 3-29 CUSTOMER_NAME ORDER_INFO ------------- ---------- ORDER_STATE LOT_LOCATION START_DATE ----------- ------------ ---------- Ship Shapers Inc. I Beams Size 10 Processing Hot Rolling 12/26/1994 1 record selected 3.7.1 1 HELP Synt ax HE[LP] {COMMANDS|CLAUSES}; HE[LP] ; Description The HELP statement displays the [...]

  • Page 56

    ISQL and Tools 3-30 FairCom Corporation Description The HISTOR Y statement lists the statements in the statement hi story buffer , along with an identifying number . Notes • ISQL maintains a list of statements typed by the user in the statement history buffer . The SET HISTOR Y statement sets the size of the history buf fer . • The statements L[...]

  • Page 57

    ISQL Statements FairCom Corporation 3-31 3.7.13 HOST or SH or ! Synt ax { HOST | SH | ! } [host_command]; Description The HOST statement executes a host operating system co mmand without terminatin g the cur- rent ISQL session. Argument s HOST | SH | ! Synonyms for directing ISQL to execute an operating system com mand. host_command The operating s[...]

  • Page 58

    ISQL and Tools 3-32 FairCom Corporation 3.7.14 LIST Synt a x L[IST] [ stmt_num ]; Description The LIST statement displays th e statement with the specified statement num ber from the state- ment history buffer and makes it the current stat ement by adding it to the end of the history list. If LIST omits st mt_num , it displays the last statem ent i[...]

  • Page 59

    ISQL Statements FairCom Corporation 3-33 3.7.15 QUIT or EXIT Synt ax Q[UIT] Description The QUIT statement terminates the current ISQL session. Related St atement s QUIT and EXIT are synonymous. There is no difference in their effect. 3.7.16 RUN Synt ax R[UN] [stmt_num]; Description The RUN statement executes the st atement with the speci fied stat[...]

  • Page 60

    ISQL and Tools 3-34 FairCom Corporation Office Furniture Inc. 10 records selected ISQL> 3.7.17 SA VE Synt a x S[AVE] filename; Description The SA VE statement saves the last statement in the history buffer in filename. The GET and ST AR T statements can then be used to r ead and execute the statement from a file. If filename does not exist, ISQL[...]

  • Page 61

    ISQL Statements FairCom Corporation 3-35 | COMMAND LINES number_lines | REPORT { ON | OFF } | ECHO { ON | OFF } | PAUSE { ON | OFF } | TIME { ON | OFF } | DISPLAY COST { ON | OFF } | AUTOCOMMIT { ON | OFF } | TRANSACTION ISOLATION LEVEL isolation_level | CONNECTION { database_name | DEFAULT } Description The SET statement changes various character [...]

  • Page 62

    ISQL and Tools 3-36 FairCom Corporation DISPLA Y COST ON | OFF SET DISPLA Y COST ON displays the values th e c-treeSQL optimizer uses to calculate the least-costly query strategy fo r a part icular SQL statement. The UPDA TE ST A TISTICS statem ent updates the values displayed b y SET DISPLA Y COST ON. SET DISPLA Y COST OFF suppresses the display a[...]

  • Page 63

    ISQL Statements FairCom Corporation 3-37 sys_chkcol_usage sys_keycol_usage Here's a page break! . . . ISQL> SET DISPLAY COST ON ISQL> -- Select from the one-record SYSCALCTABLE table: ISQL> SELECT * FROM SYSCALCTABLE; Estimated Cost Values : ----------------------- COST : 8080 CARDINALITY : 200 TREE SIZE : 3072 FLD --- 100 3.7.19 SHOW[...]

  • Page 64

    ISQL and Tools 3-38 FairCom Corporation ____________________ EDITOR ..................... : vi HISTORY buffer size ........ : 50 PAUSE ..................... : ON COMMAND LINES .............. : 10 TIMEing command execution.. : OFF SPOOLing ................... : ON LINESIZE .................. : 78 REPORTing Facility ......... : ON PAGESIZE ..........[...]

  • Page 65

    ISQL Statements FairCom Corporation 3-39 Example T o record the displayed output into the file called STK, enter: ISQL> SPOOL STK ON ; ISQL> SELECT * FROM customer ; ISQL> SPOOL OFF ; 3.7.21 ST ART Synt ax ST[ART] filename [ argument ] [ ... ] ; Description The ST AR T statement executes the first SQL stat ement stored in the specified scr[...]

  • Page 66

    ISQL and Tools 3-40 FairCom Corporation ISQL> -- Display a script file with the ! shell statement. The script's SQL ISQL> -- statement uses the LIKE predicate to retrieve customer names ISQL> -- beginning with the string passed as an argument in a START statement: ISQL> ! more start_ex.sql SELECT customer_name FROM customers WHERE [...]

  • Page 67

    ISQL Statements FairCom Corporation 3-41 has_ccnstrs NOT NULL VARCHAR 1 has_ucnstrs NOT NULL VARCHAR 1 tbl_status NOT NULL VARCHAR 1 rssid NOT NULL INT 4 The following example uses the table command to d etail the struct ure of the tables used in examples throughout this chapter . ISQL> table - List the sample tables TABLENAME --------- customer[...]

  • Page 68

    ISQL and Tools 3-42 FairCom Corporation lot_id NOT NULL INT 4 purity DOUBLE 8 p_deviation DOUBLE 8 strength DOUBLE 8 s_deviation DOUBLE 8 comments CHAR 200 ISQL> table samples COLNAME NULL ? TYPE LENGTH ------- ------ ---- ------ lot_id INT 4 samples INT 4 comments CHAR 200 ISQL> 3.7.23 TITLE Synt a x TITLE [ [ TOP | BOTTOM ] [ [ LEFT | CENTE[...]

  • Page 69

    ISQL Statements FairCom Corporation 3-43 Examples The following example shows the effect of specifying a top title without a bottom ti tle, then both a top and bottom title. ISQL> TITLE "fred" ISQL> select * from syscalctable; fred FLD --- 100 1 record selected ISQL> TITLE BOTTOM "flintstone" ISQL> select * from sysc[...]

  • Page 70

    ISQL and Tools 3-44 FairCom Corporation[...]

  • Page 71

    FairCom Corporation 4-1 Chapter 4 Dat a Load Utility: dbload 4.1 INTRODUCTION This chapter describes the c-treeSQL database load utility , dbload . This utilit y loads records from an input d ata file into tables o f a databa se. The format of the data file is specified by a record description given in an input com man ds file to dbload . Both dblo[...]

  • Page 72

    ISQL and Tools 4-2 FairCom Corpora tion Figure 4- 1: dbload Execution Process 4.2 PREREQUISITES FOR DBLOAD Before running dbload , you need: • A valid, readable commands file • INSER T privileges on the tables named in the commands fil e 4.3 DBLOAD COMMAND LINE SYNT AX The dbload command does not directl y sp ecify an input file, but instead na[...]

  • Page 73

    Data Load Utility: dbload FairCom Corporation 4-3 -l logfile Specifies the file into which the error lo ggi ng is done. stderr is the default. db load also writes statistics to the file: • Number of records read • Number of records skipped • Number of records loaded • Number of records rejected -b badfile The file into which the bad rows th[...]

  • Page 74

    ISQL and Tools 4-4 FairCom Corpora tion 4.4.1 V ariable Length Records For variable length records, the fields in th e da ta file can be of varying length. Unless the key- word FIXED is used in the commands fi le, it is assumed that the dbload record processing will be for variable length records. 4.4.2 Fixed Length Records For fixed length records[...]

  • Page 75

    Data Load Utility: dbload FairCom Corporation 4-5 4.5.1 The DEFINE RECORD St atement The DEFINE RECORD statement is us ed to define the record that is to be loaded into the data- base. It describes the data fou nd in the data file . The foll owing are the definition s that are made known by the DEFINE RECORD statemen t: • Names the record to be l[...]

  • Page 76

    ISQL and Tools 4-6 FairCom Corpora tion • start_position is th e position where t he field starts. It must be an unsigned integer . • end_position is the position where the fiel d en ds. It must be an unsi gned integer . The first position of each record is 1 and not 0. If date and time types are to be inserted they can be specified as characte[...]

  • Page 77

    Data Load Utility: dbload FairCom Corporation 4-7 statement. The following example shows the list interchanged with respect to the list in the DEFINE RECORD statement. DEFINE RECORD dept_rec AS ( dept_no, dept_name, location ) FIELD DELIMITER ' ' ; FOR EACH RECORD dept_rec FROM dept_in INSERT INTO ADMIN.department (loc, no, name) VALUES ([...]

  • Page 78

    ISQL and Tools 4-8 FairCom Corpora tion The following is the commands f ile to load records into the or ders table. The input data file is or ders_in which is a binary file in the fixed length recor d fo rmat. DEFINE RECORD orders_rec OF FIXED LENGTH 30 AS ( order_no POSITION (1:4) LONG, order_date POSITION (6:16) CHAR, product POSITION (18:25) CHA[...]

  • Page 79

    Data Load Utility: dbload FairCom Corporation 4-9 Position for SHORT no t specified corr ectly . The size of the field (start position to end position) must be equa l to th e size of SHOR T . Position for LONG not specified correctly . The size of the field (start position to end position) mu st be equal to the size of LONG . Position for FLOA T no[...]

  • Page 80

    ISQL and Tools 4-10 FairCom Corporation[...]

  • Page 81

    FairCom Corporation 5-1 Chapter 5 Dat a Unload Utility: dbdump 5.1 INTRODUCTION This chapter describes the c-treeSQL database dump utility , dbdump . dbdump writes the data in a database to a file. The format of the exported data is specified by the record description given in an input comm and file to dbdump . Both dbload and dbdump commands files[...]

  • Page 82

    ISQL and Tools 5-2 FairCom Corpora tion • SELECT privileges on the tables named in the commands file 5.3 DBDUMP COMMAND LINE SYNT AX The dbdump command accepts the commands file name, the database name and a command option. Synt a x dbdump -f commands_file [-n] database_name Options -f command s_file Specifies the f ile containing dbdump co mmand[...]

  • Page 83

    Data Unload Utility : dbdump FairCom Corporation 5-3 The syntax definition for the commands file is as shown: dbdump_commands: define_record_statement for_record_statement The following is sample commands file showin g dum p instructions. DEFINE RECORD ord_rec AS ( ord_no, item_name, date, item_qty ) FIELD DELIMITER ' ' ; FOR RECORD ord_r[...]

  • Page 84

    ISQL and Tools 5-4 FairCom Corpora tion • r ecor d _length is the length of the fixed length record. This length sh ould include the length of field or record delimiters, if any . • field_name is the name used to refer to a field in the data file. • delimiter_char is the field delimiter and is a single character . delim iter_char must be spec[...]

  • Page 85

    Data Unload Utility : dbdump FairCom Corporation 5-5 ( no, name, loc ) FIELD DELIMITER ' ' ; FOR RECORD dept_rec DUMP INTO deptrecs_out USING SELECT dept_no , dept_name , location FROM ADMIN.dept ; The following is the commands file to write records from the customer tab le. The output data file is cust_out which is a binary file in the f[...]

  • Page 86

    ISQL and Tools 5-6 FairCom Corpora tion[...]

  • Page 87

    FairCom Corporation 6-1 Chapter 6 Schema Export Utility: dbschema 6.1 INTRODUCTION This chapter describes the c-treeSQL utility , dbschema . This utility recreates specified data- base elements and data. Synt ax dbschema [ -h ] [ -d ] [-u user_name ] [-a password ] [ -o outfile ] [ -p [ user_name.]procedure_name [ , ... ] ] [ -t [ user_name.]table_[...]

  • Page 88

    ISQL and Tools 6-2 FairCom Corpora tion against a corresponding user name before it connect s to the database. If omit ted, the default value depends on the environment. (On UNIX , the val ue of the DH_P ASSWD environmen t variable specifies the default password.) -o outfil e Redirects the output to the specified file. The default is standard outpu[...]

  • Page 89

    Schema Export Utility: dbschema FairCom Corporation 6-3 ADMIN@isis% dbschema -t dbp1,test_view rdsdb DBSCHEMA create table ADMIN.dbp1 ( c1 integer ) pctfree 20; create view ADMIN.test_view ( fld ) as select * from test_revoke1 ; The following example uses the -p option with the % wildcard character to generat e definitions for all stored procedures[...]

  • Page 90

    ISQL and Tools 6-4 FairCom Corpora tion[...]

  • Page 91

    FairCom Corporation A-1 Appendix A T utorial Source Code A.1 INTRODUCTORY T U TORIAL CREATE TABLE CUSTMAST ( cm_custnum VARCHAR(5), cm_zip VARCHAR(10), cm_state VARCHAR(3), cm_rating VARCHAR(2), cm_name VARCHAR(48), cm_address VARCHAR(48), cm_city VARCHAR(48) ); COMMIT WORK; INSERT INTO CUSTMAST VALUES ('1000', '92867', 'CA[...]

  • Page 92

    ISQL and Tools A-2 FairCom Corporation oi_itemnum VARCHAR(6) ); CREATE INDEX orderitem ON orderitems (oi_ordernum, oi_seqnumber); CREATE TABLE itemmast ( im_weight INTEGER, im_price MONEY, im_itemnum VARCHAR(6), im_desc VARCHAR(48) ); CREATE INDEX itemnum ON itemmast (im_itemnum); CREATE TABLE custmast ( cm_custnum VARCHAR(5), cm_zip VARCHAR(10), c[...]

  • Page 93

    Tutorial Source Code FairCom Corporation A-3 COLUMN oi_quantity FORMAT "A10" heading "QTY" COLUMN im_price FORMAT "$99.99" heading "PRICE" SELECT custmast.cm_name, orderitems.oi_quantity, itemmast.im_price FROM custmast, orderitems, itemmast, orderlist WHERE orderlist.ol_custnum = custmast.cm_custnum AND orde[...]

  • Page 94

    ISQL and Tools A-4 FairCom Corporation im_desc VARCHAR(48)); CREATE TABLE custmast ( cm_custnum VARCHAR(5), cm_zip VARCHAR(10), cm_state VARCHAR(3), cm_rating VARCHAR(2), cm_name VARCHAR(48), cm_address VARCHAR(48), cm_city VARCHAR(48)); COMMIT WORK; DELETE FROM orderlist; DELETE FROM orderitems; DELETE FROM itemmast; DELETE FROM custmast; COMMIT W[...]

  • Page 95

    Tutorial Source Code FairCom Corporation A-5 ROLLBACK WORK; INSERT INTO orderitems VALUES ('3', 1, 2, '3'); INSERT INTO orderitems VALUES ('3', 2, 3, '99'); INSERT INTO orderlist VALUES ('9/22/2002', '9/26/2002', '3', '1002'); SELECT orderitems.oi_itemnum, itemmast.im_i[...]

  • Page 96

    ISQL and Tools A-6 FairCom Corporation[...]

  • Page 97

    FairCom Corporation Index-i Index Symbols @Execute syntax . . . . . . . . . . . . . . . . . . . . . 3-12 A Adding titles . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 B Beginning titles . . . . . . . . . . . . . . . . . . . . . . . 3-9 BREAK statement . . . . . . . . . . . . . . . . . . . . . 3-4 BREAK statement syntax . . . . . . . . . .[...]

  • Page 98

    ISQL and Tools Index-ii FairCom Corporation Formatting ISQL outpu t . . . . . . . . . . . . . . . . . 3-3 G GET statement . . . . . . . . . . . . . . . . . . . . . . . . 3-3 GET statement syntax . . . . . . . . . . . . . . . . . 3-27 H HELP statement syntax . . . . . . . . . . . . . . . . 3-29 HISTORY statement . . . . . . . . . . . . . . . . . . .[...]

  • Page 99

    Index Index-iii FairCom Corporation COMPUTE . . . . . . . . . . . . . . 3-4 , 3-7 , 3-21 COMPUTE syntax . . . . . . . . . . . . . . . . 3-21 DEFINE . . . . . . . . . . . . . . . . . . . . 3-4 , 3-23 DEFINE RECORD . . . . . . . . . . . . . 4-5 , 5-3 DEFINE syntax . . . . . . . . . . . . . . . . . . . 3-23 DISPLAY . . . . . . . . . . . . . . . 3-4 , [...]