Manuale Utente di IBM Informix

Comandi di Base

Gestione del Server

ComandoDescrizione
oninitInizializza e avvia il server Informix
onmodeCambia la modalità del server (quiescent, online, ecc.)
onstatVisualizza lo stato e le statistiche del server
ontapeUtilità di backup e ripristino
onbarBackup e ripristino tramite IBM Storage Manager
onspacesGestisce gli spazi di archiviazione
onparamsModifica i parametri del server

Comandi Comuni del Server

# 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

Connessione al Database

Usare dbaccess

# Interactive mode
dbaccess

# Run SQL script
dbaccess database_name < sql_script.sql

# Connect with specific user
dbaccess -user myuser mydb

Parametri di Connessione

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

Istruzioni SQL

Creare un 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;

Creare Tabelle

-- 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)
);

Inserire Dati

-- 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';

Interrogare i Dati

-- 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;

Aggiornare i Dati

-- 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';

Eliminare i Dati

-- 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;

File di Configurazione

File di Configurazione Principali

FileScopo
$INFORMIXDIR/etc/onconfigConfigurazione principale del server
$INFORMIXDIR/etc/sqlhostsConfigurazione di rete
$INFORMIXDIR/etc/$ONCONFIGConfigurazione del root dbspace

Esempio di Parametri onconfig

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

Esempio di sqlhosts

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

Backup e Ripristino

Usare 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

Usare onbar

# Full backup
onbar -b -L 0

# Restore
onbar -r

# Verify backup
onbar -v

Ottimizzazione delle Prestazioni

Parametri Chiave della Memoria

  • SHMVIRTSIZE - Dimensione della memoria condivisa virtuale
  • SHMADD - Segmenti di memoria condivisa aggiuntivi
  • BUFFERPOOL - Configurazione della cache dei dati

Indicizzazione

-- 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;

Statistiche

-- Update table statistics
UPDATE STATISTICS FOR TABLE customers;

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