Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. create table testtable(
  2. id bigint unsigned auto_increment,
  3. city_id varchar(256),
  4. person_id varchar(256),
  5. primary key(id) comment 'This is comment for the primary key',
  6. key idx1 (city_id, person_id) comment 'This is the comment for test index'
  7. ) comment='This is the comment for test table';
  8.  
  9. // jdbc:mysql://localhost:3306/testdb?useInformationSchema=true&useUnicode=true&characterEncoding=utf8
  10. final Connection connection = ...;
  11. final DatabaseSpecificOverrideOptions databaseSpecificOverrideOptions =
  12. SchemaCrawlerUtility.matchDatabaseSpecificOverrideOptions(connection);
  13.  
  14. final SchemaCrawler schemaCrawler = new SchemaCrawler(connection, databaseSpecificOverrideOptions);
  15.  
  16. final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
  17. options.setSchemaInfoLevel(SchemaInfoLevelBuilder.maximum());
  18. options.setTableInclusionRule(new IncludeAll());
  19. options.setColumnInclusionRule(new IncludeAll());
  20.  
  21. final Catalog catalog = schemaCrawler.crawl(options);
  22. final Collection<schemacrawler.schema.Table> tables = catalog.getTables();
  23.  
  24. for (schemacrawler.schema.Table t : tables) {
  25. System.out.println(t.getPrimaryKey().getRemarks());
  26. for (schemacrawler.schema.Index index : t.getIndexes()) {
  27. System.out.println(index.getRemarks());
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement