回覆列表
-
1 # 老死不想來
-
2 # 使用者4689034636226
Drop table if exists Role; Create table if not exists Role( id INT UNSIGNED NOT NULL AUTO_INCREMENT, Name varchar(64) not null unique key, Primary key(id) )ENGINE=InnoDB; Drop table if exists UserRole; Create table if not exists UserRole( id INT UNSIGNED NOT NULL AUTO_INCREMENT, User_id int UNSIGNED not null, Role_id int UNSIGNED not null, Primary key(id), Index(User_id),foreign key(User_id) references User(id), Index(Role_id),foreign key(Role_id) references Role(id) )ENGINE=InnoDB;UserRole裡面就引用了User_id,Index(User_id),foreign key(User_id) references User(id),索引User_id,外來鍵User_id,引用了User表裡的主鍵id
在File裡面有NewModel
在Navigator裡,右鍵SCHEMA下面的schema名稱/TABLES,有NewTable的