select * from emp where ename='研发部';
ALTER TABLE emp ADD PRIMARY KEY(empno);
alter table emp drop primary key;
select * from emp where empno = 1;
select * from emp where sex = '男'
select * from emp where logincount = 1
create table news(id int , title varchar(32),con varchar(1024)) engine=MyISAM;
create fulltext index ful_inx on news (con);
'but it often happens that they are not above supporting themselves by dishonest means.which should be more disreputable.Cultivate poverty like a garden herb'
mysql> select match(con) against('poverty') from news;
+-------------------------------+
| match(con) against('poverty') |
+-------------------------------+
| 0 |
| 0 |
| 0 |
| 0.9853024482727051 |
+------------------------------+
create index 索引名 on 表名(列1,列2);
create [UNIQUE|FULLTEXT] index index_name on tbl_name (col_name [(length)] [ASC | DESC] , …..); alter table table_name ADD INDEX [index_name] (index_col_name,...) 添加主键(索引) ALTER TABLE 表名 ADD PRIMARY KEY(列名,..); 联合主键
DROP INDEX index_name ON tbl_name; alter table table_name drop index index_name; 删除主键(索引)比较特别: alter table t_b drop primary key;
show index(es) from table_name; show keys from table_name; desc table_Name;
CREATE TABLE dept( deptno MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, dname VARCHAR(20) NOT NULL DEFAULT "", loc VARCHAR(13) NOT NULL DEFAULT "" ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; --放入数据,前面应该已经添加了,如果没有则需要重新添加 --测试开始.
alter table dept add primary key (deptno)
explain select * from dept where deptno=1;
mysql> explain select * from dept where deptno=1; *************************** 1. row *************************** id: 1 select_type: SIMPLE table: dept type: const possible_keys: PRIMARY key: PRIMARY key_len: 3 ref: const rows: 1 Extra: 1 row in set (0.00 sec)
alter table dept add index myind (dname,loc);
explain select * from dept where dname='研发部'; 会显示使用到了索引myind explain select * from dept where loc='MsBDpMRX'; 不会显示使用到了索引myind
explain select * from dept where dname like '%研发部'; 不会显示使用到了索引myind explain select * from dept where dname like '研发部%'; 会显示使用到了索引myind
alter table dept drop index myind alter table dept add index myind (dname) explain select * from dept where dname='研发部' or loc='aa';-- 就不会使用到dname列上的
select * from dept from dname=1234; //不会使用到索引 select * from dept from dname='1234'; //会使用到索引
show status like 'Handler_read%';
alter table table_name disable keys; loading data//insert语句; alter table table_name enable keys;
select * from 表名 where 条件1='' or 条件2='tt' explaine select * from dept group by dname; =>这时显示 extra: using filesort 说明会进行排序 explaine select * from dept group by dname order by null =>这时不含有显示 extra: using filesort 说明不会进行排序
explain select * from emp , dept where emp.deptno=dept.deptno;
explain select * from emp left join dept on emp.deptno=dept.deptno;
create table bbs(id int ,con varchar(1024) , pub_time int);
date('Ymd',时间-3*24*60*60); 2038年-1-19
create table temp1( t1 float(10,2), t2 decimal(10,2)); insert into temp1 values(1000000.32,1000000,32); 发现 t1 成了 1000000.31 所以有问题.
create table temp2( id int) engine=MyISAM; insert into temp2 values(1); insert into temp2 values(2); insert into temp2 values(3); insert into temp2 select * from temp2;--复制 delete from temp2 where id=1; 发现 该表对于的数据文件没有变小
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有