Saturday, April 25, 2009

Personality Development - a slide I liked

Too much information about the MySQL TIMESTAMP

Source:http://www.gizmola.com/blog/archives/93-Too-much-information-about-the-MySQL-TIMESTAMP.html

The MySQL timestamp is an oddity, being both a mySQL "Data Type" as well as a type of specialty column that provides a built in default. It doesn't help matters, that the timestamp was changed significantly around mysql version 4.1.

The Old TIMESTAMP


In older mysql versions, the TIMESTAMP was not in the same format as a DateTime column, and you could also set up truncation by defining the TIMESTAMP to have a fixed size. For example, you could define a TIMESTAMP column to be a TIMESTAMP(4) which would then only store the 4 digit Year portion of a DateTime value. I won't go into much detail on the pre version 4.1 TIMESTAMP, however, if you're stuck with an older version of MySQL I recommend you read the manual carefully before you attempt to use any of the information here. I'm going to concentrate on the current TIMESTAMP.

TIMESTAMP Properties


At its most fundamental, the TIMESTAMP is really nothing more than a Unix TimeStamp, which is to say, that internally it is stored as an integer value of seconds. Where a MySQL DATETIME column can be used to store any date and time from Jan 1, 1000 to 12/31/9999, the TIMESTAMP is limited in the same ways that the Unix timestamp is currently limited -- it can only store values from Jan 1, 1970 to Jan 9, 2038.

Those familiar with Unix design, will recognize the Jan 9, 2038 date as being the next big "Y2K" computing panic, and if you're young enough, you may realize a large payday in your future, selling remediation services to companies in roughly another 28 years. The folks at http://www.y2038.com/ are already estimating this to be as much as a 10 trillion dollar jackpot, although no doubt by that time most of the coding will be done by the Morlocks from their underground cave cities. Outsourcing of IT to Morlocks will be a major industry trend by the year 2020, mark my words.

Saving bytes


MySQL stores a timestamp as a 32 bit integer, which of course requires 4 bytes of storage. This is one reason why you might want to use a TIMESTAMP over a DATETIME, which requires 8 bytes. Primarily, people look to the TIMESTAMP because, as its name implies, it can be utilized to stamp the time on a row at the point it's inserted. Let's take a look at a mysql TIMESTAMP in action.

First let's create a table with a single TIMESTAMP column in it. We will not refer to this column, and observe what happens when we insert a new row into the table. In case you're keeping score:
mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.0.45 |
+-----------+
1 row in set (0.00 sec)


  1. CREATE TABLE atimestamp (id INT PRIMARY KEY AUTO_INCREMENT, justnow DATETIME, created TIMESTAMP);


mysql> describe atimestamp;
+---------+-----------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-----------+------+-----+-------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| justnow | datetime | YES | | NULL | |
| created | timestamp | NO | | CURRENT_TIMESTAMP | |
+---------+-----------+------+-----+-------------------+----------------+
3 rows in set (0.00 sec)


So here we have the table, along with a datetime column that we will set to the magic value of NOW().

mysql> insert into atimestamp (justnow) values (NOW());
Query OK, 1 row affected (0.00 sec)

mysql> select * from atimestamp;
+----+---------------------+---------------------+
| id | justnow | created |
+----+---------------------+---------------------+
| 1 | 2009-04-23 14:29:58 | 2009-04-23 14:29:58 |
+----+---------------------+---------------------+
1 row in set (0.00 sec)


Just as one would hope, MySQL automatically sets the value of TIMESTAMP column I named "created" to be the same as the Server time. So if our primary goal is to have a column that keeps track of when the row was created, our TIMESTAMP does a great job.

Or does it?


Stopping an UPDATE from overwriting the TIMESTAMP



What happens if, at later time, we UPDATE a column in the table?

mysql> update atimestamp set justnow = NOW();
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from atimestamp;
+----+---------------------+---------------------+
| id | justnow | created |
+----+---------------------+---------------------+
| 1 | 2009-04-23 14:30:32 | 2009-04-23 14:30:32 |
+----+---------------------+---------------------+
1 row in set (0.00 sec)


This is not good. Our created time has been lost, because the default behavior of a TIMESTAMP is to update the value to NOW(), any time the row is changed.

The TIMESTAMP Defaults


Setting a column to be a MySQL TIMESTAMP is equivalent to also giving the column a default of CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP. For those not familiar with Mysql Defaults, when creating a table, you can specify a default value for a column to receive if it is not specifically assigned a value during an INSERT. You do this using the DEFAULT keyword, and for all columns other than a TIMESTAMP this must be a constant value. Timestamp columns can specify the CURRENT_TIMESTAMP default which tells mySQL to default this column to NOW().

Stopping UPDATE on TIMESTAMP


