启动
[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 ~]$