MySQL 创建基本表SQL语句

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
点击跳转

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值