DB2 入門命令練習(一)
建立一個新的資料庫
[db2inst1@xttdb ~]$ db2 "create database test02 using codeset utf-8 territor
y CN"
DB20000I The CREATE DATABASE command completed successfully.
檢視資料庫資訊
[root@xttdb expc]# db2 list database directory
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = TEST01
Database name = TEST01
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 2 entry:
Database alias = TEST02
Database name = TEST02
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
連線資料庫
[db2inst1@xttdb ~]$ db2 connect to test02
Database Connection Information
Database server = DB2/LINUX 10.1.0
SQL authorization ID = DB2INST1
Local database alias = TEST02
檢視所有連線資訊
[db2inst1@xttdb ~]$ db2 list application
Auth Id Application Appl. Application Id DB # of
Name Handle Name Agents
-------- -------------- ---------- -------------------------------------------------------------- -------- -----
ROOT db2bp 98 *LOCAL.db2inst1.150119163417 TEST02 1
DB2INST1 db2bp 108 *LOCAL.db2inst1.150119163649 TEST02 1
關閉db2資料庫
在有連線的時候直接關閉db2會提示有其他連線存在
[db2inst1@xttdb ~]$ db2stop
SQL1025N The database manager was not stopped because databases are still active.
斷開所有的連線
[db2inst1@xttdb ~]$ db2 force application all
DB20000I The FORCE APPLICATION command completed successfully.
DB21024I This command is asynchronous and may not be effective immediately.
再次關閉資料庫即可
[db2inst1@xttdb ~]$ db2stop
SQL1064N DB2STOP processing was successful.
開啟資料庫
[db2inst1@xttdb ~]$ db2start
SQL1063N DB2START processing was successful.
刪除資料庫
[db2inst1@xttdb ~]$ db2 drop db test01
DB20000I The DROP DATABASE command completed successfully.
[db2inst1@xttdb ~]$ db2stop
SQL1064N DB2STOP processing was successful.
[db2inst1@xttdb ~]$ db2 list database directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = TEST02
Database name = TEST02
Local database directory = /home/db2inst1
Database release level = f.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
檢視幫助資訊
[root@xttdb expc]# db2 ? SQL1092N
SQL1092N The requested command or operation failed because the user ID
does not have the authority to perform the requested command or
operation. User ID: "
Explanation:
Authentication of a user is completed using a security facility outside
of the DB2 database system (part of the operating system or a separate
product.) Authorization is performed using DB2 facilities (using DB2
tables and configuration files.) This message can be returned when there
is a problem with either authentication or authorization.
[root@xttdb expc]# db2 ? restore
RESTORE DATABASE source-db-alias { restore-options | CONTINUE | ABORT }
restore-options:
[USER username [USING password]]
[Restore-Inventory-Clause] [INCREMENTAL [AUTOMATIC | ABORT]]
[Media-Target-Clause] [TAKEN AT date-time]
[[TO target-directory] | [ON path [{,path}...] [DBPATH ON path]]]
[TRANSPORT [STAGE IN staging-db-alias] [USING STOGROUP stogroup-name]]
[INTO target-db-alias] [LOGTARGET {directory | {{INCLUDE | EXCLUDE} [FORCE]}}]
[NEWLOGPATH directory] [WITH num-buff BUFFERS] [BUFFER buffer-size]
[REPLACE HISTORY FILE] [REPLACE EXISTING]
[REDIRECT [GENERATE SCRIPT file-name]] [PARALLELISM n] [COMPRLIB lib-name]
[COMPROPTS options-string] [WITHOUT ROLLING FORWARD]
[WITHOUT PROMPTING]
建立表
[db2inst1@xttdb ~]$ db2
db2 => connect to test02
Database Connection Information
Database server = DB2/LINUX 10.1.0
SQL authorization ID = ROOT
Local database alias = TEST02
db2 => list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
0 record(s) selected.
db2 => create table test_tab(id varchar(100),name varchar(100))
DB20000I The SQL command completed successfully.
db2 => commit
DB20000I The SQL command completed successfully.
db2 => list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
TEST_TAB ROOT T 2015-01-20-01.08.03.470497
1 record(s) selected.
列出表空間資訊
db2 => list tablespaces
Tablespaces for Current Database
Tablespace ID = 0
Name = SYSCATSPACE
Type = Database managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal
Tablespace ID = 1
Name = TEMPSPACE1
Type = System managed space
Contents = System Temporary data
State = 0x0000
Detailed explanation:
Normal
Tablespace ID = 2
Name = USERSPACE1
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
Tablespace ID = 3
Name = SYSTOOLSPACE
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29320885/viewspace-1409185/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DB2 入門命令練習(二)DB2
- 入門練習
- db2入門學習DB2
- sql查詢入門練習題SQL
- CAD入門級練習題
- 入門MySQL——查詢語法練習MySql
- 英語口語練習--職業入門篇
- Find命令練習
- 慕課網Python入門練習題---Python
- mysql 基礎命令入門學習MySql
- db2 入門常用操作DB2
- Docker 入門系列一:docker 命令Docker
- [MySQL光速入門]008 SQL強化練習MySql
- 遊戲關卡設計如何入門和練習?遊戲
- 編譯器背後的故事(入門練習)編譯
- C語言入門級練習(敲程式碼)C語言
- leaflet學習一 入門
- MyBatis入門學習(一)MyBatis
- 一次DB2 DR演練DB2
- [MySQL光速入門]009 SQL強化練習答案MySql
- java入門第三季6-5練習Java
- Oracle入門查詢練習題及參考答案Oracle
- Redis入門及常用命令學習Redis
- 21 個 curl 命令練習
- Redis 命令練習彙總Redis
- Pytorch入門演練PyTorch
- find 命令入門
- Egg入門學習(一)
- 【mybatis學習之入門(一)】MyBatis
- ReactJS入門學習一ReactJS
- JAVA入門第二季4-2練習Java
- Linux系統入門命令學習經驗Linux
- Linux入門學習(1基礎操作命令)Linux
- git入門到熟練使用Git
- ElasticSearch7.6 入門學習(一)Elasticsearch
- webpack入門學習手記(一)Web
- JavaScript入門-學習筆記(一)JavaScript筆記
- JDK學習基礎入門(一)JDK