DB2 UDB V8.1 Management Learning Notes (ii) _DB2

Source: Internet
Author: User
Tags db2 db2 client db2 connect db2 connect to numeric value
The DB2 tutorial being looked at is: DB2 UDB V8.1 Management Learning Notes (ii). Table space types are divided into SMS and DMS, respectively, system management spaces, database management. SMS is easy and easy to use and eliminates the need to manually create and maintain data storage files. The DMS needs to manually specify the file name of the container and stored data, and ensure that sufficient disk space is available.
For a database, there is at least one temporary tablespace with a page size of 4K, and additional user temporary tablespace space with a larger page size can be created, and the system will be used automatically.
You cannot change the data type of a field with an ALTER statement, and you can change the length of the data for some fields, which is more restrictive than ORACLE,DB2.
Can be used: select expression from Sysibm.sysdummy; Instead, the following statements are equivalent: values expressions;
The creation, updating, and deletion of tables and views are all written in log, so you can commit or rollback them.
In the UPDATE statement, if you do not explicitly assign a value to a field that has a default value defined, the field does not rerun the expression defined in the default value when the update is updated. In order for it to perform the expression of the default value definition again, the following methods can be used:
CREATE TABLE T1 (C1 varchar (), lastupdatetime with default current timpstamp); update T1 Set c1 = ' new string ', Lastupdat ETime = default;
For DB2 databases, you can specify codepage parameters at creation time, and cannot be modified after creation. When the application accesses the database, DB2 compares the codepage of the two to the same, and does the automatic conversion of the code page if it is inconsistent. To reduce the overhead of conversion, you should try to ensure that the code pages used by your application are consistent with the database.
You can set the codepage of the DB2 CLP tool to use:
$ db2set db2codepage= 1386
This example sets the value of the Chinese GBK character set on the Windows platform. Note that this numeric value is defined by DB2 itself. The code page values for the various character sets on the corresponding platform can be found on the IBM Web site.
In the DB2 CLP, the operation of cataloging remote databases first maps the remote host to a local node, and the section names itself, and this example uses a TCPIP connection. SERVICE_NAME is generally defined in the/etc/services file of the remote host.
$ DB2 CATALOG TCPIP NODE local_node_name REMOTE hostname|ip SERVER service_name
The database of a known remote host is then mapped to a local alias, noting that local aliases cannot be duplicated at the host level. section name specifies the node just cataloged above.
$ DB2 CATALOG DATABASE db_name as Local_alias at Local_node_name USER username USING password
You can now connect to the remote host database with the alias defined in the catalog just described
$ DB2 CONNECT to Local_alias USER username USING password
Get Database Detail configuration information
$ DB2 get CONFIGURATION show DETAIL
For the error number returned by DB2, you can use the following methods to refer to the description (for example, SQL 10008):
$ DB2? sql10008
Database Backup and Recovery:
The Backup and Recovery tool enables you to complete the transfer of databases across different servers by using the following command-line methods:
Backup
$ DB2 BACKUP DATABASE db_name USER user_name using password to backup_dir_name$ DB2 BACKUP database dlhdb USER DLH USING A DMINDLH to D:\backups
Recovery
$ DB2 RESTORE DATABASE source_db_name USER user_name USING password from backup_dir_name to taken at Backup_file_create_time To Driver_letter in new_db_name$ DB2 RESTORE DATABASE dlhdb USER dlh USING admindlh from d:\backups taken at 20031209141 056 to D:into newdb
Action on an instance:
Setting the default instance environment variable
$ DB2 SET Db2instance=inst_name
Start the current instance
$ db2start
Stop current instance
$ db2stop [Force]
Connect to an instance
$ DB2 ATTACH to Anstance Inst_name
Get configuration parameters for an instance
$ DB2 Get DBM CFG show DETAIL
Export database complete definition to script files, including tables, views, functions, database parameters, etc.
$ db2look-d Sample (database)-a-e-l-x-m-f-O (parameter) samplesql.out (output file)
When you load a table's data, it is possible to cause the tablespace to be in the backup pending (0x0020) state. For example, to load the plastic data into a double type field.
Table spaces in the backup pending state cannot be accessed.
You can revert to the normal state (0x0) by running a backup operation on this tablespace.
For a self-added field, you can specify two ways:
Generated by default as identitygenerated always as identity
The difference is that the first way to insert data allows you to manually specify the value of the self added field, as long as it is not repeated, and the database automatically sets the next value;
The second method does not allow the designation and can only be automatically allocated and inserted by the database.
DB2 the use of the SQL statement relay semantics:
SELECT * from T1 where a like '%abc\%def ' escape ' \ ';
A sql1043c error occurred while creating the database, possible problems:
The specified container is low on disk space.
When the container is a file type, the following long-num parameter is incorrect, such as 25600 for 256Mb, but if 256 is specified, the above error is caused.
Platform RH Linux 8
DB2 UDB v8.1
The data source to DB2 was established in was 5, but the connection failed, and the following error was returned:
[Servlet Error]-[sqlconnect]: java.lang.UnsatisfiedLinkError:SQLConnect
The reason is no

[1] [2] Next page

The DB2 tutorial being looked at is: DB2 UDB V8.1 Management Learning Notes (ii). Set the following environment variables for the user running the was service:
D_library_pathlibpathdb2instance ...
The above environment variables are defined in the $INSTHOME/sqllib/db2profile file and can be used in the solution:
$ sh stopserver.sh servername$. $INSTHOME/sqllib/db2profile$ SH startserver.sh servername
You can also place the Db2profile in the was startup script first.
If you set only the Ld_library_path,libpath two environment variables, DB2 returns the following error:
cli0600e Invalid connection handle or connection is closed. SQLSTATE S1000
Corresponding to Oracle's job package functionality, DB2 is implemented through a GUI tool-task center. You need to make the necessary tool settings before using the task center, you need to create some database objects that you can create in an existing database, or you can create a separate database. Implement the following command:
Create catalog Tools schema_name Create new Database db_name
This command creates a database named Db_name for the Catalog tool and specifies a schema name.
Note: You cannot specify a codeset with a using clause, and the iso8859-1 character set is used by default.
Quest Center for DB2 features database performance diagnostics, dynamic monitoring of DB memory, disk IO, tablespace, load, and so on.
Type of DB2 client:
DB2 Runtime clients DB2 Runtime Client
DB2 manages clients DB2 Administrator Client (contains all content of the Run-time client)
DB2 Application Development Client DB2 Application Development client (contains all content for managing clients)
DB2 Thin clients DB2 Thin Client
DB2 Relational Connect federated database, used to connect heterogeneous databases.

prev [1] [2]

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.