MySql 主键
2016-03-14 16:47
183 查看
增加主键
create table my_pril
(name varchar(20) not null comment '姓名',
number char(10) primary key comment '学号: itcast +0000 ,不能重复')charset utf8;
复合主键
create table my_pri2
(number char(10) comment '学号 :itcast +000',
course char (10) comment '课程代码: 3901 +0000',
score tinyint unsigned default 60 comment '成绩',
primary key (number,course)
)charset utf8;
追加主键
create table my_pri3
(course char(10) not null comment '课程编号 :00000 ',
name varchar(10) not null comment'课程名字');
alter table my_pri3 modify course char(10) primary key comment '课程编号 :00000 '; 方法1
alter table my_pri3 add primary key (course); 方法2
删除主键
alter table my_pri3 drop primary key ;
create table my_pril
(name varchar(20) not null comment '姓名',
number char(10) primary key comment '学号: itcast +0000 ,不能重复')charset utf8;
复合主键
create table my_pri2
(number char(10) comment '学号 :itcast +000',
course char (10) comment '课程代码: 3901 +0000',
score tinyint unsigned default 60 comment '成绩',
primary key (number,course)
)charset utf8;
追加主键
create table my_pri3
(course char(10) not null comment '课程编号 :00000 ',
name varchar(10) not null comment'课程名字');
alter table my_pri3 modify course char(10) primary key comment '课程编号 :00000 '; 方法1
alter table my_pri3 add primary key (course); 方法2
删除主键
alter table my_pri3 drop primary key ;
相关文章推荐
- MySQL查看SQL语句执行效率
- MySQL索引
- MySql连接——内连接、外连接(左连接、右连接、全连接)
- MySQL索引类型总结和使用技巧以及注意事项
- YUM 安装并配置MYSQL
- Mysql 主从热备份
- MySQL查询指定行的记录
- 黄聪:MySQL 按指定字段自定义列表排序
- Mysql timestamp 类型
- servlet&jsp 及MySQL 乱码解决方案
- mysql常用字符串操作函数大全,以及实例
- 如何在Windows系统中配置Mysql群集(Mysql Cluster)
- MySQL备份之增量备份方案
- mysql 查看表结构,字段的基本信息(简单明了)。
- mysql工具篇--Workbench的使用
- mySql 时间类型
- MySQL优化必须调整的10项配置
- MySQL数据库的优化
- navicat 1045 access denied for user
- windows mysql 自动备份的几种方法