44 assert ( colNum <
MAXCOL );
55 if ( colNum > 0 && colNum <= (
signed)
fNumCols ) {
return fColAttr[colNum-1]; }
67 while ( isspace(*strPtr) ) { ++strPtr; }
68 if ( *strPtr == 0 ) {
return token; }
71 char firstChar = *strPtr++;
73 if ( ! isalnum(firstChar) && firstChar !=
'_' ) {
return token; }
76 while ( isalnum(*strPtr) || *strPtr ==
'_' ) { token += *strPtr++; }
96 attrib.
Type = fieldType;
105 TString SqlUpper(sql);
108 const char* strPtr = SqlUpper.Data();
115 if ( token1 !=
"CREATE" || token2 !=
"TABLE" || token4 !=
"(" ) {
116 cout <<
"Cannot recreate: SQL " << SqlUpper
117 <<
" does not start CREATE TABLE ... (" << endl;
123 cout <<
"Recreating FairDbTableMetaData for table " <<
fTableName << endl;
129 while ( delim !=
")" ) {
133 if ( name ==
"INDEX" || name ==
"KEY" || name ==
"PRIMARY" ) {
149 if ( delim ==
"(" ) {
151 istringstream is(delim);
158 cout <<
" Column: " << col <<
" name " << this->
ColName(col)
160 <<
" precision " << precision << endl;
164 while ( delim !=
"," && delim !=
")" ) {
166 if ( delim ==
"NOT" && opt2 ==
"NULL") {
169 }
else if ( delim ==
"PRIMARY" && opt2 ==
"KEY") {
171 }
else if ( delim ==
"AUTO_INCREMENT") {
173 }
else if ( delim ==
"UNSIGNED") {
176 cout <<
"Column: " << col <<
" name " << name <<
" type " << ft.
AsString()
177 <<
" ignoring unknown option: " << delim << endl;
190 bool hasRowCounter =
false;
195 sql <<
"create table " << tableName <<
"(";
199 for(
int i=1; i<= numCols; i++) {
201 if ( this->
ColName(i) ==
"ROW_COUNTER" ) { hasRowCounter =
true; }
202 sql << this->
ColName(i) <<
" " ;
207 && ! mainTable ) { sql <<
" not null primary key" ; }
211 || this->
ColName(i) ==
"ROW_COUNTER"
212 ) { sql <<
" not null" ; }
214 if (i < numCols) { sql <<
", "; }
228 if ( hasRowCounter ) { sql <<
", primary key (SEQNO,ROW_COUNTER)"; }
229 else { sql <<
", index (SEQNO)"; }
231 sql <<
", key TIMESTART (TIMESTART), key TIMEEND (TIMEEND)";
239 sql <<
", constraint FK_" <<
fTableName <<
" foreign key(SEQNO) references "
242 sql <<
", constraint PK_" << fTableName
243 <<
"VAL primary key(SEQNO,ROW_COUNTER) using index tablespace R3B_DEV_IDX";
246 <<
"VAL primary key(SEQNO) using index tablespace R3B_DEV_IDX";
248 sql <<
")tablespace R3B_DEV_DATA";
251 if ( ! hasRowCounter )
252 sql <<
"; create index " << tableName <<
"_idx on "
253 << tableName <<
"(seqno) tablespace R3B_DEV_IDX";
254 sql <<
"; create index " <<
fTableName <<
"VAL_idx2 on "
255 <<
fTableName <<
"VAL(TIMESTART) tablespace R3B_DEV_IDX";
256 sql <<
"; create index " << fTableName <<
"VAL_idx3 on "
257 << fTableName <<
"VAL(TIMEEND) tablespace R3B_DEV_IDX";
266 sql <<
"; create public synonym " << tableName <<
" for " << tableName;
267 sql <<
"; grant select on " << tableName <<
" to r3b_reader";
268 sql <<
"; grant select,insert,update on " << tableName <<
" to r3b_writer";