Você está na página 1de 4

By: BGK (AbInitio Developer)

m_db
This command is used for performing database operation from the command prompt.
The basic command is m_db. It is invoked as follows:
m_db command [ options ]
To get a (very long) usage statement, use this:
m_db -help
Following are the few m_db commands that are used frequently:

m_db gendml:
Generates appropriate metadata for the specified table or select statement or table expression:
m_db gendml dbc_file [ options ] -table tablename
m_db gendml dbc_file [ options ] -select 'sql-select-statement'
m_db gendml dbc_file [ options ] -insert 'sql-insert-statement'
m_db gendml dbc_file [ options ] -tables texpr [ options2 ]
m_db gendml dbc_file [ options ] -views texpr [ options2 ]
m_db gendml dbc_file [ options ] -aliases texpr [ options2 ]
m_db gendml dbc_file [ options ] -all_objects texpr [ options2 ]
Example:
m_db gendml mydb.dbc -table edw.exg_rate' Generate dml of exg_rate table in edw schema
m_db gendml mydb.dbc -tables '*' Generate dmls of all the tables in a database
m_db gendml mydb.dbc -tables 'basel.*' generate dmls of all the tables in Basel schema.

m_db test:
Runs diagnostic tests against your database for the specified .dbc file:
Syntax:
m_db test dbc_file
Examples
m_db test mydb.dbc
m_db test mydb.dbc -diff -catalog_queries -tables '*.*'

m_db unload:
Unloads data from database table, select or expression to stdout:

By: BGK (AbInitio Developer)


m_db
m_db
m_db
m_db
m_db
m_db

unload
unload
unload
unload
unload
unload

dbc_file
dbc_file
dbc_file
dbc_file
dbc_file
dbc_file

[options]
[options]
[options]
[options]
[options]
[options]

-table tablename
-select 'sql-select-statement'
-tables texpr [options2]
-views texpr [options2]
-aliases texpr [options2]
-all_objects texpr [options2]

Examples
m_db unload mydb.dbc -table 'fred.mytable'
Heres how to use m_db unload to strip or replace the column delimiters from returned data:
m_db unload mydb.dbc -column_delimiter '' -select "select foo from bar"

m_db load:
Using api mode (only), loads data to a database table or insert statement from standard input or a file or a string:
m_db load dbc_file -dml 'metadata-string' -table tablename [ -data string || -data_file filename ]
m_db load dbc_file -dml_file dml-filename -table tablename [ -data string || -data_file filename ]
m_db load dbc_file -dml 'metadata-string' \
-insert 'sql-insert-statement' [ -data string || -data_file filename ]
m_db load dbc_file -dml_file dml-filename \
-insert 'sql-insert-statement' [ -data string || -data_file filename ]
Where -data string specifies the data as a string on the command line, and -data_file filename specifies a file that contains the data.
You can also specify the -binmode flag with this command. -binmode is useful on Windows only: it prevents \r\n being converted to \n.

m_db truncate:
Truncates the given table:
m_db truncate dbc_file -table tablename

m_db run
Runs SQL (specified either as a string or from a file) against a database:
m_db run dbc_file -sql 'sql-string'
m_db run dbc_file -sqlfile filename [ -ignore_drop_table_errors ]
Example
m_db run mydb.dbc \

By: BGK (AbInitio Developer)


-sql 'create table foo (a char(5))'

m_db list
To list all users in the database:
m_db list dbc_file -owners
To list the default database user you are connected as:
m_db list dbc_file -user
To list all tables for a table expression (texpr can be '*'):
m_db list dbc_file [ options ] -tables texpr
To list all views for a table expression:
m_db list dbc_file [ options ] -views texpr
To list all aliases for a table expression:
m_db list dbc_file [ options ] -aliases texpr

m_db create_commit_table
Creates a commit table (used by the Update Table component):
m_db create_commit_table dbc_file \
-table commit_tablename \
-index index_name \
[ -drop ] [ -print_ddl ]

m_db create
Creates a database table defined by DDL equivalent to the metadata-string, or the contents of dml-file.
If the table already exists, an error will be returned unless the -existence_ok flag is supplied.
m_db create dbc_file -dml 'metadata-string' \
-table tablename \
[-existence_ok]
m_db create dbc_file -dml_file dml-file \
-table tablename \
[-existence_ok]

By: BGK (AbInitio Developer)


Note that the DDL generated using the m_db create command (or using the Create if Table Does Not Exist Access option of the Output Table component)
is meant only to be a quick way of generating approximate table descriptions for testing and demonstration purposes.
To create permanent tables within a database, you should write a Create Table SQL statement that describes the table exactly. If you would like to create a
table within a graph, you can use a Run SQL component to run the Create Table statement.
The following command (executed against an Oracle database) will create an empty table whose record definition will be as defined in the DML file:
m_db create my_oracle_config.dbc \ -dml_file test.dml -table test_table

Você também pode gostar