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 statementDb2look-D cqyancao-e-o dB. SQL-I db2user-W pswDatabase 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 db
This document introduces two common methods for importing and exporting table structures in the DB2 database.
Method 1
In the object View window of the control center, select the data table of the table structure to be exported, press Ctrl or Shift to select multiple data tables, right click, and choose-> Generate DD
If you want to create a table with a known table structure in db2, you can use:
(1) create table a as select * from B where 1
(2) create table a as select * from B ---- create table a, and copy the data in
This article will introduce you to the description of how to collect statistics on various types of tables in the DB2 database for your reference. If you are interested in this, please take a look and I believe it will help you.
DB2 provides three command tools to reorganize and analyze table data:REORGCHKREORGRUNSTAT
The statistical information of objects is c
This article calls the shell script through Java code and passes in the parameter implementation DB2 the database table exports to the file, the code is as follows:Import Java.io.file;import java.io.ioexception;import java.io.inputstreamreader;import java.io.LineNumberReader; Import Java.util.HashMap; Import Org.slf4j.logger;import org.slf4j.LoggerFactory; Import Com.*.dmp.bean.agentconfiginfo;import com.*.
Db2 import and export table data 1. export the DEL Text File export to D: \ t_testtable2012121_del of del select * from T_TESTTABLE @ www.2cto.com 2. export the ixf text file. the ixf file contains the table structure. The db2 database information export to D: \ t_testtable2012121_ixf of ixf select * from T_TESTTABLE @
Label:1: Delete field non-empty propertyALTER TABLE XXX ALTER COLUMN XXX drop NOT NULLThis feature requires a version of DB2 9.0 or more2: Add field non-empty propertyALTER TABLE XXX ALTER COLUMN XXX set NOT NULL3: Add a new fieldALTER TABLE XXX add column XXXX varchar (100)4: Delete a fieldALTER
Label:Now there is a row of data, to be copied to multiple lines, each row only two field values are different, DB2 no SQL Server top keyword, the only want to copy a few times, and then update the data, found no.Then think of a temporary create a table B, insert this row of data, and then constantly modify B and then insert a.DB2 Copy Table structure:CREATE
DB2 Build Table:
Create table Tab_name (
field 1 type not null/default value
)
Change the type or length of a field in a table:
Alter TABLE Tab_name
alter COLUMN todolist SET DATA TYPE
simple to delete and change:
Add an article:
INSERT into Tab_name (C1
Db2 xml to table Version: DB2 Version 9.1 1. Create a test table and initialize data
create table emp (doc XML);INSERT INTO EMP VALUES ('
2. Use the xmltable method to convert xml format data to a temporary table
?SELECT X.* FROM
DB2 SQL0668N Operation not allowed for reason code "7" on table code instance, db2sql0668nDB2 SQL0668N Operation not allowed for reason code "7" on table code instance
db2 => select count(*) from db2admin.test_tab1 -----------SQL0668N Operation not allowed for reason code "7" on
match the pagesize of the table. Then, the maintenance personnel can use the statements used to create the table space in the original DB2 to refer to creating their own new table space. Use db2look-d $ dbname-l-e-x-o $ db. Layout
In this way, you can view dB. layout to copy some parameters of the originally create
test: with Oozie, execute Sqoop action to import data from DB2 into the Hive partition table. Places to be aware of:1, to add hive.metastore.uris this parameter. Otherwise, the data cannot be loaded into the hive table. Also, if there is more than one such operation in an XML literal, this parameter needs to be configured in each action.2, be aware of the escape
Label:>[Error] Script line: 1-1---------------------------------------"STATUS" is not valid in the context where it is used. sqlcode=-206, sqlstate=42703, driver=3.53.71More exceptions ... An error occurred during implicit system action type "2". Information returned for the error includes SQLCODE " -206", SQLSTATE "42703" and Message Tokens "STATUS": sqlcode=-727, sqlstate=56098, driver=3.53.71This error is always reported when executing the SQL text because:In
The following articles mainly introduce the DB2 database lock table problem. In actual operations, if the center queries data, pay attention to it. If interactive data query is used, the command center will apply the s lock to the queried records. at this time, if you want to update the record, because update requires the x lock, the exclusive lock will be in the lock wait.
First, enable the monitoring swi
How to obtain the details of a user table in DB2
1. Get the User Name of the current user
SELECT CURRENT SCHEMA FROM SYSIBM.SYSDUMMY1
2. Obtain the names of all tables under a user.
Select creator, TYPE, NAME, remarks from sysibm. Variables Ables where type = 'T' and creator = 'username' -- case sensitive
3. Obtain the details of a table under the current user.
---- Start
Temporary tables are usually used to define temporary sets. However, when most temporary sets are required, we do not need to define temporary tables. When we use only one temporary set in an SQL statement, we can useNested table expressionsTo define a temporary set. When we need to use the same temporary set multiple times in an SQL statement, we can useCommon table expressionsThe temporary
Issue: In the DB2 database, if you modify the structure of the table, you need to do a reorg operation on the table to get the table state back to normal.
A: There are 4 kinds of operations, you need to do reorg operation of the table
1.) SET DATA TYPE Altered-data-type
How
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.