SQL support for dynamic schema

本文介绍了eXtremeDB对于动态数据库模式的有限支持,包括如何使用mcoddl模块实现动态模式,以及在执行CREATE TABLE语句时如何更新数据库字典。动态模式需要预先指定数据库中类和索引的最大数量以及字典的最大大小。创建表的语法和各种数据类型也被详细说明。虽然ALTER TABLE和DROP TABLE语句受到限制,但可以通过版本控制来实现类似的功能。
摘要由CSDN通过智能技术生成
Implementation overview
eXtremeSQL provides limited support for the dynamic database schema. The dynamic schema is implemented using the mcoddl module and requires specifying limits for the maximum number of classes and indexes in the database.


CREATE TABLE statement
When the xSQL CREATE TABLE statement is executed the runtime creates a definition of the new table using internal SQL API. The the current database dictionary is converted into the DDL format, and a new table is represented using the DDL and added to the existed database schema. The new DDL schema is converted back into the eXtremeDB C-dictionary format and the old dictionary is replaced with the new one. In order to make this possible it is necessary to reserve space for any new dictionary up-front, when allocating the dictionary. Furthermore, since the eXtremeDB database header contains structures associated with classed or indexes, it is necessary to reserve space in the array to add new classes and indexes. Thus the following must be specified for any dynamic schema:
the maximum number of classes in the database
the maximum number of indexes in the database
the maximum size of the dictionary
Note that at runtime applications can redefine the defaults through the mco_db_params_t structure ( max_classes, max_indexes, ddl_dict_size fields) and the xsqlCmd reads these parameters from the configuration file:


db_params {
 ...
 max_classes:100,
 max_indexes:1000,
 ddl_dict_size 64K,
 ...
}


These parameters are set to zero by mco_db_params_init() function (in the C API) and McoSqlOpenParameters::McoSqlOpenParameters (in the C++ API). The xsqlcmd utility sets its own set of defaults, which is 100/1000/64K. So, the application must change the defaults in order to use dynamic DDL
CRETE TABLE syntax statement:


create_statement: CREATE TABLE name "("  {  column_name data_type [ column constraint [ ... ]  ]
    |  [ CONSTRAINT name ]  table_constraint }  [ "," ... ]  ")"


where
column_constraint: 


     [ NOT ] NULL
     | PRIMARY KEY
     | UNIQUE
     | USING [ HASH | RTREE ] INDEX
     | [ FOREGN KEY ] REFERENCES table_name [ "(" column_name [ "," ... ]   ")" 
 
table_constraint:


     | UNIQUE "("  column_name [ "," ... ]  ")"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值