O exemplo a seguir usa db2_exec() para emitir um conjunto
     de instruções DDL no processo de criação de uma tabela.
    
<?php
$conn = db2_connect($database, $user, $password);
// Cria a tabela de teste
$create = 'CREATE TABLE animals (id INTEGER, breed VARCHAR(32),
    name CHAR(16), weight DECIMAL(7,2))';
$result = db2_exec($conn, $create);
if ($result) {
    print "A tabela foi criada com sucesso.\n";
}
// Preenche a tabela de teste
$animals = array(
    array(0, 'cat', 'Pook', 3.2),
    array(1, 'dog', 'Peaches', 12.3),
    array(2, 'horse', 'Smarty', 350.0),
    array(3, 'gold fish', 'Bubbles', 0.1),
    array(4, 'budgerigar', 'Gizmo', 0.2),
    array(5, 'goat', 'Rickety Ride', 9.7),
    array(6, 'llama', 'Sweater', 150)
);
foreach ($animals as $animal) {
    $rc = db2_exec($conn, "INSERT INTO animals (id, breed, name, weight)
      VALUES ({$animal[0]}, '{$animal[1]}', '{$animal[2]}', {$animal[3]})");
    if ($rc) {
        print "Insert... ";
    }
}
?>
     
    O exemplo acima produzirá:
A tabela foi criada com sucesso.
Insert... Insert... Insert... Insert... Insert... Insert... Insert...