- 1、本文档共45页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
MySQL 开发者
SQL 权威指南
SQL For MySQL Developers
A Comprehensive Tutorial and Reference
整理:侯杰
MySQL 开发范例
第一章 SQL 概要
1. 引入一个名为 BOOKSQL 的新用户,他的密码是 BOOKSQLPW 。
CREATE USER ‘BOOKSQL’@’LOCALHOST’ IDENTIFIED BY ‘BOOKSQLPW’
create user houjie410782‘ ’@ ’localhost ’ identified by 630529‘ ’
2. 给 SQL 用户 BOOKSQL 创建和操作表的权限。
grant all privileges on *.* to ‘BOOKSQL’@’LOCALHOST’ with grant option;
grat all privileges on *.* to houjie410782‘ ’@ ’localhost ’ with grant option;
3. 创建数据库 tennis 。
create database tennis;
4. 指定 tennis 为当前数据库。
use tennis;
5. 创建表 players ,teams ,matches ,penalties ,committee_members 。
create table players
(playerno integer not null,
name char(15) not null,
initials char(3) not null,
birth_date date,
sex char(1) not null,
joined smallint not null,
street varchar(30) not null,
houseno char(4),
postcode char(6),
town varchar(30) not null,
phoneno char(13),
leagueno char(4),
primary key (playerno)
)
create table teams(
teamno integer not null,
playerno integer not null,
division char(6) not null,
primary key (teamno)
)
create table matches(
matchno integer not null,
teamno integer not null,
playerno integer not null,
won smallint not null,
lost smallint not null,
primary key (matchno)
)
create table penalties(
paymentno integer not null,
playerno integer not null,
payment_date date not null,
amount decimal(7,2) not null,
primary key (paymentno)
- 1 -
MySQL 开发范例
)
create table committee_members(
playerno integer not null,
begin_date date not null,
end_date date,
position char(20),
primary key (
文档评论(0)