1 show databases; 2 3 //假设存在seckill 数据库 4 use seckill; 5 6 //查看所有表 7 show tables; 8 9 //查看某个表的字段,例如存在 student 表 10 desc student; 11 12 //查看student 数据 13 selet * from student 14 15 //接下来就可以对这个数据库(seckill)作各种操作了,select 啊,update ...%&*$^$^ 巴拉巴拉的
1 //指定主键 2 create table permission ( 3 permission_id int(11) not null auto_increment, 4 available int not null, 5 description char(20) null, 6 permission int(20) not null, 7 url char(20) not null, 8 primary key(permission_id) 9 )engine = innodb default charset=utf8 auto_increment=1;
1 //指定外键 2 create table role_permission ( 3 role_id int(11) not null , 4 permission_id int(11) not null , 5 foreign key(permission_id) references permission(permission_id), 6 foreign key(role_id) references sys_role(role_id) 7 )engine = innodb default charset=utf8 ; 8
分为定长串和变长串,char : 定长, text : 变长 ,mysql处理定长数据快于处理变长数据,此外,mysql不允许对变长列(或一个列的可变部分)进行索引,这也会极大地影响性能。
(2)数字数据类型
所有数据类型都有有符号和无符号之分(除bit 和 boolean), 默认为有符号(即是可以表示负数),若是不想表示负数,可以使用unsigned关键字。
(3)时间和日期数据类型
如对本文有疑问, 点击进行留言回复!!
网友评论