使用SpringSide 3.1.4.3开发Web项目的全过程(上)
2009-09-24 00:00:00 来源:WEB开发网第五步、将数据库迁移到MySQL中。在项目中,创建数据库和初始化数据库的语句都是以SQL文件存在的,如下图:
但是该语句都是针对Derby的,如果要应用于MySQL,还必须得要做一些修改才行,先修改schema.sql,如下:
drop table if exists RESOURCES_AUTHORITIES;
drop table if exists ROLES_AUTHORITIES;
drop table if exists USERS_ROLES;
drop table if exists RESOURCES;
drop table if exists AUTHORITIES;
drop table if exists USERS;
drop table if exists ROLES;
create table USERS (
ID integer primary key auto_increment,
LOGIN_NAME varchar(20) not null unique,
PASSWORD varchar(20),
NAME varchar(20),
EMAIL varchar(30)
);
create unique index USERS_LOGIN_NAME_INDEX on USERS(LOGIN_NAME);
create table ROLES (
ID integer primary key auto_increment,
NAME varchar(20) not null unique
);
create table USERS_ROLES (
USER_ID integer not null,
ROLE_ID integer not null,
FOREIGN KEY (ROLE_ID) references ROLES(ID),
FOREIGN KEY (USER_ID) references USERS(ID)
);
CREATE TABLE AUTHORITIES (
ID integer primary key auto_increment,
NAME varchar(20) not null,
DISPLAY_NAME varchar(20) not null
);
create table ROLES_AUTHORITIES (
ROLE_ID integer not null,
AUTHORITY_ID integer not null,
FOREIGN KEY (ROLE_ID) references ROLES(ID),
FOREIGN KEY (AUTHORITY_ID) references AUTHORITIES(ID)
);
CREATE TABLE RESOURCES (
ID integer primary key auto_increment,
RESOURCE_TYPE varchar(20) not null,
VALUE varchar(255) not null,
ORDER_NUM float not null
);
create table RESOURCES_AUTHORITIES (
AUTHORITY_ID integer not null,
RESOURCE_ID integer not null,
FOREIGN KEY (AUTHORITY_ID) references AUTHORITIES(ID),
FOREIGN KEY (RESOURCE_ID) references RESOURCES(ID)
);
Tags:使用 SpringSide 开发
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接