mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Updated SQL_Schema_Repository (markdown)
+3
-5
@@ -34,16 +34,13 @@ String sql = "CREATE TABLE `test1` (\n" +
|
||||
" KEY `k_c` (`c_tinyint`,`c_int`),\n" +
|
||||
" KEY `k_d` (`c_char`,`c_bigint`)\n" +
|
||||
") ENGINE=InnoDB AUTO_INCREMENT=1769503 DEFAULT CHARSET=utf8mb4 COMMENT='10000000'";
|
||||
|
||||
|
||||
repository.console(sql);
|
||||
|
||||
// 在如下的代码中可以知道repository中已经存在表test1
|
||||
MySqlCreateTableStatement createTableStmt = (MySqlCreateTableStatement) repository.findTable("test1").getStatement();
|
||||
assertEquals(21, createTableStmt.getTableElementList().size());
|
||||
|
||||
//StringBuilder buf = new StringBuilder();
|
||||
//createTableStmt.showCoumns(buf);
|
||||
|
||||
// 通过执行命令"show columns from test1"可以获得mysql console风格的输出
|
||||
assertEquals("+--------------+---------------+------+-----+---------------------+-----------------------------+\n" +
|
||||
"| Field | Type | Null | Key | Default | Extra |\n" +
|
||||
"+--------------+---------------+------+-----+---------------------+-----------------------------+\n" +
|
||||
@@ -66,6 +63,7 @@ assertEquals("+--------------+---------------+------+-----+---------------------
|
||||
"| c_longblob | longblob | YES | | NULL | |\n" +
|
||||
"+--------------+---------------+------+-----+---------------------+-----------------------------+\n", repository.console("show columns from test1"));
|
||||
|
||||
// 执行alter语句,修改repository中内容
|
||||
repository.console("alter table test1 drop column c_decimal;");
|
||||
assertEquals(20, createTableStmt.getTableElementList().size());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user