Hitachi

Hitachi Advanced Database Setup and Operation Guide


3.12.2 I cannot create a table

If the SQL statement (CREATE TABLE statement) is long and you make a mistake in entering the adbsql command, try the procedure described below to create a table.

The following describes the procedure for executing an SQL statement saved in a file.

Note

You can also use other text editors to create the file (infile) that is being created in steps 1 through 3.

  1. Create the file (infile) that is to contain the SQL statement.

    Enter the operating system command shown below and press Enter. Create the file under the home directory (/home/adbmanager) and use the file name infile.

    vi /home/adbmanager/infile
  2. Enter the SQL statement to be executed.

    Press the I key and enter the SQL statement shown below.

    Enter ADBUSER02 in the first row and #HelloHADB_02 in the second row. Enter the CREATE TABLE statement beginning on the third row.

    ADBUSER02
    #HelloHADB_02
    CREATE TABLE "SAMPLE" ("STATECODE" SMALLINT, "STATENAME" VARCHAR(15),
    "ZIPCODE" CHAR(15), "ADDRESS" VARCHAR(100), "AREA" DECIMAL(19))
    IN ADBUTBL01;
  3. Finish creating the file (infile) containing the SQL statement.

    Press Esc, enter the following command, and then press Enter:

    :wq

    The file (infile) containing the SQL statement has now been created.

  4. Execute the file (infile) containing the SQL statement.

    With the HADB server started, execute the following HADB command:

    adbsql -V < infile

    When the above command is executed, the SQL statement entered in step 2 is executed. The following shows an example of the execution result.

    ■ Execution result example

      USER-ID ?
    ADBUSER02
     
      PASSWORD ?
    #HelloHADB_02
     
    COMMAND ? +----2----+----3----+----4----+----5----+----6----+----7----+
    CREATE TABLE "SAMPLE" ("STATECODE" SMALLINT, "STATENAME" VARCHAR(15),
    NEXT ? +----2----+----3----+----4----+----5----+----6----+----7----+
    "ZIPCODE" CHAR(15), "ADDRESS" VARCHAR(100), "AREA" DECIMAL(19))
    NEXT ? +----2----+----3----+----4----+----5----+----6----+----7----+
    IN ADBUTBL01;
    KFAA96403-I SQL processing completed.

    A table has been created that contains this information.