Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

DB_ATTRIBUTE

Represents the attribute information of a class for which the current user has access authorization in the database.

Attribute Name

Data Type

Description

attr_name

VARCHAR(255)

Attribute name

class_name

VARCHAR(255)

Name of the class to which the attribute belongs

attr_type

VARCHAR(8)

‘INSTANCE’ for an instance attribute, ‘CLASS’ for a class attribute, and ‘SHARED’ for a shared attribute.

def_order

INTEGER

Order of attributes in the class. Begins with 0. If the attribute is inherited, the order is the one defined in the super class.

from_class_name

VARCHAR(255)

If the attribute is inherited, the super class in which it is defined is used. Otherwise, NULL

from_attr_name

VARCHAR(255)

If the attribute is inherited and its name is changed to resolve a name conflict, the original name defined in the super class is used. Otherwise, NULL

data_type

VARCHAR(9)

Data type of the attribute (one in the "Meaning" column of the "Data Types Supported by CUBRID" table in _db_attribute)

prec

INTEGER

Precision of the data type. 0 is used if the precision is not specified.

scale

INTEGER

Scale of the data type. 0 is used if the scale is not specified.

code_set

INTEGER

Character set (value of table "character sets supported by CUBRID" in  _db_attribute) if it is string type. 0 otherwise.

domain_class_name

VARCHAR(255)

Domain class name if the data type is an object. NULL otherwise.

default_value

VARCHAR(255)

Saved as a character string by default, regardless of data types. If no default value is specified, NULL is stored if a default value is NULL, it is displayed as 'NULL'. An object data type is represented as 'volume id | page id | slot id' while a set data type is represented as '{element 1, element 2, ... '.

is_nullable

VARCHAR(3)

'NO' if a not null constraint is set, and 'YES' otherwise.

Definition

CREATE VCLASS db_attribute (

attr_name, class_name, attr_type, def_order, from_class_name, from_attr_name, data_type, prec, scale, code_set, domain_class_name, default_value, is_nullable)

AS

SELECT a.attr_name, c.class_name,

            CASE WHEN a.attr_type = 0 THEN 'INSTANCE'

                      WHEN a.attr_type = 1 THEN 'CLASS'

                      ELSE 'SHARED' END,

            a.def_order, a.from_class_of.class_name, a.from_attr_name, t.type_name,

            d.prec, d.scale, d.code_set, d.class_of.class_name, a.default_value,

            CASE WHEN a.is_nullable = 0 THEN 'YES' ELSE 'NO' END

FROM _db_class c, _db_attribute a, _db_domain d, _db_data_type t

WHERE a.class_of = c AND d.object_of = a AND d.data_type = t.type_id AND

              (CURRENT_USER = 'DBA' OR

              {c.owner.name} subseteq (

                              SELECT set{CURRENT_USER} + coalesce(sum(set{t.g.name}), set{})

                              from db_user u, table(groups) as t(g)

                              where u.name = CURRENT_USER ) OR

              {c} subseteq (

SELECT sum(set{au.class_of})

                              FROM _db_auth au

                              WHERE {au.grantee.name} subseteq (

                                                      SELECT set{CURRENT_USER} + coalesce(sum(set{t.g.name}), set{})

                                                      from db_user u, table(groups) as t(g)

                                                      where u.name = CURRENT_USER ) AND

                                                                      au.auth_type = 'SELECT'))

Example 1

The following example shows how to retrieve attributes and data types of the event class.

SELECT attr_name, data_type, domain_class_name

FROM db_attribute

WHERE class_name = 'event'

ORDER BY def_order;

  attr_name             data_type             domain_class_name

==================================================================

  'code'                'INTEGER'             NULL

  'sports'              'STRING'              NULL

  'name'                'STRING'              NULL

  'gender'              'CHAR'                NULL

  'players'             'INTEGER'             NULL

Example 2

The following example shows how to retrieve attributes of the female_event class and its super class.

SELECT attr_name, from_class_name

FROM db_attribute

WHERE class_name = 'female_event'

ORDER BY def_order;

  attr_name             from_class_name

============================================

  'code'                'event'

  'sports'              'event'

  'name'                'event'

  'gender'              'event'

  'players'             'event'

Example 3

The following example shows how to retrieve classes whose attribute names are similar to name, among the ones owned by the current user. (The user is PUBLIC.)

SELECT a.class_name, a.attr_name

FROM db_class c join db_attribute a ON c.class_name = a.class_name

WHERE c.owner_name = CURRENT_USER AND attr_name like '%name%'

ORDER BY 1;

  class_name            attr_name

============================================

  'athlete'             'name'

  'code'                'f_name'

  'code'                's_name'

  'event'               'name'

  'female_event'        'name'

  'nation'              'name'

  'stadium'             'name'