示例#1
0
 @Override
 public Sql makeDropSql(DTable td) {
   ComboSql sql = new ComboSql();
   sql.add(Sqls.create("DROP TABLE " + td.getName()));
   for (DField df : td.getAutoIncreaments()) {
     sql.add(Sqls.create(gSQL(DSEQ, td.getName(), df.getName())));
     // sql.addSQL(new ExecutableSql(gSQL(DTRI, td.getName(),
     // df.getName())));
   }
   return sql;
 }
示例#2
0
 @Override
 public Sql makeCreateSql(DTable td) {
   ComboSql sql = new ComboSql();
   // Make create table SQL
   StringBuilder sb = new StringBuilder("CREATE TABLE ").append(td.getName()).append('(');
   appendAllFields(td, sb);
   // Append PK
   Iterator<DField> dfIt = td.getPks().iterator();
   if (dfIt.hasNext()) {
     String names = dfIt.next().getName();
     while (dfIt.hasNext()) names += "," + dfIt.next();
     sb.append(',').append(gSQL(CPK, td.getName(), names));
   }
   sb.append(')');
   sql.add(Sqls.create(sb.toString()));
   // For all auto increaments fields, create the sequance and trigger
   for (DField df : td.getAutoIncreaments()) {
     // create sequance;
     sql.add(Sqls.create(gSQL(CSEQ, td.getName(), df.getName())));
     // create trigger;
     sql.add(Sqls.create(gSQL(CTRI, td.getName(), df.getName())));
   }
   return sql;
 }