Monday, June 28, 2010

database operations

http://www.1keydata.com/sql/sql-create-index.html

 A  table index helps SQL statements run faster. The syntax for creating an index is:
CREATE INDEX IDX_CUSTOMER_LAST_NAME
on CUSTOMER (Last_Name)

 
 Copying table:
CREATE TABLE copyname SELECT * FROM originalname 

Creating key across multiple columns :
alter table tbl_name add primary key(col1,col2,col3);

If there are duplicates rows in a db across this combination:
alter ignore table judgments add unique index  `idx_nm` (col1,col2,col3);
and then drop the idx: alter ignore table judgments drop idx_name



Connections:
Q)How to check the number of connections to a db ?
A) show processlist;
 
Q)How to see the current indexes?
A) show indexes from table_name;

1 comment:

  1. http://www.databasejournal.com/features/mysql/article.php/2201621/Deleting-Duplicate-Rows-in-a-MySQL-Database.htm

    ReplyDelete