Is there a MySQL command to drop all indexes except the PRIMARY index?

I have a single index database table, where the PRIMARY keyword, Type is BTREE, Unique is YES, Packed NO, Column is ID, Cardinality is 728, and Collation is A.

I have a script that runs when the page loads, which adds entries to the MySQL database table and also removes duplicates from the database table.

Below is the script section that removes duplicates:

// Removes Duplicates from the MySQL Database Table

   // Removes Duplicates from the MySQL Database Table based on 'Entry_Date' field
      mysql_query("Alter IGNORE table $TableName add unique key (Entry_Date)");

   // Deletes the added index created by the Removes Duplicates function
      mysql_query("ALTER TABLE $TableName DROP INDEX Entry_Date");

Using the Remove Duplicates command above, an additional index is added to the table. The next row command should remove this added index.

, , " ", " ", . script , .

: , script, , , ?

, , script: ,

+3
2

, , . , create table1 as ( * from table_2), , PK.

0

, , , . . . , , , - IGNORE, , , . , . , .

-. , "my_table", - my_mey_column, :

delete from my_table where my_key_column not in (select min(my_key_column) from my_table group by Entry_Date)

: - mysql, @a_horse_with_no_name

:

create temporary table if not exists tmp_posting_data select id from posting_data where 1=2 

insert into tmp_posting_data(id) select min(id) from posting_data group by Entry_Date

delete from Posting_Data where id not in (select id FROM tmp_posting_data)

, @a_horse_with_no_name. , , , :

Alter table posting_data add unique key (Entry_Date)

, RSS, "insert" "insert" "replace", ,

replace into posting_data (......) values(.....)
0

All Articles