-- create database db_std_mgr_sys;
// TODO schema都用db开头,表都用t开头,字段都用f开头,存储过程都用proc开头,触发器都用trig开头,函数都用func开头,这样能有效避免用关键字命名,比如班级是class,名字是name这些都是关键字(会显示蓝色的标识符)
use db_std_mgr_sys;;
create table t_student(
f_id bigint(20) not null auto_increment,
f_name varchar(10) not null default '',
f_code varchar(20) not null default '' comment '学号,值唯一',
f_sex varchar(8) not null default '',
f_phone varchar(20) not null default '',
f_school_id bigint not null default -1 comment '所在学校id',
f_grade_id BIGINT not null default -1 comment '所在年级id',
f_cls_id bigint not null default -1 comment '所在班级id',
primary key(f_id),
unique key uk_std_code(f_code) -- 和主键一样默认会创建索引(可以有多个列),uk_std_code是索引名
key idx_phone(f_phone) -- 注意,unique key和key都是会生成索引,而且可以省略key后面的标识符如uk_std_code等,但是不要省略,否则对应索引的名字为第一个字段的名字;primary key的可以省略,因为它的索引名就是PRIMARY(所以explain select* xxx,的是索引名)
)engineinnodb, charset 'utf8', comment '学生表';; -- TODO 就用这种写法了,注意这里先有delimiter ;;

表二:

use db_std_mgr_sys;
create table `user`(
uid bigint not null auto_increment,
username varchar(20) not null,
`password` varchar(40) not null,
phone varchar(20) not null,
email varchar(30) not null,
primary key (uid),
unique key (username),
unique key (phone),
unique key (email)
)engineINNODB, charset utf8;;
/*这里要注意key后面一定要有()而不能直接是primary key uid,这里的key就是索引的意思,
而前面的primary、unique都是修饰,主键也是索引的一种;若只有key没有修饰则表示该索引是普通索引;
若是unique key uq_username (username),则是给这个索引命名为uq_username,否则索引名和索引的列名是一样的为username*/

最新文章

  1. nginx+ISS 负载均衡 快速入门
  2. 从0开始学angularjs-笔记02
  3. gauss消元
  4. [每日自动更新]Hillstone 山石网科 StoneOS ISP路由表配置文件
  5. 【leetcode】3Sum Closest
  6. [转载]:Delphi xe7并行编程快速入门
  7. 手机GUI自动化测试介绍
  8. jQuery鼠标事件
  9. Javascript页面跳转与浏览器兼容
  10. HDU 1983 Kaitou Kid - The Phantom Thief (2)
  11. (Sql Server)数据的拆分和合并
  12. 本地存储 cookie,session,localstorage( 二)angular-local-storage
  13. An impassioned circulation of affection
  14. Lloyd’s 算法 和 K-Means算法
  15. K8s存储卷、pv和pvc的使用
  16. GitHub-分支管理03-多人合作【重点】
  17. python3读文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x9f in position 2: illegal multibyte sequence
  18. 《Python编程》课程报告 python技术在数据分析中的应用之网络爬虫
  19. (8)进程---Queue队列
  20. tail -f 和tail -F的区别

热门文章

  1. 源码剖析Django REST framework的认证方式及自定义认证
  2. MyBatis开发学习记录
  3. 《用Java写一个通用的服务器程序》02 监听器
  4. MySQL错误:2003-Can't connect to MySQL server on 'localhost'(10061 "unknown error")
  5. 模块化编程node
  6. apache编译安装 httpd 2.2 httpd 2.4
  7. 程序员的自我救赎---11.3:WinService服务
  8. PDFBox 打印带背景的文件速度慢
  9. Java开发小技巧(一)
  10. Libcurl的编译_HTTP/HTTPSclient源代码演示样例