· 8 years ago · Jan 30, 2018, 03:12 AM
1public class ExportDB {
2 public static void main(String[] args) {
3 ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
4 Metadata metadata = new MetadataSources(serviceRegistry).buildMetadata();
5 SchemaExport schemaExport = new SchemaExport();
6 schemaExport.create(EnumSet.of(TargetType.DATABASE), metadata);
7 }
8}
9
102016-11-19 00:22:12,845 WARN [org.hibernate.orm.connections.pooling] - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
11Hibernate: drop table if exists hibernate_sequences
12Hibernate: drop table if exists user
13Hibernate: create table hibernate_sequences (sequence_name varchar(255) not null, sequence_next_hi_value bigint, primary key (sequence_name))
14Hibernate: create table user (id bigint not null, balance decimal(20,4) default 0.00, createTime time, displayName varchar(64), password varchar(64), username varchar(64), primary key (id))
15Hibernate: alter table user add constraint UK_7kuje5s4lbyq9qyv1r9ecm2it unique (username)
16
17MariaDB [cms]> create table hibernate_sequences (sequence_name varchar(255) not null, next_val bigint, primary key (sequence_name));
18ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
19
20create table hibernate_sequences (
21 sequence_name varchar(255) CHARACTER SET utf8 not null ,
22 next_val bigint,
23 primary key (sequence_name)
24) engine=MyISAM