GBase 8s 在您创建数据库时自动生成系统目录表。可以如同查询数据库中的任何其他表那样查询系统目录表。新创建的数据库的系统目录表位于称为数据库空间的公共磁盘区域中。每个数据库都有它自己的系统目录表。系统目录中的所有表和视图都有前缀 sys(例如:系统目录表 systables)。
数据库服务器经常访问系统目录。每次处理 SQL 语句时,数据库服务器都会访问系统目录来确定系统特权、添加或验证表或列名等等。
CREATE SCHEMA AUTHORIZATION maryl CREATE TABLE customer (customer_num SERIAL(101), fname CHAR(15), lname CHAR(15), company CHAR(20), address1 CHAR(20), address2 CHAR(20), city CHAR(15), state CHAR(2), zipcode CHAR(5), phone CHAR(18)) GRANT ALTER, ALL ON customer TO cathl WITH GRANT OPTION AS maryl GRANT SELECT ON customer TO public GRANT UPDATE (fname, lname, phone) ON customer TO nhowe CREATE VIEW california AS SELECT fname, lname, company, phone FROM customer WHERE state = 'CA' CREATE UNIQUE INDEX c_num_ix ON customer (customer_num) CREATE INDEX state_ix ON customer (state)
列名 | 第一行 | 第二行 |
---|---|---|
tabname | customer | california |
owner | maryl | maryl |
partnum | 16778361 | 0 |
tabid | 101 | 102 |
rowsize | 134 | 134 |
ncols | 10 | 4 |
nindexes | 2 | 0 |
nrows | 0 | 0 |
created | 01/26/2007 | 01/26/2007 |
version | 1 | 0 |
tabtype | T | V |
locklevel | P | B |
npused | 0 | 0 |
fextsize | 16 | 0 |
nextsize | 16 | 0 |
flags | 0 | 0 |
site | ||
dbname |
colname | tabid | colno | coltype | collength | colmin | colmax |
---|---|---|---|---|---|---|
customer_num | 101 | 1 | 262 | 4 | ||
fname | 101 | 2 | 0 | 15 | ||
lname | 101 | 3 | 0 | 15 | ||
company | 101 | 4 | 0 | 20 | ||
address1 | 101 | 5 | 0 | 20 | ||
address2 | 101 | 6 | 0 | 20 | ||
city | 101 | 7 | 0 | 15 | ||
state | 101 | 8 | 0 | 2 | ||
zipcode | 101 | 9 | 0 | 5 | ||
phone | 101 | 10 | 0 | 18 | ||
fname | 102 | 1 | 0 | 15 | ||
lname | 102 | 2 | 0 | 15 | ||
company | 102 | 3 | 0 | 20 | ||
phone | 102 | 4 | 0 | 18 |
在 syscolumns 表中,对表中的每个列都指定一个顺序列号 colno,它在列所在的表中唯一地标识该列。在 colno 列中,对 customer 表的 fname 列指定值 2,并对视图 california 的 fname 列指定值 1。
colmin 和 colmax 列是空的。当某一列是索引中的第一个键(或唯一的键)且没有 NULL 值或重复值,并且已运行 UPDATE STATISTICS 语句时,这些列就会包含值。
数据库服务器还将行添加至 sysviews 系统目录表中,该表的 viewtext 列包含定义视图的 CREATE VIEW 语句的每一行。该列中,在语句中列名前面的 x0(例如:x0.fname)起别名的作用,用来区分在自连接中使用的相同列。
grantor | grantee | tabid | tabauth |
---|---|---|---|
maryl | public | 101 | su-idx-- |
maryl | cathl | 101 | SU-IDXAR |
maryl | nhowe | 101 | --*----- |
maryl | 102 | SU-ID--- |
tabauth 列指定授予用户的对 customer 和 california 表的表级别特权。此列使用 8 字节模式(如 s(选择)、u(更新)、*(列级别特权)、i(插入)、d(删除)、x(索引)、a(改变)和 r(引用))来标识特权的类型。在此示例中,用户 nhowe 具有对 customer 表的列级别特权。连字符 (-) 表示未向用户授予 tabauth 值中由连字符占据其位置的特权。
如果 tabauth 特权代码是大写的(例如,表示 Select 的 S),那么用户具有此特权,并可将该特权授予他人;但是,如果特权代码是小写的(例如:表示 Select 的 s),那么用户不能将该特权授予他人。
grantor | grantee | tabid | colno | colauth |
---|---|---|---|---|
maryl | nhowe | 101 | 2 | -u- |
maryl | nhowe | 101 | 3 | -u- |
maryl | nhowe | 101 | 10 | -u- |
colauth 列指定对 customer 表授予的列级别特权。此列使用 3 字节模式(如 s (Select)、u (Update) 和 r (References))来标识特权类型。例如:用户 nhowe 具有对 customer 表(由 tabid 值 101 指示)的第二个列(因为 colno 值是 2)的 Update 特权。
idxname | c_num_ix | state_ix |
---|---|---|
owner | maryl | maryl |
tabid | 101 | 101 |
idxtype | U | D |
集群 | ||
part1 | 1 | 8 |
part2 | 0 | 0 |
part3 | 0 | 0 |
part4 | 0 | 0 |
part5 | 0 | 0 |
part6 | 0 | 0 |
part7 | 0 | 0 |
part8 | 0 | 0 |
part9 | 0 | 0 |
part10 | 0 | 0 |
part11 | 0 | 0 |
part12 | 0 | 0 |
part13 | 0 | 0 |
part14 | 0 | 0 |
part15 | 0 | 0 |
part16 | 0 | 0 |
levels | ||
leaves | ||
nunique | ||
clust | ||
idxflags |
在此表中,idxtype 列标识创建的索引是需要唯一值 (U) 还是接受重复的值 (D)。例如:customer.customer_num 列的 c_num_ix 索引是唯一的。