PROBLEM: How to modify or change the database’s charset
SOLUTION; charset of dbase – to change this ALTER DATABASE
Archive for the ‘mysql’ Category
How to change charset of database
Friday, May 22nd, 2009 by dreamluverzoptimizing mysql database
Friday, May 22nd, 2009 by dreamluverzWhat are Indexes?
Indexes are organized versions of specific columns in your tables. MySQL uses indexes to facilitate quick retrieval of records. With indexes, MySQL can jump directly to the records you want. Without any indexes, MySQL has to read the entire data file to find the correct record(s). Here’s an example.
Suppose we created a table called “people”:
CREATE TABLE people (
peopleid SMALLINT NOT NULL,
name CHAR(50) NOT NULL
);
Then we insert 1000 different names into the table in a completely random, non-alphabetic order. A small portion of the data file may be represented like this:

Types of Indexes
There are several types of indexes to choose from in MySQL:
[Note: Full query lists and examples can be found at the end of this article.]
- “Normal” Indexes – “Normal” indexes are the most basic indexes, and have no restraints such as uniqueness. These can be added by creating an index (
CREATE INDEX name_of_index ON tablename (columns_to_index);), altering the table (ALTER TABLE tablename ADD INDEX [name_of_index] (columns_to_index);), or when creating the table (CREATE TABLE tablename ( [...], INDEX [name_of_index] (columns_to_index) );). - Unique Indexes – Unique indexes are the same as “Normal” indexes with one difference: all values of the indexed column(s) must only occur once. These can be added by creating an index (
CREATE UNIQUE INDEX name_of_index ON tablename (columns_to_index);), altering the table (ALTER TABLE tablename ADD UNIQUE [name_of_index] (columns_to_index);) or when creating the table (CREATE TABLE tablename ( [...], UNIQUE [name_of_index] (columns_to_index) );). - Primary keys – Primary keys are unique indexes that must be named
“PRIMARYâ€. If you have usedAUTO_INCREMENTcolumns, you’re probably familiar with these. These indexes are almost always added when creating the table (CREATE TABLE tablename ( [...], PRIMARY KEY (columns_to_index) );), but may also be added by altering the table (ALTER TABLE tablename ADD PRIMARY KEY (columns_to_index);). Note that you may only have one primary key per table. - Full-text indexes – Full-text indexes are used by MySQL in full-text searches. Because full-text search is so new and would add unnecessary complexity to this article, I won’t explain it here. Should you want more information, visit the MySQL documentation [2].
monetary data: decimal vs. double
Friday, May 22nd, 2009 by dreamluverzThe DECIMAL and NUMERIC data types are used to store exact numeric data values. In MySQL, NUMERIC is implemented as DECIMAL. These types are used to store values for which it is important to preserve exact precision, for example with monetary data.
Related article: http://dreamluverz.com/developers-tools/mysql/double-float-decimal
mysql error: 1005
Friday, May 22nd, 2009 by dreamluverz ERROR 1005: Can’t create table (errno: 121) Help
Solution: For some reasons this error appeared for the first time and caused my mysql to drop. But it only happens when clicking on a specific table. So I recreated the table but can’t use the same name again so what i did backup everything with the new table name for that specific table and recreate the database.
It helps. On some forum they’re actually talking of foreign keys or duplicate keys but i just recreate it.
ISNULL() in mysql
Friday, May 22nd, 2009 by dreamluverzSELECT * FROM table1 LEFT JOIN table2 ON table2 .folder_id = table1.id
WHERE members_folders.mem_id=’1100′ AND ISNULL(table2.id)
-get records from table1 that doesn’t have a record on table2
ISNULL() – Test whether the argument is NULL
source: http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_isnull



