日期:2014-05-20 浏览次数:20760 次
enum Student {
Name(Type.CHAR, 3),
Grade(Type.NUMBER, 2),
Class(Type.NUMBER, 2),
Lesson(Type.VARCHAR, 12),
Score(Type.NUMBER, 2), ;
Type type;
int length;
Student(Type _type, int _length) {
type = _type;
length = _length;
}
}
enum Type {
CHAR, VARCHAR, NUMBER, SMALLINT;
}
public class NewTest {
public static void main(String[] args) {
String sql = "CREATE TABLE " + Student.class.getName() + "{\n";
for (Student s : Student.values()) {
sql += "\t" + s + " ";
sql += s.type;
sql += "(" + s.length + "),\n";
}
sql += "}";
System.out.println(sql);
}
}
CREATE TABLE Student{
Name CHAR(3),
Grade NUMBER(2),
Class NUMBER(2),
Lesson VARCHAR(12),
Score NUMBER(2),
}