<?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>drittenormalform *Beta* &#187; snippet</title>
	<atom:link href="http://drittenormalform.de/wordpress/tag/snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://drittenormalform.de/wordpress</link>
	<description>Datenbank Merkzettel und Sammlung rund um Storagethemen</description>
	<lastBuildDate>Mon, 05 Oct 2009 10:10:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Test Tabellen erstellen per PROCEDURE</title>
		<link>http://drittenormalform.de/wordpress/2009/07/17/test-tabellen-erstellen-per-procedure/</link>
		<comments>http://drittenormalform.de/wordpress/2009/07/17/test-tabellen-erstellen-per-procedure/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 07:08:18 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Helferlein]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[nützliches]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://drittenormalform.de/wordpress/?p=62</guid>
		<description><![CDATA[Ronald Bradfrods Blogeintrag über MVCC Merkwürdigkeiten in MySQL hat mich inspiriert seine Variante mal anzutesten wie er sich Tabellen mit Inhalt anlegt.
Und seine Funktion dann so anzupassen das eine Tabelle auch mit String Feldern und einem timestamp gefüllt werden kann.
Tabelle anlegen:

create table stringtab
( id int unsigned not null primary key auto_increment,
  f1 varchar(512) not [...]]]></description>
			<content:encoded><![CDATA[<p>Ronald Bradfrods Blogeintrag über <a href="http://ronaldbradford.com/blog/understanding-innodb-mvcc-2009-07-15/">MVCC Merkwürdigkeiten</a> in MySQL hat mich inspiriert seine Variante mal anzutesten wie er sich Tabellen mit Inhalt anlegt.<br />
Und seine Funktion dann so anzupassen das eine Tabelle auch mit String Feldern und einem timestamp gefüllt werden kann.</p>
<p>Tabelle anlegen:</p>
<pre>
<code>create table stringtab
( id int unsigned not null primary key auto_increment,
  f1 varchar(512) not null,
  f2 varchar(512) not null,
  ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) engine=innodb;</code>
</pre>
<p>Dann die passende Funktion:</p>
<pre>
<code>DELIMITER $$
DROP PROCEDURE IF EXISTS `fill_strings` $$
CREATE PROCEDURE `fill_strings`(in p_max int)
    DETERMINISTIC
begin
  declare counter int default 1;
  truncate table stringtab;
  insert into stringtab values (1,1,1,now());
  while counter &lt; p_max
  do
      insert into stringtab (f1, f2, ts)
          select  right (concat(counter,f1,"blah"),511),
                    right (concat(f1,"blub",f2),511),
                    from_unixtime(RAND()*1251885200)
          from stringtab;
      select count(*) from stringtab into counter;
  end while;
  select counter;
end $$
DELIMITER ;</code></code></pre>
<p>aufgerufen wird das ganze dann so:</p>
<pre><code>call fill_strings(130);</code></pre>
<p>Die Funktion gibt dann die tatsächlich eingefügten Zeilen als Rückgabewert aus.</p>
<p>Und für was man das ganze dann alles verwenden kann darauf gehe ich dann im nächsten Artikel ein  <img src='http://drittenormalform.de/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://drittenormalform.de/wordpress/2009/07/17/test-tabellen-erstellen-per-procedure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

