易截截图软件、单文件、免安装、纯绿色、仅160KB

Mysql文集

导入数据指定列
load data local infile 'D:\\service_func_utf8.txt' into table service_func fields terminated by '\t' (service_id, func_id1, func_id2, func_id3, func_id4, func_id5, func_id6);
MYSQL将查询结果导出到文件
select * from tablename into outfile '/tmp/test.txt';
MYSQL联合主键
create   table   oldmail(
    id   varchar(200)   not   null,
    username     varchar(255)   not   null   ,
    primary   key(id,username)
)
3 mysql的主键问题:
Mysql的两种主键。Primary key 和not null auto_incriment在建立mysql表时,给一个字段添加了主键primary key 在insert数据时可以不用insert主键,mysql会自动添加0,但是在第二次insert时没有填写值mysql数据库还是默认添加0,会导致有重复的主键,这是不可以的。所有在定义了primary key时,在insert数据时要给主键填写值。在建立mysql表时,给一个字段添加了主键not null auto_increment=1;这也是一个主键。时自增长的以1为开始。这个字段是可以不用填写值的,mysql数据库会自动给填写值,不会出现primary key的状况。Alter table tb add primary key(id);Alter table tb change id id int(10) not null auto_increment=1;
4 删除自增长的主键id先删除自增长在删除主键
Alter table tb change id id int(10);//删除自增长
Alter table tb drop primary key;//删除主建
重命名表
ALTER   TABLE   旧表名   RENAME   TO   新表名;


相关文档:

mysql 导入、导出数据库、表

mysql 导出表:
mysqldump -u 用户名 -p  --opt  数据库用户名 表名
> 表名.sql
mysql 导出数据库:
mysqldump -u
用户名 -p  --opt  数据库用户名
>
数据库
名.sql
mysql 导入表:
>source e:\base\pet.sql;
mysql 导入表数据:
>LOAD DATA LOCAL INFILE 'e:path/pet.txt ......

MySQL语句优化的基本原则

MySQL语句优化的基本原则: 
◆1、使用索引来更快地遍历表。 
缺省情况下建立的索引是非群集索引,但有时它并不是最佳的。在非群集索引下,数据在物理上随机存放在数据页上。合理的索引设计要建立在对各种查询的分析和预测上。一般来说: 
a.有大量重复值、且经常有范围查询( > ,< ,> =,< ......

Mysql 学习笔记

 显示所有数据库 show databases;
 创建数据库 create dababase stu;
 删除数据库drop database stu;
 切换到数据库use stu;
 取得当前的数据库,带()表示函数:select database();
创建表(要切换到数据库中)
mysql> create table stu_info(
   
-> stu_id int(8) ......

具有负载均衡功能MySQL服务器集群部署实现


具有负载均衡功能MySQL服务器集群部署实现
http://www.realure.cn/2009_241.html
http://www.realure.cn/2009_242.html
http://www.realure.cn/2009_243.html
http://www.realure.cn/2009_244.html
http://www.realure.cn/2009_245.html ......

MySQL行锁深入研究

     
做项目时由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图书借阅系统。假设
id=1
的这本书库存为
1
,但是有
2
个人同时来借这本书,此处的逻辑为
Select restnum from book where id =1 ;
-- 如果 restnum 大于 0 ,执行 update
Update boo ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号