自动生成MySQL报错 1050 - Table 'sys_action' already exists 20
CREATETABLEsys_action(actionIdVARCHAR(32)NOTNULL,actionNameVARCHAR(32)NOTNULL,typeTIN...
CREATE TABLE sys_action(
actionId VARCHAR(32) NOT NULL,
actionName VARCHAR(32) NOT NULL,
type TINYINT NOT NULL,
remark VARCHAR(1000),
PRIMARY KEY (actionId)
)ENGINE=INNODB
;
CREATE TABLE sys_menu(
menuId VARCHAR(32) NOT NULL,
menuName VARCHAR(32) NOT NULL,
actionId VARCHAR(32) NOT NULL,
remark VARCHAR(1000),
type TINYINT,
PRIMARY KEY (menuId)
)ENGINE=INNODB
;
CREATE TABLE sys_role(
roleId VARCHAR(32) NOT NULL,
rolename VARCHAR(32) NOT NULL,
remark VARCHAR(1000),
status TINYINT NOT NULL,
PRIMARY KEY (roleId)
)ENGINE=INNODB
;
CREATE TABLE sys_roleaction(
roleaction VARCHAR(10) NOT NULL,
actionId VARCHAR(32) NOT NULL,
roleId VARCHAR(32) NOT NULL,
PRIMARY KEY (roleaction)
)ENGINE=INNODB
;
CREATE TABLE sys_rolemenu(
rolemenu VARCHAR(32) NOT NULL,
menuId VARCHAR(32) NOT NULL,
roleId VARCHAR(32) NOT NULL,
PRIMARY KEY (rolemenu)
)ENGINE=INNODB
;
CREATE TABLE sys_userId(
userId VARCHAR(32) NOT NULL,
account VARCHAR(32) NOT NULL,
passwd VARCHAR(32) NOT NULL,
remark VARCHAR(1000),
creatTime DATETIME,
lastloginTime DATETIME,
PRIMARY KEY (userId)
)ENGINE=INNODB
;
CREATE TABLE sys_userrole(
roleuser VARCHAR(32) NOT NULL,
userId VARCHAR(32) NOT NULL,
roleId VARCHAR(32) NOT NULL,
PRIMARY KEY (roleuser)
)ENGINE=INNODB
;
ALTER TABLE sys_roleaction ADD CONSTRAINT Refsys_action5
FOREIGN KEY (actionId)
REFERENCES sys_action(actionId)
;
ALTER TABLE sys_roleaction ADD CONSTRAINT Refsys_role11
FOREIGN KEY (roleId)
REFERENCES sys_role(roleId)
;
ALTER TABLE sys_rolemenu ADD CONSTRAINT Refsys_menu9
FOREIGN KEY (menuId)
REFERENCES sys_menu(menuId)
;
ALTER TABLE sys_rolemenu ADD CONSTRAINT Refsys_role12
FOREIGN KEY (roleId)
REFERENCES sys_role(roleId)
;
ALTER TABLE sys_userrole ADD CONSTRAINT Refsys_userId1
FOREIGN KEY (userId)
REFERENCES sys_userId(userId)
;
ALTER TABLE sys_userrole ADD CONSTRAINT Refsys_role2
FOREIGN KEY (roleId)
REFERENCES sys_role(roleId)
; 展开
actionId VARCHAR(32) NOT NULL,
actionName VARCHAR(32) NOT NULL,
type TINYINT NOT NULL,
remark VARCHAR(1000),
PRIMARY KEY (actionId)
)ENGINE=INNODB
;
CREATE TABLE sys_menu(
menuId VARCHAR(32) NOT NULL,
menuName VARCHAR(32) NOT NULL,
actionId VARCHAR(32) NOT NULL,
remark VARCHAR(1000),
type TINYINT,
PRIMARY KEY (menuId)
)ENGINE=INNODB
;
CREATE TABLE sys_role(
roleId VARCHAR(32) NOT NULL,
rolename VARCHAR(32) NOT NULL,
remark VARCHAR(1000),
status TINYINT NOT NULL,
PRIMARY KEY (roleId)
)ENGINE=INNODB
;
CREATE TABLE sys_roleaction(
roleaction VARCHAR(10) NOT NULL,
actionId VARCHAR(32) NOT NULL,
roleId VARCHAR(32) NOT NULL,
PRIMARY KEY (roleaction)
)ENGINE=INNODB
;
CREATE TABLE sys_rolemenu(
rolemenu VARCHAR(32) NOT NULL,
menuId VARCHAR(32) NOT NULL,
roleId VARCHAR(32) NOT NULL,
PRIMARY KEY (rolemenu)
)ENGINE=INNODB
;
CREATE TABLE sys_userId(
userId VARCHAR(32) NOT NULL,
account VARCHAR(32) NOT NULL,
passwd VARCHAR(32) NOT NULL,
remark VARCHAR(1000),
creatTime DATETIME,
lastloginTime DATETIME,
PRIMARY KEY (userId)
)ENGINE=INNODB
;
CREATE TABLE sys_userrole(
roleuser VARCHAR(32) NOT NULL,
userId VARCHAR(32) NOT NULL,
roleId VARCHAR(32) NOT NULL,
PRIMARY KEY (roleuser)
)ENGINE=INNODB
;
ALTER TABLE sys_roleaction ADD CONSTRAINT Refsys_action5
FOREIGN KEY (actionId)
REFERENCES sys_action(actionId)
;
ALTER TABLE sys_roleaction ADD CONSTRAINT Refsys_role11
FOREIGN KEY (roleId)
REFERENCES sys_role(roleId)
;
ALTER TABLE sys_rolemenu ADD CONSTRAINT Refsys_menu9
FOREIGN KEY (menuId)
REFERENCES sys_menu(menuId)
;
ALTER TABLE sys_rolemenu ADD CONSTRAINT Refsys_role12
FOREIGN KEY (roleId)
REFERENCES sys_role(roleId)
;
ALTER TABLE sys_userrole ADD CONSTRAINT Refsys_userId1
FOREIGN KEY (userId)
REFERENCES sys_userId(userId)
;
ALTER TABLE sys_userrole ADD CONSTRAINT Refsys_role2
FOREIGN KEY (roleId)
REFERENCES sys_role(roleId)
; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询