martedì 22 aprile 2014

Estrarre la struttura di una tabella con DB2

Se si vuole conoscere la struttura di una tabella per ricrearla, DB2 mette a disposizione un tool chiamato DB2LOOK.
Il programma non si trova nella cartella BIN ma nella cartella MISC.

La sintassi è la seguente : 

db2look -d DBname [-u Creator] [-s] [-g] [-a] [-t Tname1 Tname2...TnameN] [-p] [-o Fname]
db2look -d DBname [-u Creator] [-a] [-e] [-t Tname1 Tname2...TnameN] [-m] [-c] [-r] [-o Fname]
db2look [-h]

        -d: Database name. *MUST* be specified

        -a: generate stats for all creators
        -c: do not generate commit statement for mimic
        -e: extract DDL file needed to duplicate database
        -g: use graph to show fetch page pairs for indices
        -h: more detailed help message
        -m: run the program in mimic mode
        -o: output filename
        -p: use plain text format
        -r: do not generate runstats statement for mimic
        -s: generate postscript file
        -t: generate stats for the specified tables
        -u: creator ID. If -u and -a are both not specified then
            Environment variable USER will be used

Un esempio di creazione di un file di testo contenente la struttura della tabella MOVCO del database DITTA1 dell'utente db2admin è la seguente : 
DB2LOOK -d DITTA1 -t MOVCO -o C:\MOVCO.TXT -u db2admin -p -e

Nessun commento:

Posta un commento