The only way not to get the update behavior is to specifically declare the TIMESTAMP to DEFAULT CURRENT_TIMESTAMP. This seems to me to defeat the purpose of having the default behavior in the first place but might be understandable if it was possible for you to have a second TIMESTAMP column, perhaps named "updated".

Unfortunately, you can't have one TIMESTAMP with DEFAULT CURRENT_TIMESTAMP, and a second one with ON UPDATE CURRENT_TIMESTAMP. More often than not, what people really want is only the DEFAULT CURRENT_TIMESTAMP behavior, so it's very important to remember this workaround, if you are using a TIMESTAMP as for example, the "signup date" in a User table. See this in action below:

  1. CREATE TABLE atimestamp (id INT PRIMARY KEY AUTO_INCREMENT, justnow DATETIME, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP);


mysql> describe atimestamp;
+---------+-----------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-----------+------+-----+-------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| justnow | datetime | YES | | NULL | |
| created | timestamp | NO | | CURRENT_TIMESTAMP | |
+---------+-----------+------+-----+-------------------+----------------+
3 rows in set (0.00 sec)

mysql> insert into atimestamp (justnow) values (NOW());
Query OK, 1 row affected (0.00 sec)

mysql> select * from atimestamp;
+----+---------------------+---------------------+
| id | justnow | created |
+----+---------------------+---------------------+
| 1 | 2009-04-23 18:15:38 | 2009-04-23 18:15:38 |
+----+---------------------+---------------------+
1 row in set (0.00 sec)

mysql> update atimestamp set justnow = NOW();
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from atimestamp;
+----+---------------------+---------------------+
| id | justnow | created |
+----+---------------------+---------------------+
| 1 | 2009-04-23 18:15:56 | 2009-04-23 18:15:38 |
+----+---------------------+---------------------+
1 row in set (0.00 sec)



Now we have automatic timestamping on INSERT, but without the timestamp being overwritten on UPDATE.

What about an UPDATE only TIMESTAMP?


Perhaps there's a really good reason to dedicate a TIMESTAMP to only apply the time when the row is updated. I can't think of one, but for the sake of completeness, here's how you can define the Default.

  1. CREATE TABLE atimestamp (id INT PRIMARY KEY AUTO_INCREMENT, justnow DATETIME, updated TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP);


mysql> describe atimestamp;
+---------+-----------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-----------+------+-----+---------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| justnow | datetime | YES | | NULL | |
| updated | timestamp | NO | | 0000-00-00 00:00:00 | |
+---------+-----------+------+-----+---------------------+----------------+
3 rows in set (0.00 sec)

mysql> insert into atimestamp (justnow) values (NOW());
Query OK, 1 row affected (0.00 sec)

mysql> select * from atimestamp;
+----+---------------------+---------------------+
| id | justnow | updated |
+----+---------------------+---------------------+
| 1 | 2009-04-24 23:33:56 | 0000-00-00 00:00:00 |
+----+---------------------+---------------------+
1 row in set (0.01 sec)

mysql> update atimestamp set justnow = NOW();
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from atimestamp;
+----+---------------------+---------------------+
| id | justnow | updated |
+----+---------------------+---------------------+
| 1 | 2009-04-24 23:34:19 | 2009-04-24 23:34:19 |
+----+---------------------+---------------------+
1 row in set (0.00 sec)



Many Timestamps, but only one that's magical


MySQL will allow you to declare multiple columns of type TIMESTAMP, but only the first timestamp in the table will have the built in Default.

  1. CREATE TABLE bigtimestamp (id INT PRIMARY KEY AUTO_INCREMENT, justnow DATETIME, created TIMESTAMP, updated TIMESTAMP, verified TIMESTAMP);


mysql> describe bigtimestamp;
+----------+-----------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------+------+-----+---------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| justnow | datetime | YES | | NULL | |
| created | timestamp | NO | | CURRENT_TIMESTAMP | |
| updated | timestamp | NO | | 0000-00-00 00:00:00 | |
| verified | timestamp | NO | | 0000-00-00 00:00:00 | |
+----------+-----------+------+-----+---------------------+----------------+
5 rows in set (0.00 sec)

mysql> insert into bigtimestamp (justnow) values (NOW());
Query OK, 1 row affected (0.01 sec)

mysql> select * from bigtimestamp;
+----+---------------------+---------------------+---------------------+---------------------+
| id | justnow | created | updated | verified |
+----+---------------------+---------------------+---------------------+---------------------+
| 1 | 2009-04-24 23:39:19 | 2009-04-24 23:39:19 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
+----+---------------------+---------------------+---------------------+---------------------+
1 row in set (0.00 sec)


Even with this limitation, it may still be a good idea to declare your Date columns as TIMESTAMP type, as the savings of 4 bytes per date per row can easily be significant if your table will have a lot of rows in it.

