db2 入門常用操作
1、 連線資料庫
[db2inst1@zhanglin-db2 ~]$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.4
You can issue database manager commands and SQL statements from the command
prompt. For example:
db2 => connect to sample
db2 => bind sample.bnd
For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
? CATALOG DATABASE for help on the CATALOG DATABASE command
? CATALOG for help on all of the CATALOG commands.
To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.
For more detailed help, refer to the Online Reference Manual.
db2 => connect to mydb
Database Connection Information
Database server = DB2/LINUXX8664 9.7.4
SQL authorization ID = DB2INST1
Local database alias = MYDB
db2 =>
2、建立表空間
db2 => create tablespace zhang
DB20000I The SQL command completed successfully.
3、顯示錶空間
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
Tablespace ID = 4
Name = ZHANG
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
4、刪除表空間
db2 => drop tablespaces zhang
DB20000I The SQL command completed successfully.
db2 =>
5、 建立表
db2 => create table test(id int,name varchar(20))
DB20000I The SQL command completed successfully.
6、插入記錄
db2 => insert into test values(1,'zhanglin')
DB20000I The SQL command completed successfully.
db2 => insert into test values(2,'db2')
DB20000I The SQL command completed successfully.
db2 => insert into test values(3,'zhangsan')
DB20000I The SQL command completed successfully.
7、查詢表記錄
db2 => select * from test
ID NAME
----------- --------------------
1 zhanglin
2 db2
3 zhangsan
3 record(s) selected.
db2 =>
8、刪除操作
db2 => delete from test where id=3
DB20000I The SQL command completed successfully.
db2 => delete from test where id=2
DB20000I The SQL command completed successfully.
db2 => select * from test
ID NAME
----------- --------------------
1 zhanglin
1 record(s) selected.
9、更新操作
db2 => update test set name='zhang-db2' where id=1
DB20000I The SQL command completed successfully.
db2 => select * from test
ID NAME
----------- --------------------
1 zhang-db2
1 record(s) selected.
db2 =>
10、刪除表
db2 => drop table test
DB20000I The SQL command completed
successfully.
db2 =>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30936525/viewspace-2018445/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 小白入門使用Nginx基礎的常用操作Nginx
- db2入門學習DB2
- Python入門(五):Python常用操作運算子Python
- Linux入門教程之sed 命令常用操作介紹Linux
- Docker 入門操作Docker
- git 入門操作Git
- DB2 入門命令練習(二)DB2
- DB2 入門命令練習(一)DB2
- jQuery入門-DOM操作jQuery
- SQLite入門操作(一)SQLite
- sap入門--操作指南
- midjourney 入門操作
- [PowerShell] 快速入門, 基本語法, 常用型別, 函式, .NET 互操作型別函式
- Linux運維,到底如何入門?常用linux操作指令盤點!Linux運維
- 入門級的Git操作Git
- Docker | 入門 & 基礎操作Docker
- nodejs 入門基本操作NodeJS
- JavaScript入門⑦-DOM操作大全JavaScript
- Docker 入門(Mac環境)-part 1 入門基本操作DockerMac
- 【Redis入門】常用工具Redis
- 常用的DB2命令DB2
- python 檔案操作入門Python
- Redis 入門 - 1(基本 key 操作)Redis
- OpenStack入門之實際操作
- BCSphere入門教程02:操作 Characteristic
- msysgit——Git bash 入門操作流程Git
- WPF 入門筆記 - 01 - 入門基礎以及常用佈局筆記
- Java入門:Lambda常用表示式解析Java
- 入門資料分析選擇Python還是SQL?七個常用操作對比PythonSQL
- Oracle - 匯入匯出常用操作語句Oracle
- openCV入門 核心操作 1 影像的基礎操作OpenCV
- DB2常用命令DB2
- 常用的DB2管理命令DB2
- db2 常用命令DB2
- DB2常用指令集合DB2
- Docker入門系列(二)--docker操作命令Docker
- UNIX 系統操作入門(三)(轉)
- UNIX 系統操作入門(二)(轉)