Web Toolbar by Wibiya

Archive for the ‘MySQL’ Category

Tips to speed up mysql queries

Monday, January 24th, 2011

1. Instead of VARCHAR, BLOB or TEXT, Use CHAR type when possible. if values of a column have constant length: MD5-hash (32 symbols), ICAO or IATA airport code (4 and 3 symbols), BIC bank code (3 symbols), etc. Data in CHAR type columns can be found faster rather than in ...

How to load data into table from a text file ?

Monday, January 24th, 2011

Here we are assuming that we have a  table with given structure: [sql] CREATE TABLE teasttable ( prkey int(11) NOT NULL auto_increment, names varchar(20), score int, timeEnter timestamp(14), PRIMARY KEY  (prkey) ); [/sql]

Mysql Tip for time based column in table

Friday, January 21st, 2011

Does the order of the columns or fields in a create table statement make a difference?  Well the answer for this is YES !!! [sql] create table testing ( a int, b int, UpdateTime timestamp, EnterTime timestamp ); [/sql]

Mysql – Merge several tables into one

Wednesday, January 19th, 2011

In mysql, you can merge several tables into one using MERGE UNION, but the fields should be same in each table [sql] CREATE TABLE `test1` ( `pkey` int(11) NOT NULL, `a` int(11) NOT NULL, `b` int(11) NOT NULL, `c` int(11) NOT NULL, PRIMARY KEY (`pkey`), UNIQUE KEY `a` (`a`,`b`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 mysql> insert into test1 (a,b,c) values (11,12,13); [/sql]

Mysql – Remove duplicate entries

Wednesday, January 19th, 2011

Assume that we have a table with given structure and data. [sql] CREATE TABLE IF NOT EXISTS testing( pid int(11) NOT NULL auto_increment, a int, b int, c int, PRIMARY KEY  (pid) ); [/sql]