Archive for the 'Databases' Category

How to Rename or Move Oracle Tablespace Datafile to Another Location

Saturday, August 4th, 2007

Oracle database does not provide an easy user interface to rename a datafile of tablespace, nor database administrator can easily move or relocate the datafile to another location or directory that different from original location on creation of database. The rename or move place task has to be performed via Oracle SQLPlus command line interface. However, if the operation is performed when the tablespace which owns the datefile is online, error will occur.

Continue reading How to Rename or Move Oracle Tablespace Datafile to Another Location » » »


How Drop Tablespace and Recover Oracle Database When Accidentally Delete Datafile

Saturday, August 4th, 2007

Accident may happens, even though it’s costly one. This is especially the case in Oracle database, which stores the database objects physically in data files on hard disk. Fast hand administrators may accidentally delete some of the datafiles, or the datafiles may get corrupted or unreadable on hard disk failure. You may get also some missing datafiles after database recovery process. In any case, missing a or a few datafiles will cause Oracle database to fail to startup, rendering the whole DB inaccessible.

Continue reading How Drop Tablespace and Recover Oracle Database When Accidentally Delete Datafile » » »

How to Remove and Drop Datafiles from Tablespace in Oracle Database

Saturday, August 4th, 2007

Oracle RDBMS databases stores data logically in the form of tablespaces and physically in the form of data files. The datafiles are added to the tablespaces as database space requirement grows bigger. However, there are several reasons you may want to remove or delete data files from a tablespace. Such as accidentally add a wrongly sized or unwanted datafile to a tablespace, or the data space usage has became smaller and some data files want to be removed, or attempt to recover Oracle database which fails to start due to missing or corrupted datafiles by removing them, Oracle does not provide an easy way or user interface to delete or drop datafiles from a tablespace. Once a datafile is made part of a tablespace, it can no longer be detached or removed from the tablespace, albeit there are several workarounds.

Continue reading How to Remove and Drop Datafiles from Tablespace in Oracle Database » » »

How to Backup and Restore (Export and Import) MySQL Databases Tutorial

Saturday, July 21st, 2007

phpMyAdmin can be used to export or backup MySQL databases easily. However, if the database size is very big, it probably won’t be a good idea. phpMyAdmin allows users to save database dump as file or display on screen, which involves exporting SQL statements from the server, and transmitting the data across slower network connection or Internet to user’s computer. This process slow the exporting process, increase database locking time and thus MySQL unavailability, slow the server and may simply crash the Apache HTTPD server if too many incoming web connections hogging the system’s resources.

Continue reading How to Backup and Restore (Export and Import) MySQL Databases Tutorial » » »


MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length

Monday, July 9th, 2007

When creating a new table or altering an existing table with primary keys, unique constraints and indexes, or when defining a new index with Alter Table manipulation statement in MySQL database, the following error may occur and prohibit the the command from completing:

ERROR 1170 (42000): BLOB/TEXT column ‘field_name’ used in key specification without a key length

Continue reading MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length » » »

Remove or Trim First or Last Few Characters in MySQL Database with SQL

Monday, April 23rd, 2007

Another useful string function in MySQL database is TRIM() which will return a text string after removing the matching leading or trailing characters, also known as prefixes or suffixes. It’s been described by MySQL reference as function that returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.

Continue reading Remove or Trim First or Last Few Characters in MySQL Database with SQL » » »

How to Find and Replace Text in MySQL Database using SQL

Monday, April 23rd, 2007

MySQL database has a handy and simple string function REPLACE() that allows table data with the matching string (from_string) to be replaced by new string (to_string). This is useful if there is need to search and replace a text string which affects many records or rows, such as change of company name, postcode, URL or spelling mistake.

Continue reading How to Find and Replace Text in MySQL Database using SQL » » »

How to Escape Characters in Oracle PL/SQL Queries

Saturday, March 24th, 2007

Oracle databases reserve some special characters with specific meaning and purpose within Oracle environment. These reserved characters include _ (underscore) wild card character which used to match exactly one character, % (percentage) which used to match zero or more occurrences of any characters and ‘ (apostrophe or quotation mark) which used to mark the value supplied. These special characters will not be interpreted literally when building SQL query in Oracle, and may caused error in results returned especially when performing string search with LIKE keyword. To use these characters so that Oracle can interpret them literally as a part of string value instead of preset mean, escape character has to be assigned.

Continue reading How to Escape Characters in Oracle PL/SQL Queries » » »