掌控 DB2:常用命令精粹

连接数据库

  • db2 CONNECT TO database_name USER username USING password

数据库操作

  • db2 CREATE DATABASE database_name
  • db2 DROP DATABASE database_name
  • db2 LIST DATABASE DIRECTORY
  • db2 BACKUP DATABASE database_name
  • db2 RESTORE DATABASE database_name

表操作

  • db2 CREATE TABLE table_name (column_name data_type, ...)
  • db2 ALTER TABLE table_name ADD COLUMN column_name data_type
  • db2 DROP TABLE table_name
  • db2 LIST TABLES

数据操作

  • db2 INSERT INTO table_name (column_name, ...) VALUES (value1, ...)
  • db2 UPDATE table_name SET column_name = value WHERE condition
  • db2 DELETE FROM table_name WHERE condition
  • db2 SELECT column_name, ... FROM table_name WHERE condition

其他常用命令

  • db2 GET DB CFG FOR database_name
  • db2 UPDATE DB CFG FOR database_name USING parameter value
  • db2 FORCE APPLICATION ALL
  • db2 LIST APPLICATIONS
  • db2 TERMINATE
  • db2 ? (获取帮助)