Search in sources :

Example 31 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class TableTest method checkModel.

private static Table checkModel() {
    // column check
    Table t = new Table("testTable");
    t.column("s1").STRING(20).unique().notNull().check("s1>5");
    t.column("s2").STRING(20).unique().check("s2>5");
    t.column("s3").STRING(20).unique("uname1").notNull().check("s3>5");
    t.column("s4").STRING(20).unique("uname2").check("s4>5");
    return t;
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table)

Example 32 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class TableTest method testFKEY.

@Test
public void testFKEY() {
    // FKEY
    Table t = new Table("master");
    t.column("id").INTEGER().pkey();
    t.column("name").STRING(20);
    t.column("address").INTEGER().pkey();
    Table t2 = new Table("child");
    t2.column("id").INTEGER().pkey();
    t2.column("address2").VARCHAR(20).fkey("master", "name", "address");
    t2.column("masterid3").VARCHAR(20).fkey("master", "id");
    t2.column("aaaaa").VARCHAR(20).fkey("master", "name", "address");
    printAllDialectsDDLs(t, t2);
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table) Test(org.junit.Test)

Example 33 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class TableTest method tableGeneratorModel.

private static Table tableGeneratorModel() {
    // tableGenerator
    Table t = new Table("testTable");
    t.addTableGenerator("tbgen1", "tb1", "pkcol", "valcol", "pkval", 1, 10);
    t.addTableGenerator("tbgen2", "tb1", "pkcol2", "valcol", "pkval", 1, 10);
    t.column("i1").INTEGER().pkey().tableGenerator("tbgen1");
    t.column("i2").INTEGER().pkey().tableGenerator("tbgen2");
    return t;
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table)

Example 34 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class ColumnDDLTest method tableModel.

private static Table tableModel() {
    Table t = new Table(testTable);
    t.column("b1").BOOLEAN();
    t.column("d2").DOUBLE();
    t.column("f3").FLOAT();
    t.column("i4").INTEGER().pkey().unique().notNull().defaultValue("1");
    t.column("l5").LONG();
    t.column("s6").SHORT();
    t.column("b7").BIGDECIMAL(10, 2);
    t.column("s8").STRING(20);
    t.column("d9").DATE();
    t.column("t10").TIME();
    t.column("t11").TIMESTAMP();
    t.column("v12").VARCHAR(300);
    return t;
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table)

Example 35 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class TableTest method testCompondPkey.

@Test
public void testCompondPkey() {
    // Compound PKEY
    Table t = new Table("testTable");
    t.column("i4").INTEGER().pkey().unique().notNull().defaultValue("1");
    t.column("l5").LONG().pkey();
    t.column("s6").SHORT();
    printAllDialectsDDLs(t);
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table) Test(org.junit.Test)

Aggregations

Table (com.github.drinkjava2.jdialects.model.Table)18 Test (org.junit.Test)10 TableModel (com.github.drinkjava2.jdialects.model.TableModel)9 ColumnModel (com.github.drinkjava2.jdialects.model.ColumnModel)8 AutoIdGenerator (com.github.drinkjava2.jdialects.id.AutoIdGenerator)7 IdGenerator (com.github.drinkjava2.jdialects.id.IdGenerator)7 TableIdGenerator (com.github.drinkjava2.jdialects.id.TableIdGenerator)6 FKeyModel (com.github.drinkjava2.jdialects.model.FKeyModel)6 SequenceIdGenerator (com.github.drinkjava2.jdialects.id.SequenceIdGenerator)4 ArrayList (java.util.ArrayList)4 Dialect (com.github.drinkjava2.jdialects.Dialect)3 FKeyConstraint (com.github.drinkjava2.jdialects.model.FKeyConstraint)3 UniqueModel (com.github.drinkjava2.jdialects.model.UniqueModel)3 DB2400Dialect (com.github.drinkjava2.jdialects.Dialect.DB2400Dialect)2 DB2Dialect (com.github.drinkjava2.jdialects.Dialect.DB2Dialect)2 DerbyDialect (com.github.drinkjava2.jdialects.Dialect.DerbyDialect)2 DerbyTenFiveDialect (com.github.drinkjava2.jdialects.Dialect.DerbyTenFiveDialect)2 DerbyTenSevenDialect (com.github.drinkjava2.jdialects.Dialect.DerbyTenSevenDialect)2 DerbyTenSixDialect (com.github.drinkjava2.jdialects.Dialect.DerbyTenSixDialect)2 H2Dialect (com.github.drinkjava2.jdialects.Dialect.H2Dialect)2