db2 创建数据库步骤详解

启动

[root@localhost ~]# su - db2inst1
[db2inst1@localhost ~]$ db2start

SQL8007W  There are "13" day(s) left in the evaluation period for the product 
"DB2 Connect Server". For evaluation license terms and conditions, refer to 
the License Agreement document located in the license directory in the 
installation path of this product. If you have licensed this product, ensure 
the license key is properly registered. You can register the license via the 
License Center or db2licm command line utility. The license key can be 
obtained from your licensed product CD.
SQL1063N  DB2START processing was successful.
[db2inst1@localhost ~]$ 

创建数据库

[db2inst1@localhost ~]$ db2 create database hibernate;
SQL1001N  "hibernate" is not a valid database name.  SQLSTATE=2E000

数据库名字应该是1-8个字符

[db2inst1@localhost ~]$ db2 create database hiber;
DB20000I  The CREATE DATABASE command completed successfully.

列出数据库

[db2inst1@localhost ~]$ db2 list db directory

 System Database Directory

 Number of entries in the directory = 3

Database 1 entry:

 Database alias                       = TESTDB
 Database name                        = TESTDB
 Local database directory             = /home/db2inst1-m
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 2 entry:

 Database alias                       = HIBER
 Database name                        = HIBER
 Local database directory             = /home/db2inst1-m
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 3 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = /home/db2inst1-m
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

[db2inst1@localhost ~]$

连接数据库

[db2inst1@localhost ~]$ db2 connect to hiber;

   Database Connection Information

 Database server        = DB2/LINUX 9.7.6
 SQL authorization ID   = DB2INST1
 Local database alias   = HIBER

[db2inst1@localhost ~]$

列出表

[db2inst1@localhost ~]$ db2 list tables;

Table/View                      Schema          Type  Creation time             
------------------------------- --------------- ----- --------------------------

  0 record(s) selected.

[db2inst1@localhost ~]$

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

auspicious航

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值