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 ......
记了一些用 Windows 的命令行来操作 MySQL 的指令。
摘要
连结 MySQL
->mysql -u username -p
username 是你的帐号名称。
远程连结
->mysql -h hostname -u username -p
hostname 是 MySQL 主机的名称。
显示全部的数据库
SHOW DATABASES;
mysql 是 MySQL 用来储存帐号和权限的数据库,不能删除。
选择 ......
1、选取最适用的字段属性
MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快。因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽可能小。例如,在定义邮政编码这个字段时,如果将其设置为CHAR(255),显然给数据库增加了不必要的空间,甚至使 ......
要不出现乱码,就要保持数据库和页面的编码格式一致.我全部使用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 ......