IBM Informix User Manual

Basic Commands

Server Management

CommandDescription
oninitInitialize and start Informix server
onmodeChange server mode (quiescent, online, etc.)
onstatDisplay server status and statistics
ontapeBackup and restore utility
onbarBackup and restore using IBM Storage Manager
onspacesManage storage spaces
onparamsModify server parameters

Common Server Commands

# Initialize and start the server
oninit

# Start in full production mode
oninit -vy

# Shut down the server
onmode -ky

# Check server status
onstat -

# View disk space
onstat -d

# View logical logs
onstat -l

# View active users
onstat -u

# View locks
onstat -k

# View transactions
onstat -x

Database Connection

Using dbaccess

# Interactive mode
dbaccess

# Run SQL script
dbaccess database_name < sql_script.sql

# Connect with specific user
dbaccess -user myuser mydb

Connection Parameters

Host: localhost (or server IP)
Port: 9088 (default)
Database: your_database
Server Name: your_informix_server

SQL Statements

Creating a Database

-- Create a simple database
CREATE DATABASE mydb;

-- Create with buffered logging
CREATE DATABASE mydb WITH BUFFERED LOG;

-- Create with logging
CREATE DATABASE mydb WITH LOG;

-- Create ANSI-compliant database
CREATE DATABASE mydb WITH LOG MODE ANSI;

Creating Tables

-- Basic table creation
CREATE TABLE customers (
    customer_id SERIAL PRIMARY KEY,
    name CHAR(50),
    email CHAR(100),
    created_date DATE
);

-- Table with constraints
CREATE TABLE orders (
    order_id SERIAL PRIMARY KEY,
    customer_id INTEGER REFERENCES customers(customer_id),
    order_date DATE,
    total_amount DECIMAL(10,2)
);

-- Temporary table
CREATE TEMP TABLE session_data (
    id INTEGER,
    data VARCHAR(255)
);

Inserting Data

-- Insert single row
INSERT INTO customers (name, email, created_date)
VALUES ('John Doe', '[email protected]', TODAY);

-- Insert multiple rows
INSERT INTO customers (name, email, created_date)
VALUES 
    ('Alice Smith', '[email protected]', TODAY),
    ('Bob Johnson', '[email protected]', TODAY);

-- Insert from another table
INSERT INTO customers (name, email, created_date)
SELECT name, email, created_date
FROM customers_import WHERE status = 'active';

Querying Data

-- Select all columns
SELECT * FROM customers;

-- Select specific columns
SELECT name, email FROM customers;

-- Where clause
SELECT * FROM customers WHERE customer_id > 100;

-- Order by
SELECT name, email FROM customers ORDER BY name;

-- Group by with aggregate
SELECT customer_id, COUNT(*) as order_count
FROM orders GROUP BY customer_id;

-- Join tables
SELECT o.order_id, c.name, o.order_date
FROM orders o, customers c
WHERE o.customer_id = c.customer_id;

-- Using JOIN syntax
SELECT o.order_id, c.name, o.order_date
FROM orders o JOIN customers c
ON o.customer_id = c.customer_id;

Updating Data

-- Update single row
UPDATE customers 
SET email = '[email protected]' 
WHERE customer_id = 101;

-- Update multiple rows
UPDATE products 
SET price = price * 0.9 
WHERE category = ' clearance';

Deleting Data

-- Delete single row
DELETE FROM customers WHERE customer_id = 101;

-- Delete based on condition
DELETE FROM orders WHERE order_date < '2024-01-01';

-- Delete all rows
DELETE FROM temp_orders;

Configuration Files

Key Configuration Files

FilePurpose
$INFORMIXDIR/etc/onconfigMain server configuration
$INFORMIXDIR/etc/sqlhostsNetwork configuration
$INFORMIXDIR/etc/$ONCONFIGRoot dbspace configuration

Example onconfig Parameters

ROOTNAME        rootdbs
ROOTPATH        /opt/IBM/informix/online.root
ROOTOFFSET      0
ROOTSIZE        200000
DBSERVERNAME    ol_informix

sqlhosts Example

ol_informix onsoctcp localhost ol_informix
dr_informix drsoctcp localhost dr_informix
lo_informix onsoctcp localhost lo_informix

Backup and Restore

Using ontape

# Full backup
ontape -s -L 0

# Level 1 backup
ontape -s -L 1

# Restore from backup
ontape -r

# Restore to specific point in time
ontape -r -t 2025-03-17

Using onbar

# Full backup
onbar -b -L 0

# Restore
onbar -r

# Verify backup
onbar -v

Performance Tuning

Key Memory Parameters

  • SHMVIRTSIZE - Virtual shared memory size
  • SHMADD - Additional shared memory segments
  • BUFFERPOOL - Data cache configuration

Indexing

-- Create index
CREATE INDEX idx_customers_email ON customers(email);

-- Create unique index
CREATE UNIQUE INDEX idx_orders_id ON orders(order_id);

-- Rebuild index
ALTER INDEX idx_customers_email ACTIVE;

Statistics

-- Update table statistics
UPDATE STATISTICS FOR TABLE customers;

-- Update statistics with high detail
UPDATE STATISTICS HIGH FOR TABLE customers;