
Jan 19, 2009

Storing and retrieving negative infinity in a MySQL database is accomplished by inserting an arbitrarily large negative number. Negative infinity is handy when storing default values in a database.
The following SQL statement is an example of inserting negative infinity:
INSERT INTO test(negative_infinity) VALUES('-1e500');
Here is the test table:
CREATE TABLE test (
negative_infinity DOUBLE NOT NULL
) ENGINE=INNODB character set utf8;
The value in the database is stored as the maximum negative value for the data type, double (-1.79769313486232e+308).
mysql> select * from test;
+------------------------+
| negative_infinity |
+------------------------+
| -1.79769313486232e+308 |
+------------------------+
1 row in set (0.00 sec)
In Java, the Double contsant for max infinity, directly correlates to the value stored by MySQL.

Dec 9, 2008

Updating a block of rows in MySQL can be accompished by using the “limit” function:
update TABLE_NAME set COLUMN_NAME=VALUE limit MAX;
E.g.
update products set state=false limit 10;

Dec 3, 2008

Rebuilding an InnoDB table index is easy in MySQL 5.0. Simply type:
mysql> ALTER TABLE table_name ENGINE=InnoDB;
Warning: When dealing with large databases, this can place a lot of load on your DB.

Nov 17, 2008

An example of modifying a MySQL table to increase a VARCHAR column size:
alter table TABLE_NAME modify COLUMN_NAME VARCHAR(1024) NOT NULL;
This increases COLUMN_NAME to 1024 characters.

Nov 17, 2008

In MySQL 5.0 it is possible to drop unqiue constraints but, the syntax is not incredibly intuitive.
alter table TABLE_NAME drop index UNIQUE_CONSTRAINT_NAME;
Code Ghar provides a more thorough description.

Jun 16, 2008

Below are the steps to create a MySQL database and add a user
CREATE DATABASE testdb CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'127.0.0.1' IDENTIFIED BY 'sumthin' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'localhost' IDENTIFIED BY 'sumthin' WITH GRANT OPTION;
All commands are executed in the MySQL console.