To log on to the database, follow these steps:
DB2 uses the command window to connect to the database
1. Export to a file to obtain the SQL statement
Db2look-D cqyancao-e-o dB. SQL-I db2user-W psw
Database Name to output file name username and password
Example: db2look-D department-u Walid-e-o db2look. SQL
-- This generates DDL statements for all tables and associated objects created by user Walid.
-- The db2look output is sent to a file named db2look. SQL.
Example: db2look-D department-Z myscm1-e-o db2look. SQL
-- This will generate DDL statements for all tables with the schema name myscm1
-- DDL of all associated objects created by $ user is also generated.
-- The db2look output is sent to a file named db2look. SQL.
Example: db2look-D department-u Walid-m-o db2look. SQL
-- This generates an update statement to capture statistics about the table/alias created by the user Walid.
-- The db2look output is sent to a file named db2look. SQL.
Example: db2look-D department-u Walid-e-wrapper W1-O db2look. SQL
-- This will generate DDL statements for all tables created by user Walid
-- DDL will also be generated for all Union objects created by user Walid of the package W1
-- The db2look output is sent to a file named db2look. SQL.
Example: db2look-D department-u Walid-e-server S1-O db2look. SQL
-- This will generate DDL statements for all tables created by user Walid
-- DDL for all associated objects created by user Walid of server S1 will also be generated
-- The db2look output is sent to a file named db2look. SQL.
2. Use the db2move command to export the database
To export initialization data from another database, first enter the exported directory, for example, D: \ dB,
Command: db2move dbname export-u username-P password. Note: dbname is the name of the original database, and username is the username and password is the password.
Restore command D: \ dB> db2move dbname import-u username-P Password
3. Use db2move to export and import a single table
Export db2move dbname export-Tn yc_news-u db2user-P Password
Import db2move dbname import-u db2user-P Password
4. Other problems
DB2 takes the first 10 records
For example:
DB2 => select * From tablename fetch first 10 rows only
DB2 Modify Field Length
DB2 alter table db2admin. config alter cvalue set datatype varchar (255)
For example:
DB2 = & gt; alter table news alter author set data type varchar (250)
DB2 => describe table news
Add a field in DB2
Alter table table_name
Add column column_name datatype