示例#1
0
void Database::CreateTable(SQLCreateTable& st) 
{
	int record_length = 0;
	Table tb;
	vector<Attribute> attrs = st.GetAttributes();
	for (auto attr = attrs.begin(); attr != attrs.end(); attr++)
	{
		tb.AddAttribute((*attr));
		record_length += (*attr).get_length();
	}
	tb.set_tb_name(st.get_tb_name());
	tb.set_record_length(record_length);
	tbs_.push_back(tb);
}
示例#2
0
 ErrorCode CreateTableStatementNode::execute() {
	Table *t = new Table();

	t->set_table_name(table_->name()); 
	
	INT32 position = 1;

	for (std::vector<ColumnIdentifierNode*>::iterator attr = (*definition_).begin(); attr != (*definition_).end(); ++attr) {
		t->AddAttribute((*attr)->name(), ((*attr)->getDataType()), position);
		++position;
	}
	
	ErrorCode er = GET_SCHEMA_MANAGER()->AddTable(t);

	return er;
}