A.3 How to create the SAMPLE table
Before you create the SAMPLE table, you must create the data DB areas (ADBUTBL01 and ADBUIDX01) where the SAMPLE table will be stored. The SAMPLE table cannot be created using the method explained here until you have created ADBUTBL01 and ADBUIDX01.
To create the SAMPLE table:
Procedure
-
Create a user named ADBUSER02. Set the password for this ADBUSER02 user to #HelloHADB_02.
SQL statement to be executed:
CREATE USER "ADBUSER02" IDENTIFIED BY '#HelloHADB_02'
-
Grant the CONNECT privilege and the schema definition privilege to the ADBUSER02 user.
SQL statement to be executed:
GRANT CONNECT, SCHEMA TO "ADBUSER02"
-
To create the SAMPLE table, execute $ADBDIR/sample/create_sampledb.sh, which is a shell script that creates the SAMPLE table.
When you execute this shell script, the SAMPLE table is defined, and then data is imported into the SAMPLE table.
The following shows the schema, table, and B-tree index definitions for the SAMPLE table that is created:
CREATE SCHEMA "ADBUSER02" CREATE TABLE "SAMPLE"( "STATECODE" SMALLINT, "STATENAME" VARCHAR(15), "ZIPCODE" CHAR(15), "ADDRESS" VARCHAR(100), "AREA" DECIMAL(19)) IN ADBUTBL01 CREATE INDEX "CODE_IDX" ON "SAMPLE"("STATECODE" ASC) IN ADBUIDX01 EMPTY
- ■ SAMPLE table format
-
STATECODE
STATENAME
ZIPCODE
ADDRESS
AREA
1
Alabama
36130-2751
State Capitol N-104 600 Dexter Avenue Montgomery
135,765,000,000
2
Alaska
99811
State Capitol Juneau
1,717,854,000,000
3
Arizona
85007
State Capitol West Wing 1700 W. Washington, 9th Fl. Phoenix
295,254,000,000
:
:
:
:
:
49
Wisconsin
53707-7863
State Capitol P.O. Box 7863 Madison
169,639,000,000
50
Wyoming
82002-0010
State Capitol Cheyenne
253,336,000,000
- Explanation:
-
STATECODE: State code
STATENAME: State name
ZIPCODE: Zip code
ADDRESS: Address of state capitol
AREA: Area of state in square meters
The files related to the sample application program are as follows:
-
$ADBDIR/sample/Sample1.java: Sample application program that uses a JDBC driver
-
$ADBDIR/sample/odbc_sample1.c: Sample application program that uses an ODBC driver
-
$ADBDIR/sample/cli_sample1.c: Sample application program that uses CLI functions
-
$ADBDIR/sample/create_sampledb.sh: Shell script for creating the SAMPLE table
-
$ADBDIR/sample/SAMPLE.txt: Data to be stored in the SAMPLE table
-
$ADBDIR/sample/SAMPLE_table.sql: File containing the definition SQL statements for defining the SAMPLE table