<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sean&#039;s Blog &#187; Databases</title>
	<atom:link href="http://seanbehan.com/tag/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Dump MySQL Database without Drop Table Syntax</title>
		<link>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/</link>
		<comments>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 00:57:34 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[flags]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=781</guid>
		<description><![CDATA[Output .sql file for MySQL but without the drop table syntax before table name use the &#8211;skip-add-drop-table flag mysqldump -u root -p database_name --skip-add-drop-table --skip-lock-tables &#62; database_name.sql]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fdatabases%2Fdump-mysql-database-without-drop-table-syntax%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Dump MySQL Database without Drop Table Syntax" data-url="http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Output .sql file for MySQL but without the drop table syntax before table name use the &#8211;skip-add-drop-table flag</p>
<pre class="wp-code-highlight prettyprint">
mysqldump -u root -p database_name --skip-add-drop-table --skip-lock-tables &gt; database_name.sql
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Managing Timestamps in MySQL with a Trigger</title>
		<link>http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/</link>
		<comments>http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 17:13:51 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[timestamping]]></category>
		<category><![CDATA[triggers]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=707</guid>
		<description><![CDATA[MySQL doesn&#8217;t support having two columns with time stamping on both initialization and/or on updating at the same time. It would be nice to be able to do *this* where the created_at column gets the current_timestamp on initialization and the updated_at gets changed on updating the row. # like so doesn't work... create table entries( [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fdatabases%2Fmanaging-timestamps-in-mysql-with-a-trigger%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Managing Timestamps in MySQL with a Trigger" data-url="http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>MySQL doesn&#8217;t support having two columns with time stamping on both initialization and/or on updating at the same time. It would be nice to be able to do *this* where the created_at column gets the current_timestamp on initialization and the updated_at gets changed on updating the row.</p>
<pre class="wp-code-highlight prettyprint">
# like so doesn't work...
create table entries(
  body blob,
  created_at datetime default current_timestamp,
  updated_at timestamp default current_timestamp on update current_timestamp
);
</pre>
<p>Seems like a feature a lot of folks would like. There are two work-arounds. The first is baking it into your application code with something like</p>
<pre class="wp-code-highlight prettyprint">
create table entries(
  body blob,
  created_at datetime default null,
  updated_at timestamp default current_timestamp on update current_timestamp
);
insert into entries (body, created_at) values ('hello world', now());
</pre>
<p>The second way is to create a trigger and call the trigger on your insert action on a row.</p>
<pre class="wp-code-highlight prettyprint">
create table entries (
  body  blob,
  created_at datetime default null,
  updated_at timestamp default null on update current_timestamp
);
create trigger init_created_at before insert on entries for each row set new.created_at = now();
</pre>
<p>Now whenever a new row is created the trigger will be executed and set the time to the current timestamp. You can forget about the created_at column in your code because it&#8217;s not meant to be changed.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

