DB2日常管理

创建视图并授权

[db2inst1@TKHEHR-DB ~]$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.7

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 =>create view TKHEHR.V_TB_INF_EMPLOYEE_PART as select * from TKHEHR.TB_INF_EMPLOYEE_PART

db2 => GRANT SELECT ON TKHEHR.V_TB_INF_EMPLOYEE_PART TO USER EHRREAD
DB20000I The SQL command completed successfully.


查看数据库节点
$ db2 list db directory

System Database Directory

Number of entries in the directory = 1

Database 1 entry:

Database alias = TKHEHR
Database name = TKHEHR
Local database directory = /hehrdta
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
连接数据库
$ db2 connect to TKHEHR

Database Connection Information

Database server = DB2/LINUXX8664 9.7.7
SQL authorization ID = DB2INST1
Local database alias = TKHEHR
当前用户下有哪些表
db2 list tables

Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
ADVISE_INDEX DB2INST1 T 2016-09-02-17.30.53.662226
ADVISE_INSTANCE DB2INST1 T 2016-09-02-17.30.53.451369
ADVISE_MQT DB2INST1 T 2016-09-02-17.30.54.449714
ADVISE_PARTITION DB2INST1 T 2016-09-02-17.32.15.256781
ADVISE_TABLE DB2INST1 T 2016-09-02-17.32.32.582638
ADVISE_WORKLOAD DB2INST1 T 2016-09-02-17.30.53.907873
EXPLAIN_ACTUALS DB2INST1 T 2016-09-02-17.34.22.280213
EXPLAIN_ARGUMENT DB2INST1 T 2016-09-02-17.30.51.608809
EXPLAIN_DIAGNOSTIC DB2INST1 T 2016-09-02-17.30.53.002681
EXPLAIN_DIAGNOSTIC_DATA DB2INST1 T 2016-09-02-17.30.53.213622
EXPLAIN_INSTANCE DB2INST1 T 2016-09-02-17.30.39.803312
EXPLAIN_OBJECT DB2INST1 T 2016-09-02-17.30.51.843793
EXPLAIN_OPERATOR DB2INST1 T 2016-09-02-17.30.51.963097
EXPLAIN_PREDICATE DB2INST1 T 2016-09-02-17.30.52.189420
EXPLAIN_STATEMENT DB2INST1 T 2016-09-02-17.30.51.153674
EXPLAIN_STREAM DB2INST1 T 2016-09-02-17.30.52.745567
16 record(s) selected.
数据库有哪些schema
db2 => select name from sysibm.sysschemata

NAME
---------------------------------------------------------
DB2INST1
EHRREAD
NULLID
ORA
SQLJ
SYSCAT
SYSFUN
SYSIBM
SYSIBMADM
SYSIBMINTERNAL
SYSIBMTS
SYSPROC
SYSPUBLIC
SYSSTAT
SYSTOOLS
TKHEHR
TKHEHRT
YOUHUA
18 record(s) selected.

猜你喜欢

转载自www.cnblogs.com/elontian/p/11272149.html
db2
今日推荐