DEV Community

mmllllzcn
mmllllzcn

Posted on

TIL: What Do the Two Dashes in GBase Database dbaccess - - Actually Mean?

The first time I saw dbaccess - -, I assumed the documentation had accidentally dropped an argument.

dbaccess - -
Enter fullscreen mode Exit fullscreen mode

It turns out that this is one of the most useful interactive entry points in GBase Database(GBase 8s). The two dashes have different meanings, and understanding them makes the four dbaccess operating modes much easier to use.

What Do the Two Dashes Mean?

Each dash represents a different instruction:

  • The first -: Do not select a database at startup.
  • The second -: Read SQL commands from standard input instead of opening the menu interface.

Once the > prompt appears, you can select a database and execute SQL:

DATABASE gbase8s;
SELECT name FROM sysdatabases;
Enter fullscreen mode Exit fullscreen mode

A semicolon terminates each SQL statement. Without it, dbaccess continues waiting for additional input.

Press CTRL-D to exit the interactive session.

How Does It Differ from the Other Three Modes?

GBase Database(GBase 8s) dbaccess supports four practical operating modes:

# Interactive command mode
dbaccess - -

# Menu mode
dbaccess

# Menu mode with a selected database
dbaccess gbase8s

# Pipe mode
echo "select 1 from systables where tabid=1;" | dbaccess gbase8s

# Script mode
dbaccess gbase8s script.sql
Enter fullscreen mode Exit fullscreen mode

Each mode serves a different operational purpose:

Mode Typical use
Menu mode Browse database objects, tables, and session information
Command mode Execute SQL interactively
Pipe mode Run a single query from a shell command
Script mode Execute repeatable SQL tasks and automation

Menu mode is useful when you want to explore without remembering SQL syntax. Pipe mode is convenient for quick checks. Script mode is better for repeatable operations.

Command mode sits between them: it gives you an interactive SQL environment without requiring the full-screen menu.

Environment Variables Are Shared Across Modes

One detail worth remembering: switching dbaccess modes does not automatically reset your client environment.

GBase Database(GBase 8s) uses environment variables such as GL_DATE and CLIENT_LOCALE to control date formatting and client locale behavior.

That means a script may inherit the same formatting settings used in an interactive session.

For automated execution, make these settings explicit in the script environment rather than relying on an operator's current shell configuration.

Two Details That Can Cause Confusion

1. Pipe Mode Needs a Complete SQL Statement

When using pipe mode, terminate the SQL statement with a semicolon:

echo "select count(*) from systables;" | dbaccess gbase8s
Enter fullscreen mode Exit fullscreen mode

Without the terminator, the client may continue waiting for input, making the command appear to hang.

2. Run Shell Commands Without Leaving dbaccess

Inside interactive command mode, prefix a command with !:

! ls -l /data
Enter fullscreen mode Exit fullscreen mode

This executes a shell command without requiring you to exit the database client.

It is particularly useful when checking files or directories during database troubleshooting.

How to Choose the Right dbaccess Mode

A simple rule is to choose based on what you need to accomplish:

  • Need to browse table structures? Use menu mode.
  • Need to check one value? Use pipe mode.
  • Need to repeat the same verification? Put the SQL in a .sql file and use script mode.
  • Need an interactive SQL session? Use dbaccess - -.
  • Need to connect to another instance? Use the remote database form.

For example:

dbaccess dbname@instancename
Enter fullscreen mode Exit fullscreen mode

The instance name must match the relevant sqlhosts entry and the DBSERVERNAME setting in onconfig.

A naming mismatch can produce a connection failure that looks similar to a network problem. GBase Database does not automatically correct inconsistent instance names.

Why the Two Dashes Matter for Troubleshooting

There is another reason to remember this command.

When an application cannot connect to GBase Database, try opening a local interactive session first:

dbaccess - -
Enter fullscreen mode Exit fullscreen mode

If the local connection succeeds, the instance is responding to the client. You can then investigate the application's connection string, network path, and connection configuration.

If it fails, investigate the instance status, listener, client environment, and license-related restrictions.

This single test helps narrow the troubleshooting scope before you start changing configuration files.

Final Thoughts

The two dashes in dbaccess - - are not a typo.

The first means no database is selected at startup. The second means SQL commands come from standard input.

Once you understand that distinction, the four GBase Database(GBase 8s) dbaccess modes become much easier to choose between.

A small command-line detail, but one that can save time during everyday database operations and troubleshooting.

Top comments (0)