Single table Insert and Update Timestamp Workaround


It is actually possible to trick mysql into providing the default timestamp behavior for "created' and "updated" columns, despite the documented limitation of only having one default timestamp per table. If you define the first timestamp column to have a default of 0, while also being NOT NULL, you can trick mysql into supplying today's date by explicitly setting the column to be NULL on insert. In this case, mySQL decides to be helpful and for no logical reason, to set the value to NOW(). The second TIMESTAMP which has the explict TIMESTAMP defaults, works normally, and is set to NOW() on insert and update.

  1. CREATE TABLE atimestamp (id INT PRIMARY KEY AUTO_INCREMENT, justnow DATETIME, created TIMESTAMP NOT NULL DEFAULT 0, updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);


mysql> describe atimestamp;
+---------+-----------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-----------+------+-----+---------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| justnow | datetime | YES | | NULL | |
| created | timestamp | NO | | 0000-00-00 00:00:00 | |
| updated | timestamp | NO | | CURRENT_TIMESTAMP | |
+---------+-----------+------+-----+---------------------+----------------+
4 rows in set (0.00 sec)

mysql> insert into atimestamp (justnow) values (NOW());
Query OK, 1 row affected (0.00 sec)

mysql> select * from atimestamp;
+----+---------------------+---------------------+---------------------+
| id | justnow | created | updated |
+----+---------------------+---------------------+---------------------+
| 1 | 2009-04-24 23:54:23 | 0000-00-00 00:00:00 | 2009-04-24 23:54:23 |
+----+---------------------+---------------------+---------------------+
1 row in set (0.00 sec)

mysql> insert into atimestamp (created, justnow) values (NULL, NOW());
Query OK, 1 row affected (0.00 sec)

mysql> select * from atimestamp;
+----+---------------------+---------------------+---------------------+
| id | justnow | created | updated |
+----+---------------------+---------------------+---------------------+
| 1 | 2009-04-24 23:54:23 | 0000-00-00 00:00:00 | 2009-04-24 23:54:23 |
| 2 | 2009-04-24 23:55:35 | 2009-04-24 23:55:35 | 2009-04-24 23:55:35 |
+----+---------------------+---------------------+---------------------+
2 rows in set (0.00 sec)

mysql> update atimestamp set justnow=NOW() WHERE id = 2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from atimestamp;
+----+---------------------+---------------------+---------------------+
| id | justnow | created | updated |
+----+---------------------+---------------------+---------------------+
| 1 | 2009-04-24 23:54:23 | 0000-00-00 00:00:00 | 2009-04-24 23:54:23 |
| 2 | 2009-04-24 23:56:48 | 2009-04-24 23:55:35 | 2009-04-24 23:56:48 |
+----+---------------------+---------------------+---------------------+
2 rows in set (0.00 sec)


While this technique works at present, I would consider it an undocumented hack, based on a side effect. It also requires you to explicitly specify NULL in the values for the created column. If you forget to reference the column in the INSERT statement, it will not set the value to NOW() as illustrated above. This technique works for now, but who knows what will happen in future versions of mySQL? Use at your own risk.

Monday, April 20, 2009

PST Password Recovery Software

Stellar Phoenix Outlook PST Repair Software is designed to recover lost or forgotten PST file password instantly. Stellar also provide recovery of your lost or corrupt outlook email file and s allow splitting PST file into smaller files when PST file size exceed from 2 GB and Outlook can’t recognize the PST files. This Software completely recovers all of Microsoft Outlook Problems.

Microsoft Outlook is a Personal information manager used to receive confidential, personal and business important client mails .It used mainly for email, contacts, notes, messages, calendar entries, journal all these features are stores in Personal Storage Table (PST). PST is a password protection feature also adds to its data security. To protect your client mail and other outlook features you must set a password. The PST password may get lost or forgotten. This is the time when you need your outlook password recovery.
Key Features:
  • Instantaneous PST password recovery
  • Mail account password recovery
  • Generation of several passwords for a single file
  • Can save recovered passwords in notepad or any other text editor
  • PST password recovery options for Outlook 2007, 2003, 2002, 2000 and 98
  • Passwords having special characters and numbers can be recovered
  • Interactive interface
  • PST repair ability
  • Can split PST into smaller PST files
  • Live Update feature to help software constantly updated
Cases, when PST password recovery may be needed:
  • Lost or forgotten the PST or mail account password
  • The bit of paper or file is missing where the password was written
  • Password was set a long ago and now you have no clue of
  • Outlook is not accepting your password

Stellar Phoenix Outlook PST Repair Software has designed the program to recover forgotten, lost or missing PST password in any case along with intuitive interface. PST Password Recovery program gives a set of new passwords to access PST.

