

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I avoid “repair with keycache” in MySQL?
To avoid repair with keycache in MySQL, you need to follow the below syntax −
create table yourNewTableName as (select *from yourOldTableName); alter table yourNewTableName add index(yourCoumnName);
Let us first create a table −
mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(20), StudentLastName varchar(20) ); Query OK, 0 rows affected (0.24 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('John','Doe'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('David','Miller'); Query OK, 1 row affected (0.05 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+------------------+-----------------+ | StudentId | StudentFirstName | StudentLastName | +-----------+------------------+-----------------+ | 1 | John | Doe | | 2 | David | Miller | +-----------+------------------+-----------------+ 2 rows in set (0.00 sec)
Step 1 − Following is the query to avoid “repair with keycache” in MySQL.
mysql> create table DemoTable as (select *from DemoTable); Query OK, 2 rows affected (0.34 sec) Records: 2 Duplicates: 0 Warnings: 0
Step 2 − Now, use alter table
mysql> alter table DemoTable add index(StudentFirstName); Query OK, 2 rows affected (0.57 sec) Records: 2 Duplicates: 0 Warnings: 0
- Related Questions & Answers
- How can I avoid too many OR statements in a MySQL query?
- How to repair MySQL tables from the command line?
- How can I create MySQL stored procedure with IN parameter?
- How can I order in group but randomly with MySQL?
- Can I use SUM() with IF() in MySQL?
- How can I start MySQL Server?
- How can I shutdown MySQL Server?
- How can I use SPACE() function with MySQL WHERE clause?
- How can I create MySQL stored procedure with OUT parameter?
- How can I create MySQL stored procedure with INOUT parameter?
- How can I view cascades in MySQL?
- How can we avoid a deadlock in Java?
- How can I use another MySQL function/s with REPEAT() function?
- How can I select the row with the highest ID in MySQL?
- How can I replace & with an ampersand in my MySQL database?
Advertisements