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后的命令行是这个样子的:
warmbupt@pchuang:/windows/MyCode/SS$ mysql -u root -ppassw0rd
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.1.37-1ubuntu5.1 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the curr ......
公司mysql统一用latin1的编码,真是叫人苦不堪言。Django用默认UTF8访问MYSQL数据库。在操作数据库时,不管你怎么转码,最终写到数据库里的中文都是乱码。在网上找了很久,也没解决这个问题。
后来看了一个DJANGO的MYSQL操作的源码,发现了一些问题 先是/d ......
要不出现乱码,就要保持数据库和页面的编码格式一致.我全部使用utf-8的编码.
首先页面:
1. 将文件用UE打开,将文件另存为UTF-8无BOM格式.很多编辑器都可用.
2.使用 header("content-type:text/html; charset=utf-8"); 强制转换成utf-8的编码.
也可以新建一个head.php,如下,在页面中用include( ......
具有负载均衡功能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 ......