Stellar Phoenix Application is most powerful to recovery lost Password. It supports Outlook 2007, 2003, 2002 and 2000. The application can also be used to split large PST file into smaller parts. This Stellar product is efficient enough to give you PST password recovery, PST repair and split PST options in a single fusion. All three jobs are productive, valuable and viable through Stellar Phoenix Outlook PST Repair Software. You can download free version of windows data recovery then please Visit here…..



Vizuality Marketing and Design Doncaster
Vizualitys marketing, PR, public relations, graphic and media design expertise will transform your ideas into brand development and corporate identity. Based in Doncaster, South Yorkshire we are leaders in our field.Design and print services also avaiable.

Instant Blaupunkt Radio Codes
It`s so easy to get your Blaupunkt Radio Code! And our fully automated process will guide you through the entire procedure. After you have entered your radio details into the boxes provided, you will be directed to the PayPal website to make a secure payment, and once completed, your Blaupunkt Radio Code will be ready for you to view Online. We will also send a copy via E-Mail for your to print off for your records.
Data Recovery Software
Buy award winning hard drive data recovery software and utilities or try the demos free. Stellar offers a complete solution of file recovery software and lost data restoration programs for Windows (Windows 95, 98, ME, NT, 2000, 2003, XP), Apple Macintosh, Novell, Linux, Unix operating system and FAT, NTFS,NTFS5,HFS, HFS+, NWFS, EXT2 and EXT3 file systems.

Data Recovery Services
Offers data recovery, data recovery services from crashed hard drives, laptops and damaged Mac drive. Stellar provides data recovery in New Jersey, data recovery services in USA, ASIA & European Countries.

File Recovery
Stellar offers you hard drive disk & file recovery and protection software and data file eraser utility for complete protection of your data.

Partition Recovery
Windows data recovery software, an easy to use NTFS & FAT partition recovery Utility that examines inaccessible hard drives for damages and corruptions and recovers the data back.

Hard Drive Recovery
Try our data recovery software. Available are Data recovery software download for windows 95,98,Me,Novell,Unix,Linux,windows NT,XP,2000 which give you easy recovery decision of try before you buy.

Atlassian offering licenses to Confluence and Jira for $5

Atlassian has made a name for itself with its java based opensource development tools. Confluence (an Intranet Wiki tool) and Jira (a bug tracker) are two of the companies Flagship products. Calling this their "Atlassian Stimulus Project", they are offering 5 user licenses for $5 each, and donating the proceeds to "Room to Read".

I have used both Confluence and Jira as well as Fisheye, and they are all excellent products, that don't quite have competitors in the LAMP world. Any small development company will find Jira a great bug tracker, capable of complex workflows. Confluence is a Wiki on steriods, that can be used in a variety of ways as an interanet tool, and for design, and internal and external documentation. Both products are modular and there are a substantial number of plugins that increase their functionality. I'd urge any small company to take a look at this offer, which is only good for the next 5 days.

Visit http://www.atlassian.com/starter/ for the details.


Share Technology Documents - Upload and download technology documents online. Share technology documents and reports with friends at latestt.com

Thursday, April 9, 2009

Microsoft Q&A: Running PHP on Windows Server 2008

Microsoft has been recently engaging in a number of open source projects. They have been working on enhancing performance, security and stability of PHP applications on Windows Server platforms.

In relation to that we would, in cooperation with Microsoft, invite you to trial a Windows based web stack consisting of IIS 7, PHP 5 and SQL Server. Via the PHP on WS 2008 website you will be able to request a 30-day trial with a Microsoft hosting partner, and you'll be able to request a downloadable trial for installation on your own computer. You will be able to find more information on that page as well. Alternatively, if you have Windows Vista you can install IIS 7 and test its FastCGI capabilities.

We have setup a dedicated board, PHP on Windows Server 2008 - Microsoft Q&A, where you will be able to post your feedback and discuss it in general. Commencing April 20th, Hank Janssen and his team from the Microsoft Open Source Center will be available to respond on the feedback, and answer whatever questions that may arise.

We hope you will take part in this Q&A to enhance PHP, and specifically to enhance it on the Windows platform.

Do feel free to ask in the board if you have any questions.

PHP Web Development services at Script2please.com

SEO Web Design - Web Rankings - UK based White Label SEO Web Design Agency. Search Engine Optimisation, Search Engine Marketing, Web Design, PPC, Conversion Specialists.

Web Design Agency - Web Design, Web Development & Web Marketing Agency based in Surrey

Media Buying - Media planning & buying, including digital from Space & Time Media.

SEO - Learn how search engine marketing, PPC management, conversion enhancement and web analytics tracking can boost your online profitability. Visit our website and harness the web with Alkemi