create database idleschool;
use idleschool;
create table if not exists types
(
type_id int(4) primary key,
type_name varchar(20)
);
create table if not exists users
(
user_id int(4) primary key auto_increment,
/*auto_increment字段自增*/
username varchar(40) not null unique,
password varchar(40) not null,
compellation varchar(20) not null,
sex enum('男','女') not null,
address varchar(40) not null,
phone varchar(11) not null,
user_type int(4) not null ,
foreign key (user_type) references types(type_id)
/*外键/候选键 key后面的字段用()*/
)
有个网站写的很全面,不知道可以去里面找
C语言中文网:http://c.biancheng.net/view/2441.html
点击跳转