资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

数据库SQL语句的使用

这篇文章主要讲解了“数据库SQL语句的使用”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“数据库SQL语句的使用”吧!

十载专注成都网站制作,成都定制网站,个人网站制作服务,为大家分享网站制作知识、方案,网站设计流程、步骤,成功服务上千家企业。为您提供网站建设,网站制作,网页设计及定制高端网站建设服务,专注于成都定制网站,高端网页制作,对成都轻质隔墙板等多个行业,拥有多年的网站设计经验。

1、创建数据库
create database if not exists cs2013;
2、创建数据库表格
create table if not exists comp (
	id int not null primary key auto_increment ,
	pid varchar(30) not null unique ,
	cname varchar(30) not null ,
	ename varchar(30) not null ,
	grade varchar(30) not null , 
	sex int not null ,
	clothe varchar(15) not null
)default charset = utf8;

create table if not exists team (
	id int not null primary key auto_increment ,
	cname varchar(30) not null ,
	ename varchar(30) not null ,
	coach0 int not null , 
	coach2 int not null ,
	stu0 int not null ,
	stu1 int not null ,
	stu2 int not null ,
	isgirls int not null ,
	email varchar(30) not null ,
	phone varchar(15) not null ,
	foreign key (coach0) references comp(id) ,
	foreign key (coach2) references comp(id) ,
	foreign key (stu0) references comp(id) ,
	foreign key (stu1) references comp(id) ,
	foreign key (stu2) references comp(id)
)default charset = utf8;

create table if not exists college (
	id int not null primary key auto_increment,
	cname varchar(30) not null ,
	ename varchar(30) not null ,
	teamcnt int not null
)default charset = utf8;

create table if not exists rc (
	id int not null primary key auto_increment ,
	college int not null ,
	team int not null ,
	date date not null ,
	foreign key (college) references college (id) ,
	foreign key (team) references team (id)
)default charset = utf8;

create table if not exists room (
	id int not null primary key auto_increment,
	name varchar(30) not null ,
	totcnt int not null ,
	regcnt int not null ,
	price double not null
)default charset = utf8;

create table if not exists hotel (
	id int not null primary key auto_increment,
	name varchar(30) not null ,
	room0 int not null ,
	room1 int not null ,
	room2 int not null ,
	foreign key (room0) references room (id) ,
	foreign key (room1) references room (id) ,
	foreign key (room2) references room (id)
)default charset = utf8;

create table if not exists rh (
	id int not null primary key auto_increment,
	college int not null ,
	hotel int not null ,
	date date not null ,
	foreign key (college) references college (id) ,
	foreign key (hotel) references hotel (id)
)default charset = utf8;

感谢各位的阅读,以上就是“数据库SQL语句的使用”的内容了,经过本文的学习后,相信大家对数据库SQL语句的使用这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!


文章名称:数据库SQL语句的使用
标题来源:http://cdkjz.cn/article/jjpphi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220