解决方案 »
- 教一个SQL语句
- 各位大哥请帮帮忙!一个关于MYSQL数据库方面的问题,我是新手,请帮忙!谢谢
- NDB Cluster同时用于读写有什么潜在问题
- 如何去掉字段中的回车换行符号
- sql 语句 ,给看看呗~
- MySQL安装配置过程中出现can't connect to mysql server on localhost 10061的错误
- 优化MySQL数据库性能的八大“妙手”
- 关于linux下MYSQL的启动????????
- mysql5.6的trigger问题
- BCB通过ODBC读取MYSQL的数据,为什么TEXT类型的值全都只显示"MEMO"??
- 求小内存mysql配置方案
- 谁有mysql-connector-java-5.0.8-bin-g.jar
select 1 from table where title='测试一下标题'
insert ignore into test1(id,name,type)(select id,name,type from test2);就举个例子 使用关键字ignore就可以了
判断是否存在,存在不插入,否则插入。很容易理解,当插入的时候,违反唯一性约束,MySQL不会尝试去执行这条语句。
这样为title字段在添加一个字段为title的hash值,然后给hash值添加唯一索引,这样先更具hash去查下数据库表里面时候有这个hash值,我想这样会快一点,以前我们做的提案系统就是这样做的,呵呵!
ADD UNIQUE index_title (title);然后再照3楼的办法,忽略会导致重复关键字错误的记录。
ADD UNIQUE index_title (title);索引文件甚至比数据文件大。
不可取数据表应该如此
id(int(10) unsigned auto_increment) class(tinyint(1)) title_crc32(int(11)) title(varchar(255))alter table tab_name add index crc32(title_crc32);
插入时 仍然先查询一次,select * from tab_name where title_crc32='new_title_crc32' and title='new_title';