MyISAM

Create an index on a MySQL column based on the length its contents?

我的未来我决定 提交于 2019-12-23 23:13:04
问题 How do I create an index on a column in MySQL v 5.0 (myisam db engine) based upon the length of its value its a TEXT data type up to 7000 characters, do I have to add another column with the length of the first column? 回答1: Yes, as MySQL doesn't support function-based indexes (like ADD INDEX myIndex(LENGTH(text))) , you'll need a new int column and define a trigger to auto-update it after inserts and updates. 回答2: Sounds like a good approach to me (sorry don't know mysql, but in oracle you

InnoDB or MyISAM - Why not both?

你离开我真会死。 提交于 2019-12-23 11:55:06
问题 I've read various threads about which is better between InnoDB and MyISAM . It seems that the debates are to use or the other. Is it not possible to use both, depending on the table? What would be the disadvantages in doing this? As far as I can tell, the engine can be set during the CREATE TABLE command. Therefore, certain tables which are often read can be set to MyISAM, but tables that need transaction support can use InnoDB. 回答1: You can have both MyISAM and InnoDB tables in the same

Problem creating foreign keys in mySql

点点圈 提交于 2019-12-23 02:54:15
问题 I created a foreign key in my sql by the following statemnt.. ALTER TABLE `users` ADD FOREIGN KEY ( `id`) REFERENCES `user_login` (`user_id`) ON DELETE CASCADE ; The creation appears to succeed then after that I execute a delete statement DELETE From user_login WHERE user_id = 1576; yet in users the row still exists that is referencing that. I open up the mysql workbench and it doesn't show any signs that the foreign key was created. Does anyone know why this would be? Or what I am doing

Deleting related records in MySQL

本小妞迷上赌 提交于 2019-12-23 02:25:08
问题 I have two MySQL (MyISAM) tables: Posts: PostID(primary key), post_text, post_date, etc. Comments: CommentID(primary key), comment_text, comment_date, etc. I want to delete all the comments in the "Comments" table belonging to a particular post, when the corresponding post record is deleted from the "Posts" table. I know this can be achieved using cascaded delete with InnoDB (by setting up foreign keys). But how would I do it in MyISAM using PHP? 回答1: DELETE Posts, Comments FROM Posts INNER

When to LOCK TABLES in MySQL (MyISAM tables)?

淺唱寂寞╮ 提交于 2019-12-22 10:20:16
问题 Is the internal locking of MySQL sufficient for a small to medium sized website? My tables are MyISAM. There might be a few hundred people concurrently hitting a specific table with SELECT'S and INSERT's. None of the INSERT/UPDATE queries would overlap. That is, no two users will be updating the same comment ID. INSERT's/UPDATE's would be one-off operations---there would be no reading of data and performing additional operations within the same query. Specifically, I am setting up a comment

mysql面试题

孤街醉人 提交于 2019-12-22 03:04:26
1、 MySQL 的复制原理以及流程 基本原理流程,3个线程以及之间的关联; 2、 mysql 中myisam与innodb的区别,至少5点 (1)、问5点不同; (2)、innodb引擎的4大特性 (3)、2者selectcount(*)哪个更快,为什么 3、MySQL中varchar与char的区别以及varchar(50)中的50代表的涵义 (1)、varchar与char的区别 (2)、varchar(50)中50的涵义 (3)、int(20)中20的涵义 (4)、mysql为什么这么设计 4、问了innodb的事务与日志的实现方式 (1)、有多少种日志; (2)、事物的4种隔离级别 (3)、事务是如何通过日志来实现的,说得越深入越好。 5、问了MySQL binlog的几种日志录入格式以及区别 (1)、binlog的日志格式的种类和分别 (2)、适用场景; (3)、结合第一个问题,每一种日志格式在复制中的优劣。 6、问了下MySQL 数据库 cpu飙升到500%的话他怎么处理? (1)、没有经验的,可以不问; (2)、有经验的,问他们的处理思路。 7、sql优化 (1)、explain出来的各种item的意义; (2)、profile的意义以及使用场景; 8、备份计划,mysqldump以及xtranbackup的实现原理 (1)、备份计划; (2)、备份恢复时间; (3

MySQL 20个经典面试题

我是研究僧i 提交于 2019-12-22 03:04:11
1、MySQL的复制原理以及流程 基本原理流程,3个线程以及之间的关联; 1. 主:binlog线程——记录下所有改变了数据库数据的语句,放进master上的binlog中; 2. 从:io线程——在使用start slave 之后,负责从master上拉取 binlog 内容,放进 自己的relay log中; 3. 从:sql执行线程——执行relay log中的语句; 2、MySQL中myisam与innodb的区别,至少5点 (1)、问5点不同; 1>.InnoDB支持事物,而MyISAM不支持事物 2>.InnoDB支持行级锁,而MyISAM支持表级锁 3>.InnoDB支持MVCC, 而MyISAM不支持 4>.InnoDB支持外键,而MyISAM不支持 5>.InnoDB不支持全文索引,而MyISAM支持。 (2)、innodb引擎的4大特性 插入缓冲(insert buffer),二次写(double write),自适应哈希索引(ahi),预读(read ahead) (3)、2者selectcount(*)哪个更快,为什么 myisam更快,因为myisam内部维护了一个计数器,可以直接调取。 3、MySQL中varchar与char的区别以及varchar(50)中的50代表的涵义 (1)、varchar与char的区别 char是一种固定长度的类型

MySQL面试题收集

走远了吗. 提交于 2019-12-22 03:03:54
1、MySQL的复制原理以及流程 基本原理流程,3个线程以及之间的关联; 1. 主:binlog线程——记录下所有改变了数据库数据的语句,放进master上的binlog中; 2. 从:io线程——在使用start slave 之后,负责从master上拉取 binlog 内容,放进 自己的relay log中; 3. 从:sql执行线程——执行relay log中的语句; 2、MySQL中myisam与innodb的区别,至少5点 (1)、问5点不同; 1>.InnoDB支持事物,而MyISAM不支持事物 2>.InnoDB支持行级锁,而MyISAM支持表级锁 3>.InnoDB支持MVCC, 而MyISAM不支持 4>.InnoDB支持外键,而MyISAM不支持 5>.InnoDB不支持全文索引,而MyISAM支持。 (2)、innodb引擎的4大特性 插入缓冲(insert buffer),二次写(double write),自适应哈希索引(ahi),预读(read ahead) (3)、2者selectcount(*)哪个更快,为什么 myisam更快,因为myisam内部维护了一个计数器,可以直接调取。 3、MySQL中varchar与char的区别以及varchar(50)中的50代表的涵义 (1)、varchar与char的区别 char是一种固定长度的类型

mysql基本面试题

爱⌒轻易说出口 提交于 2019-12-22 03:03:34
1、MySQL的复制原理以及流程 基本原理流程,3个线程以及之间的关联; 1. 主:binlog线程——记录下所有改变了数据库数据的语句,放进master上的binlog中; 2. 从:io线程——在使用start slave 之后,负责从master上拉取 binlog 内容,放进 自己的relay log中; 3. 从:sql执行线程——执行relay log中的语句; 2、MySQL中myisam与innodb的区别,至少5点 (1)、问5点不同; 1>.InnoDB支持事物,而MyISAM不支持事物 2>.InnoDB支持行级锁,而MyISAM支持表级锁 3>.InnoDB支持MVCC, 而MyISAM不支持 4>.InnoDB支持外键,而MyISAM不支持 5>.InnoDB不支持全文索引,而MyISAM支持。 (2)、innodb引擎的4大特性 插入缓冲(insert buffer),二次写(double write),自适应哈希索引(ahi),预读(read ahead) (3)、2者selectcount(*)哪个更快,为什么 myisam更快,因为myisam内部维护了一个计数器,可以直接调取。 3、MySQL中varchar与char的区别以及varchar(50)中的50代表的涵义 (1)、varchar与char的区别 char是一种固定长度的类型

Waiting for table level lock on a MySQL table

你。 提交于 2019-12-21 20:17:22
问题 The last few days, at random times my website has become very slow. I started to investigate the best I could. I saw that the MySQL process was using 85 - 95% of the available memory of my server (should I upgrade my memory also?). I checked my MySQL process log, and I noticed a huge list of queries with: Waiting for table level lock But what I also noticed, what that ALL of these queries with "table level lock", was only queries which had something to do with my table called users . I have