<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Frank Seitz - Developer Logbuch - Datenbanken</title>
    <link>http://fseitz.de/blog/</link>
    <description>Notizen aus der Welt der Programmierung und Administration</description>
    <dc:language>de</dc:language>
    <generator>Serendipity 1.5.1 - http://www.s9y.org/</generator>
    <pubDate>Thu, 29 May 2025 14:24:02 GMT</pubDate>

    <image>
        <url>http://fseitz.de/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Frank Seitz - Developer Logbuch - Datenbanken - Notizen aus der Welt der Programmierung und Administration</title>
        <link>http://fseitz.de/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>SQLite client (sqlite3) mit Transaktionen und Foreign Key Constraints</title>
    <link>http://fseitz.de/blog/index.php?/archives/177-SQLite-client-sqlite3-mit-Transaktionen-und-Foreign-Key-Constraints.html</link>
            <category>SQLite</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/177-SQLite-client-sqlite3-mit-Transaktionen-und-Foreign-Key-Constraints.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=177</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=177</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;https://www.sqlite.org&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/sqlite-759x339.png&quot; width=&quot;125&quot; height=&quot;56&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://sqlite.org&quot;&gt;SQLite&lt;/a&gt; unterstützt Transaktionen und Forein Key Constraints. Diese sind bei
  Nutzung des interaktiven Clients &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://sqlite.org/cli.html&quot;&gt;sqlite3&lt;/a&gt; per Default allerdings &lt;i class=&quot;sdoc-seg-i&quot;&gt;nicht&lt;/i&gt;
  aktiviert.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine automatische Aktivierung lässt sich durch eine geeignete Startup-Datei
  erreichen:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ vi ~/.sqliterc&amp;#10;BEGIN TRANSACTION;&amp;#10;PRAGMA foreign_keys = ON;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Von nun an werden Datenänderungen per INSERT, UPDATE, DELETE auf der Datenbank
  erst permanent, wenn sie mit COMMIT bestätigt werden. Mit ROLLBACK können
  sie wahlweise verworfen werden.
&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Mon, 08 Jul 2024 21:11:19 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/177-guid.html</guid>
    
</item>
<item>
    <title>SQLite-Datenbank von einem entfernten Rechner zugreifen</title>
    <link>http://fseitz.de/blog/index.php?/archives/169-SQLite-Datenbank-von-einem-entfernten-Rechner-zugreifen.html</link>
            <category>Perl</category>
            <category>SQLite</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/169-SQLite-Datenbank-von-einem-entfernten-Rechner-zugreifen.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=169</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=169</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;https://www.sqlite.org&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/sqlite-759x339.png&quot; width=&quot;125&quot; height=&quot;56&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://www.sqlite.org&quot;&gt;SQLite&lt;/a&gt; ist ein leichtgewichtiges relationales Datenbanksystem, das
  genial konzipiert, allerdings nicht netzwerkfähig ist. Letzteres ist laut
  der Autoren Absicht: &quot;SQLite is designed for situations where the
  data and application coexist on the same machine.&quot;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Mitunter möchte man dennoch eine SQLite-Datenbank von einem entfernten
  Rechner zugreifen. Dass es keine gute Idee ist, wie es im Netz öfter
  als Lösung genannt wird, die Datenbankdatei (eine SQLite-Datenbank
  besteht aus einer einzigen Datei) auf ein Netzwerk-Dateisystem zu legen,
  wird von den Autoren in &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://www.sqlite.org/draft/useovernet.html&quot;&gt;SQLite Over a Network, Caveats and Considerations&lt;/a&gt; dargelegt.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Unter Perl lässt sich der Netzwerk-Zugriff auch solide unter Rückgriff
  auf &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://metacpan.org/dist/DBI&quot;&gt;DBI&lt;/a&gt; und &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://metacpan.org/dist/DBI/view/dbiproxy.PL&quot;&gt;dessen Proxy-Server&lt;/a&gt; realisieren. Der Unterschied
  ist, dass in dem Fall die &lt;i class=&quot;sdoc-seg-i&quot;&gt;API Schicht&lt;/i&gt; ins Netz verlegt wird und
  nicht die &lt;i class=&quot;sdoc-seg-i&quot;&gt;File-I/O Schicht&lt;/i&gt; (s. obiges Dokument).
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Starten des Proxy-Servers auf dem Rechner mit der SQLite-Datenbank:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ ssh USER@HOST &quot;bash -lc &#039;dbiproxy --localport=PORT&#039;&quot;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Zugriff auf die Datenbank aus Perl heraus von einem beliebigen
  Rechner aus:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: perl; toolbar: false; pad-line-numbers: 1&quot;&gt;use DBD::SQLite;&amp;#10;&amp;#10;my $dbh = DBI-&amp;gt;connect(&#039;dbi:Proxy:hostname=HOST;port=PORT;dsn=DSN&#039;,{&amp;#10;    RaiseError =&amp;gt; 1,&amp;#10;    ShowErrorStatement =&amp;gt; 1,&amp;#10;});&amp;#10;&amp;#10;# ab hier können wir auf die SQLite-Datenbank zugreifen, als ob sie lokal wäre&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Hierbei ist:
&lt;/p&gt;
&lt;dl class=&quot;sdoc-list-dl&quot;&gt;
  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;HOST&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Der Name des Rechners, auf dem die SQLite-Datenbank liegt.
    &lt;/p&gt;
  &lt;/dd&gt;

  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;PORT&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Der Port, auf dem der Proxy-Server läuft.
    &lt;/p&gt;
  &lt;/dd&gt;

  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;DSN&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Der DBI &lt;i class=&quot;sdoc-seg-i&quot;&gt;Data Source Name&lt;/i&gt; der SQLite-Datenbank. Dieser hat die
      Form &lt;tt class=&quot;sdoc-seg-c&quot;&gt;dbi:SQLite:dbname=PATH&lt;/tt&gt;, wobei PATH der Pfad der
      Datenbank-Datei auf dem entfernten Rechner ist.
    &lt;/p&gt;
  &lt;/dd&gt;
&lt;/dl&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine breitere Darstellung der Möglichkeiten des DBI Proxy-Servers
  findet sich in &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://docstore.mik.ua/orelly/linux/dbi/ch08_02.htm&quot;&gt;Programming the Perl DBI - Database Proxying&lt;/a&gt;.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;b class=&quot;sdoc-seg-b&quot;&gt;Warnung:&lt;/b&gt; Der DBI Proxy-Server hat offenbar ein Memory Leak und sollte
  daher nicht unbegrenzt lange laufen.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Soll lediglich mit dem SQLite-Client auf eine entfernte Datenbank
  zugegriffen werden, kann dies per &lt;tt class=&quot;sdoc-seg-c&quot;&gt;ssh(1)&lt;/tt&gt; erreicht werden:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: shell; toolbar: false; pad-line-numbers: 1&quot;&gt;$ ssh -t USER@HOST sqlite3 PATH&lt;/pre&gt;
&lt;/div&gt;
 
    </content:encoded>

    <pubDate>Sun, 14 Nov 2021 19:08:34 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/169-guid.html</guid>
    
</item>
<item>
    <title>Oracle+Linux: ORA-00845: MEMORY_TARGET not supported on this system</title>
    <link>http://fseitz.de/blog/index.php?/archives/62-Oracle+Linux-ORA-00845-MEMORY_TARGET-not-supported-on-this-system.html</link>
            <category>Datenbanken</category>
            <category>Oracle</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/62-Oracle+Linux-ORA-00845-MEMORY_TARGET-not-supported-on-this-system.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=62</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=62</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;https://docs.oracle.com/en/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/database-114x100.png&quot; width=&quot;80&quot; height=&quot;70&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Unter Linux (Debian) bricht eine zuvor funktionierende
  Oracle-Datenbank beim Hochfahren plötzlich ab. Die Meldung lautet:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;ORA-00845: MEMORY_TARGET not supported on this system&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Im Netz wird in Blogs als Lösung genannt, man möge &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/dev/shm&lt;/tt&gt; mounten
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# mount -t tmpfs tmpfs -o size=2g /dev/shm&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  oder, falls &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/dev/shm&lt;/tt&gt; bereits gemountet ist, den Speicher vergrößern
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# mount -o remount,size=2g /dev/shm&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Dies hat beides allerdings nicht geholfen, da es eine weitere
  Fehlerursache gibt. Die Meldung im &lt;tt class=&quot;sdoc-seg-c&quot;&gt;alert_&amp;lt;DB&amp;gt;.log&lt;/tt&gt; zu dem Fehler
  lautet:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;WARNING: You are trying to use the MEMORY_TARGET feature. This feature&amp;#10;requires the /dev/shm file system to be mounted for at least&amp;#10;1275068416 bytes. /dev/shm is either not mounted or is mounted with&amp;#10;available space less than this size. Please fix this so that MEMORY_TARGET&amp;#10;can work as expected. Current available is 0 and used is 0 bytes.&amp;#10;Ensure that the mount point is /dev/shm for this directory.&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Der entscheidende Punkt in der Meldung, welcher zur Lösung führt,
  ist, dass Oracle keinen verfügbaren Speicher erkennt (&quot;Current
  available is 0 and used is 0 bytes&quot;) und dass der Mountpoint exakt
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/dev/shm&lt;/tt&gt; sein muss (&quot;Ensure that the mount point is /dev/shm for
  this directory&quot;).
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Letztere Bedingung war auf dem Debian-System (testing) nicht erfüllt:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# df -h /dev/shm&amp;#10;Filesystem            Size  Used Avail Use% Mounted on&amp;#10;tmpfs                 3.0G     0  3.0G   0% /run/shm&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Als Mountpoint wird hier nicht &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/dev/shm&lt;/tt&gt; angezeigt, sondern
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/run/shm&lt;/tt&gt;, weil &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/dev/shm&lt;/tt&gt; lediglich ein Symlink auf &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/run/shm&lt;/tt&gt; ist:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# ls -l /dev/shm&amp;#10;lrwxrwxrwx 1 root root 8 Aug 7 09:37 /dev/shm -&amp;gt; /run/shm&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Mit diesem Setup kommt der Oracle-Kernel (11.2.0.1.0) nicht klar. Er
  erkennt (aus nicht weiter erforschten Gründen) die Größe des
  Shared-Memory-Bereichs nicht.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Der Fix besteht darin, im Oracle-Kernel alle Vorkommen von
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/dev/shm&lt;/tt&gt; durch &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/run/shm&lt;/tt&gt; zu ersetzen:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# cd $ORACLE_HOME/bin&amp;#10;# cp oracle oracle.bak&amp;#10;# sed &#039;s|/dev/shm|/run/shm|g&#039; oracle.bak &amp;gt;oracle&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Danach fährt die Datenbank wieder hoch:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ sqlplus / as sysdba&amp;#10;&amp;#10;SQL*Plus: Release 11.2.0.1.0 Production on Fri Aug 7 13:29:21 2020&amp;#10;&amp;#10;Copyright (c) 1982, 2009, Oracle.  All rights reserved.&amp;#10;&amp;#10;Connected to an idle instance.&amp;#10;&amp;#10;SQL&amp;gt; startup&amp;#10;ORACLE instance started.&amp;#10;&amp;#10;Total System Global Area 1272213504 bytes&amp;#10;Fixed Size		    1336260 bytes&amp;#10;Variable Size		  805309500 bytes&amp;#10;Database Buffers	  452984832 bytes&amp;#10;Redo Buffers		   12582912 bytes&amp;#10;Database mounted.&amp;#10;Database opened.&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Links&lt;/h1&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;&lt;a class=&quot;sdoc-seg-u&quot; href=&quot;http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html&quot;&gt;Oracle Database Software Downloads&lt;/a&gt;&lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;&lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://docs.oracle.com/en/database&quot;&gt;Oracle Database Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Wed, 27 Jan 2021 09:31:00 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/62-guid.html</guid>
    
</item>
<item>
    <title>MS SQL Server: DB-übergreifender Zugriff auf Tabelle nur über View</title>
    <link>http://fseitz.de/blog/index.php?/archives/164-MS-SQL-Server-DB-uebergreifender-Zugriff-auf-Tabelle-nur-ueber-View.html</link>
            <category>Datenbanken</category>
            <category>MS SQL Server</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/164-MS-SQL-Server-DB-uebergreifender-Zugriff-auf-Tabelle-nur-ueber-View.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=164</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=164</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/microsoft-sql-server-719x182.png&quot; width=&quot;198&quot; height=&quot;50&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;b class=&quot;sdoc-seg-b&quot;&gt;Ausgangslage:&lt;/b&gt;
&lt;/p&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      In einer Datenbank &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mydb1&lt;/tt&gt; befindet sich eine Tabelle &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema1.mytable&lt;/tt&gt;
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      In einer zweiten Datenbank &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mydb2&lt;/tt&gt; befindet sich eine View
      &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema2.myview&lt;/tt&gt;
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      View &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema2.myview&lt;/tt&gt; selektiert Tabelle &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema1.mytable&lt;/tt&gt;
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;b class=&quot;sdoc-seg-b&quot;&gt;Anforderung:&lt;/b&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Es soll ein Server-Zugang &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mylogin&lt;/tt&gt; geschaffen werden, der Daten über View
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema2.myview&lt;/tt&gt; selektieren darf, aber nicht direkt aus Tabelle
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema1.mytable&lt;/tt&gt;.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;b class=&quot;sdoc-seg-b&quot;&gt;Lösung:&lt;/b&gt;
&lt;/p&gt;
&lt;ol class=&quot;sdoc-list-ol&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Login &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mylogin&lt;/tt&gt; erzeugen mit dem User-Mapping: &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mydb1&lt;/tt&gt; -&amp;gt; &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myuser1&lt;/tt&gt;
      und &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mydb2&lt;/tt&gt; -&amp;gt; &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myuser2&lt;/tt&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      User &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myuser1&lt;/tt&gt; erhält keine speziellen Rechte.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      User &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myuser2&lt;/tt&gt; erhält Leserecht auf View &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema2.myview&lt;/tt&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Den Schemata &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema1&lt;/tt&gt; und &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myschema2&lt;/tt&gt; den gleichen Owner geben
      (und damit den enthaltenen Objekten &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mytable&lt;/tt&gt; und &lt;tt class=&quot;sdoc-seg-c&quot;&gt;myview&lt;/tt&gt;).
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Für die Datenbanken &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mydb1&lt;/tt&gt; und &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mydb2&lt;/tt&gt; &quot;cross-database ownership
      chaining&quot; aktivieren.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;b class=&quot;sdoc-seg-b&quot;&gt;SQL:&lt;/b&gt;
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: sql; toolbar: false; pad-line-numbers: 1&quot;&gt;CREATE LOGIN mylogin WITH PASSWORD = &#039;mypassword&#039;;&amp;#10;&amp;#10;CREATE DATABASE mydb1;&amp;#10;ALTER DATABASE mydb1 SET DB_CHAINING ON;&amp;#10;&amp;#10;CREATE DATABASE mydb2;&amp;#10;ALTER DATABASE mydb2 SET DB_CHAINING ON;&amp;#10;&amp;#10;USE mydb1;&amp;#10;&amp;#10;CREATE SCHEMA myschema1;&amp;#10;&amp;#10;CREATE TABLE myschema1.mytable (id INT PRIMARY KEY);&amp;#10;CREATE USER myuser1 FOR LOGIN mylogin;&amp;#10;&amp;#10;USE mydb2;&amp;#10;&amp;#10;CREATE SCHEMA myschema2;&amp;#10;CREATE USER myuser2 FOR LOGIN mylogin;&amp;#10;&amp;#10;CREATE VIEW myschema2.myview AS SELECT * FROM mydb1.myschema1.mytable;&amp;#10;GRANT SELECT ON myschema2.myview TO myuser2;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Über &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mylogin&lt;/tt&gt; ausgeführt:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: sql; toolbar: false; pad-line-numbers: 1&quot;&gt;-- erfolgreich&amp;#10;SELECT * FROM mydb2.myschema2.myview;&amp;#10;&amp;#10;-- schlägt fehl: The SELECT permission was denied on the object &#039;mytable&#039;,&amp;#10;-- database &#039;mydb1&#039;, schema &#039;myschema1&#039;&amp;#10;SELECT * FROM mydb1.myschema1.mytable;&lt;/pre&gt;
&lt;/div&gt;
 
    </content:encoded>

    <pubDate>Wed, 21 Oct 2020 16:27:00 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/164-guid.html</guid>
    
</item>
<item>
    <title>SQL: SELECT-Statement in einer Methode kapseln</title>
    <link>http://fseitz.de/blog/index.php?/archives/155-SQL-SELECT-Statement-in-einer-Methode-kapseln.html</link>
            <category>Datenbanken</category>
            <category>SQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/155-SQL-SELECT-Statement-in-einer-Methode-kapseln.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=155</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=155</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/sql-icon-86x100.png&quot; width=&quot;48&quot; height=&quot;56&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Das potentiell komplexeste Statement in SQL ist das SELECT-Statement.
  Dieses wiederverwendbar zu kapseln, z.B. in einer Methode einer
  Klasse, kann eine Herausforderung sein. Dieses Problem wollen wir
  hier allgemeingültig lösen.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Hier ein Beispiel. Mit folgendem SELECT-Statement wollen wir aus dem
  Data Dictionary (Catalog) von PostgreSQL Informationen über die auf der
  Datenbank definierten Datenbank-Funktionen abfragen:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: sql; toolbar: false; pad-line-numbers: 1&quot;&gt;SELECT&amp;#10;    fnc.oid AS fnc_oid&amp;#10;    , usr.usename AS fnc_owner&amp;#10;    , nsp.nspname AS fnc_schema&amp;#10;    , fnc.proname AS fnc_name&amp;#10;    , pg_get_function_identity_arguments(pro.oid) AS fnc_arguments&amp;#10;    , pg_get_functiondef(fnc.oid) AS fnc_source&amp;#10;FROM&amp;#10;    pg_proc AS fnc&amp;#10;    JOIN pg_namespace AS nsp&amp;#10;        ON fnc.pronamespace = nsp.oid&amp;#10;    JOIN pg_user usr&amp;#10;        ON fnc.proowner = usr.usesysid&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Dieses relativ kurze Statement besitzt eine beachtliche
  Komplexität. Es erstreckt sich über drei Relationen (zwei Tabellen,
  eine View), deren Aufbau und Verknüpfung alles andere als
  offensichtlich ist. Wir wollen es so kapseln, dass wir bei Abfragen
  keine Details über die interne Repräsentation des Data Dictionary
  wissen müssen. In einem ersten Schritt haben wir den Kolumnen
  bereits Aliasnamen gegeben (s.o.), aus denen sich die Bedeutung
  der Kolumnen recht klar ergibt:
&lt;/p&gt;
&lt;dl class=&quot;sdoc-list-dl&quot;&gt;
  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;fnc_oid&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Statt &lt;tt class=&quot;sdoc-seg-c&quot;&gt;oid&lt;/tt&gt;. Objekt-Id der Funktion.
    &lt;/p&gt;
  &lt;/dd&gt;

  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;fnc_owner&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Statt &lt;tt class=&quot;sdoc-seg-c&quot;&gt;usename&lt;/tt&gt;. Name des Owners der Funktion.
    &lt;/p&gt;
  &lt;/dd&gt;

  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;fnc_schema&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Statt &lt;tt class=&quot;sdoc-seg-c&quot;&gt;nspname&lt;/tt&gt;. Name des Schemas, in dem sich die Funktion befindet.
    &lt;/p&gt;
  &lt;/dd&gt;

  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;fnc_name&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Statt &lt;tt class=&quot;sdoc-seg-c&quot;&gt;proname&lt;/tt&gt;. Name der Funktion.
    &lt;/p&gt;
  &lt;/dd&gt;

  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;fnc_arguments&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Statt &lt;tt class=&quot;sdoc-seg-c&quot;&gt;pg_get_function_identity_arguments(oid)&lt;/tt&gt;. Argumentliste der
      Funktion als kommaseparierte Aufzählung der Datentypen. Diese
      Information ist bedeutsam, da eine Funktion nur durch ihre Signatur
      (Name plus Argumentliste) eindeutig bestimmt ist.
    &lt;/p&gt;
  &lt;/dd&gt;

  &lt;dt class=&quot;sdoc-list-dt&quot;&gt;fnc_source&lt;/dt&gt;
  &lt;dd class=&quot;sdoc-list-dd&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Statt &lt;tt class=&quot;sdoc-seg-c&quot;&gt;pg_get_functiondef(oid)&lt;/tt&gt;. Quelltext der Funktion.
    &lt;/p&gt;
  &lt;/dd&gt;
&lt;/dl&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Über diesen Kolumnen wollen wir unsere Abfragen formulieren.
  Das Problem ist jedoch, dass wir die Kolumnen-Aliase nicht überall in
  einer Abfrage verwenden können, auch nicht in der
  WHERE-Klausel, die die Ergebnismenge bestimmt. Wenn wir
  obiges Statement um eine WHERE-Klausel ergänzen, müssen wir dort also
  weiterhin die internen Namen verwenden. Das wollen wir gerade nicht.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine mögliche Lösung ist das Anlegen einer View:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: sql; toolbar: false; pad-line-numbers: 1&quot;&gt;CREATE VIEW function_view AS&amp;#10;&amp;lt;obiges_statement&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Durch die View werden die internen Namen verdeckt. Abfragen der View
  werden allein über den Kolumnennamen des zugrundeliegenden Statements
  formuliert. Das ist genau das, was wir wollen. Mit der View schaffen
  wir allerdings eine öffentliche Schnittstelle, die wir (ohne besondere
  Vorkehrungen) nicht nach Belieben anlegen (Namenskonflikte) und ändern
  können (wir wissen nicht, wer die View sonst noch nutzt). Dies ist das
  Gegenteil einer Kapselung. Das Ziel einer echten Kapselung
  in einer Methode, und nur dort, erreichen wir mit einer View nicht.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine in dieser Hinsicht bessere Lösung bietet eine Inline-View,
  die nur innerhalb unserer Methode bekannt ist. Bei einer Inline-View
  betten wir das Select-Statement in die FROM-Klausel unserer
  Abfrage ein:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: sql; toolbar: false; pad-line-numbers: 1&quot;&gt;SELECT&amp;#10;    ...&amp;#10;FROM (&amp;#10;    &amp;lt;obiges_statement&amp;gt;&amp;#10;) AS function_view&amp;#10;...&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Diese Lösung hat jedoch den Nachteil, dass sie nicht portabel
  ist. Z.B. erzwingt PostgreSQL einen Namen für die Inline-View (&lt;tt class=&quot;sdoc-seg-c&quot;&gt;AS
  function_view&lt;/tt&gt;), Oracle jedoch nicht. Wobei ein Name im Falle von
  Oracle zwar vereinbart werden kann, dann aber ohne das
  Schlüsselwort &lt;tt class=&quot;sdoc-seg-c&quot;&gt;AS&lt;/tt&gt;.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine weitere Möglichkeit bietet die Einbettung in eine WITH-Klausel:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: sql; toolbar: false; pad-line-numbers: 1&quot;&gt;WITH function_view AS (&amp;#10;    &amp;lt;obiges_statement&amp;gt;&amp;#10;)&amp;#10;SELECT&amp;#10;    ...&amp;#10;FROM&amp;#10;    function_view&amp;#10;...&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Diese Lösung ist portabel und separiert die konkrete Abfrage
  (&lt;tt class=&quot;sdoc-seg-c&quot;&gt;SELECT ... FROM function_view ...&lt;/tt&gt;) klar von dem gekapselten
  SELECT-Statement.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Auf dieser Grundlage können wir die Selektion wie gewünscht kapseln.
  Hier die Implementierung einer Methode in Perl, die so
  ausgelegt ist, dass die Klauseln SELECT (Namensparameter select),
  WHERE (Namensparameter where) und ORDER BY (Namensparameter orderBy)
  frei gesetzt werden können:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: perl; toolbar: false; pad-line-numbers: 1&quot;&gt;package PostgreSql::Catalog;&amp;#10;&amp;#10;sub functionSelect {&amp;#10;    my ($class,%clause) = @_;&amp;#10;&amp;#10;    # Defaults&amp;#10;&amp;#10;    $clause{&#039;select&#039;} //= [&#039;*&#039;]; # Default für SELECT-Klausel&amp;#10;    $clause{&#039;from&#039;} = [&#039;function_view&#039;]; # FROM-Klausel ist festgelegt&amp;#10;&amp;#10;    # Gekapselter Statement-Rumpf&amp;#10;&amp;#10;    my $stmt = &amp;lt;&amp;lt; &#039;    __SQL__&#039;;&amp;#10;    WITH function_view AS (&amp;#10;        SELECT&amp;#10;            fnc.oid AS fnc_oid&amp;#10;            , usr.usename AS fnc_owner&amp;#10;            , nsp.nspname AS fnc_schema&amp;#10;            , fnc.proname AS fnc_name&amp;#10;            , pg_get_function_identity_arguments(pro.oid) AS fnc_arguments&amp;#10;            , pg_get_functiondef(fnc.oid) AS fnc_source&amp;#10;        FROM&amp;#10;            pg_proc AS fnc&amp;#10;            JOIN pg_namespace AS nsp&amp;#10;                ON fnc.pronamespace = nsp.oid&amp;#10;            JOIN pg_user usr&amp;#10;                ON fnc.proowner = usr.usesysid&amp;#10;    )&amp;#10;    __SQL__&amp;#10;    $stmt =~ s/^    //mg;&amp;#10;&amp;#10;    # Erzeuge vollständiges Statement über den angegebenen Klauseln&amp;#10;&amp;#10;    for my $key (qw/select from where orderBy/) {&amp;#10;        if (my $arr = $clause{$key}) {&amp;#10;            my $clause  = $key eq &#039;orderBy&#039;? &#039;ORDER BY&#039;: uc $key;&amp;#10;            $stmt .= sprintf &quot;%s\n    %s\n&quot;,$clause,join &quot;\n    , &quot;,@$arr;&amp;#10;        }&amp;#10;    }&amp;#10;&amp;#10;    return $stmt;&amp;#10;}&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Beispiel: Der Aufruf
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: perl; toolbar: false; pad-line-numbers: 1&quot;&gt;# Ermittele alle Funktionen im Schema &#039;donald&#039;, deren Quelltext&amp;#10;# die Zeichenkette &#039;to_date&#039; enthält&amp;#10;&amp;#10;$sql = PostgreSql::Catalog-&amp;gt;functionSelect(&amp;#10;    select =&amp;gt; [&amp;#10;        &quot;fnc_schema&quot;,&amp;#10;        &quot;fnc_name || &#039;(&#039; || fnc_arguments || &#039;)&#039; AS fnc_signature&quot;,&amp;#10;    ],&amp;#10;    where =&amp;gt; [&amp;#10;        &quot;fnc_schema = &#039;donald&#039;&quot;,&amp;#10;        &quot;fnc_source LIKE &#039;%to_date%&#039;&quot;,&amp;#10;    ],&amp;#10;    orderBy =&amp;gt; [&amp;#10;        1,&amp;#10;        2&amp;#10;    ],&amp;#10;);&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  generiert das Statement
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: sql; toolbar: false; pad-line-numbers: 1&quot;&gt;WITH function_view AS (&amp;#10;    SELECT&amp;#10;        fnc.oid AS fnc_oid&amp;#10;        , usr.usename AS fnc_owner&amp;#10;        , nsp.nspname AS fnc_schema&amp;#10;        , fnc.proname AS fnc_name&amp;#10;        , pg_get_function_identity_arguments(pro.oid) AS fnc_arguments&amp;#10;        , pg_get_functiondef(fnc.oid) AS fnc_source&amp;#10;    FROM&amp;#10;        pg_proc AS fnc&amp;#10;        JOIN pg_namespace AS nsp&amp;#10;            ON fnc.pronamespace = nsp.oid&amp;#10;        JOIN pg_user usr&amp;#10;            ON fnc.proowner = usr.usesysid&amp;#10;)&amp;#10;SELECT&amp;#10;    fnc_schema&amp;#10;    , fnc_name || &#039;(&#039; || fnc_arguments || &#039;)&#039; AS fnc_signature&amp;#10;FROM&amp;#10;    function_view&amp;#10;WHERE&amp;#10;    fnc_schema = &#039;donald&#039;&amp;#10;    AND fnc_source LIKE &#039;%to_date%&#039;&amp;#10;ORDER BY&amp;#10;    1&amp;#10;    , 2&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  das wir gegen die Datenbank ausführen können.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Wir haben folgendes erreicht:
&lt;/p&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Wir haben das Gerüst eines komplexen Select-Statements in einer
      Methode gekapselt.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Wir haben eigene Kolumnennamen vereinbart, über denen
      wir Selektionen formulieren können. Nur diese Namen muss der
      Aufrufer kennen.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Wir haben eine Methode geschaffen, die eine Schnittstelle zur
      Erzeugung von frei formulierten Selektionen über dem gekapselten Statement
      bereitstellt.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Fri, 09 Oct 2020 22:48:00 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/155-guid.html</guid>
    
</item>
<item>
    <title>MySQL: Join mit mehrwertiger Fremdschlüsselkolumne durch find_in_set()</title>
    <link>http://fseitz.de/blog/index.php?/archives/137-MySQL-Join-mit-mehrwertiger-Fremdschluesselkolumne-durch-find_in_set.html</link>
            <category>Datenbanken</category>
            <category>MySQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/137-MySQL-Join-mit-mehrwertiger-Fremdschluesselkolumne-durch-find_in_set.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=137</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=137</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.mysql.de/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/mysql-logo-170x115.png&quot; width=&quot;74&quot; height=&quot;50&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Der reinen Datenbank-Lehre nach ist es strikt verboten mehrere Werte
  auf einem Attribut zu speichern. Sowas kommt in der Realität trotzdem
  vor, sogar bei Fremdschlüssel-Attributen. D.h. das
  Fremdschlüssel-Attribut referenziert in dem Fall nicht nur eine,
  sondern &lt;i class=&quot;sdoc-seg-i&quot;&gt;mehrere&lt;/i&gt; Zeilen. Die gute Nachricht ist, dass MySQL es
  erlaubt, für so ein - ansich unterlaubtes - Design mithilfe der
  Funktion &lt;tt class=&quot;sdoc-seg-c&quot;&gt;find_in_set()&lt;/tt&gt; eine Join-Condition zu formulieren.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Beispiel&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Gegeben zwei Tabellen &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TableA&lt;/tt&gt; und &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TableB&lt;/tt&gt;, wobei Attribut
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TableB.tablea_id&lt;/tt&gt; auf &lt;i class=&quot;sdoc-seg-i&quot;&gt;mehrere&lt;/i&gt; Zeilen in &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TableA&lt;/tt&gt; verweist.
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;TableA    TableB&amp;#10;&amp;#10;id        id tablea_id&amp;#10;--        -- ---------&amp;#10;1         1  2,3&amp;#10;2         2  3&amp;#10;3         3  1,2,3,4&amp;#10;4         4  NULL&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Wäre &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TableB.tablea_id&lt;/tt&gt; ein normales Fremdschlüssel-Attribut mit
  &lt;i class=&quot;sdoc-seg-i&quot;&gt;einem&lt;/i&gt; Wert sähe die Join-Condition so aus:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;TableA.id = TableB.tablea_id&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Diese Bedingung ist hier nicht anwendbar, da eine Identität (&lt;tt class=&quot;sdoc-seg-c&quot;&gt;=&lt;/tt&gt;)
  zwischen &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TableA.id&lt;/tt&gt; und &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TableB.tablea_id&lt;/tt&gt; nur manchmal gegeben ist.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Selektion
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;SELECT&amp;#10;    b.id b_id&amp;#10;    , a.id a_id&amp;#10;FROM&amp;#10;    TableA a&amp;#10;    INNER JOIN TableB b&amp;#10;    ON a.id = b.tablea_id&amp;#10;ORDER BY&amp;#10;    b.id&amp;#10;    , a.id&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  liefert ein &lt;i class=&quot;sdoc-seg-i&quot;&gt;falsches&lt;/i&gt; Resultat
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre-no-border&quot;&gt;+------+------+&amp;#10; b_id | a_id |&amp;#10;+------+------+&amp;#10;|    1 |    2 | zweifelhaft&amp;#10;|    2 |    3 | erwartet&amp;#10;|    3 |    1 | zweifelhaft&amp;#10;+------+------+&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Da MySQL bei numerischen Identitäts-Vergleichen eine laxe Auffassung
  hat und gegen den numerischen Anfang einer Zeichenkette vergleicht,
  auch wenn die Zeichenkette insgesamt keine Zahl darstellt, ist die
  Ergebnismenge zusätzlich zweifelhaft. Statt der erwarten einen
  Zeile werden drei Zeilen geliefert.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  MySQL besitzt jedoch eine Funktion &lt;tt class=&quot;sdoc-seg-c&quot;&gt;find_in_set()&lt;/tt&gt;, mit deren Hilfe
  eine Join-Condition formuliert werden kann, die die mehrwertigen
  Verweise korrekt auflöst:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;FIND_IN_SET(TableA.id, TableB.tablea_id) &amp;gt; 0&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Selektion
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;SELECT&amp;#10;    b.id b_id&amp;#10;    , a.id a_id&amp;#10;FROM&amp;#10;    TableA a&amp;#10;    INNER JOIN TableB b&amp;#10;    ON FIND_IN_SET(a.id, b.tablea_id) &amp;gt; 0&amp;#10;ORDER BY&amp;#10;    b.id&amp;#10;    , a.id&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  liefert das korrekte Resultat
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre-no-border&quot;&gt;+------+------+&amp;#10; b_id | a_id |&amp;#10;+------+------+&amp;#10;|    1 |    2 |&amp;#10;|    1 |    3 |&amp;#10;|    2 |    3 |&amp;#10;|    3 |    1 |&amp;#10;|    3 |    2 |&amp;#10;|    3 |    3 |&amp;#10;|    3 |    4 |&amp;#10;+------+------+&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Links&lt;/h1&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;&lt;a class=&quot;sdoc-seg-u&quot; href=&quot;http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_find-in-set&quot;&gt;MySQL: find_in_set()&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Thu, 25 Feb 2016 15:46:23 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/137-guid.html</guid>
    
</item>
<item>
    <title>PostgreSQL: Installation und Konfiguration</title>
    <link>http://fseitz.de/blog/index.php?/archives/6-PostgreSQL-Installation-und-Konfiguration.html</link>
            <category>Datenbanken</category>
            <category>PostgreSQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/6-PostgreSQL-Installation-und-Konfiguration.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=6</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=6</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.postgresql.org/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/postgresql-logo-95x51.png&quot; width=&quot;95&quot; height=&quot;51&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;http://www.postgresql.org/&quot;&gt;PostgreSQL&lt;/a&gt; gilt als das beste
  frei erhältliche Relationale Datenbanksystem. Es besitzt viele
  Gemeinsamkeiten mit Oracle, ist aber wesentlich leichter zu
  administrieren. Hier die wichtigsten Kommandos, um damit an den Start
  gehen zu können.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;PostgreSQL RDBMS installieren (Debian)&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# apt-get install postgresql&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Zum DB-Admin machen&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# su - postgres&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Nur von diesem Unix-Account aus kann nach der Installation eine
  Connection zum DBMS aufgebaut werden.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Liste der existierenden Datenbanken&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ psql -l&amp;#10;[Liste]&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Nach der Installation existiert zunächst nur die Datenbank
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;postgres&lt;/tt&gt;.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Datenbank erzeugen/zerstören&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ createdb DB&amp;#10;...&amp;#10;$ dropdb DB&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Liste der existierenden Benutzer&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ psql&amp;#10;postgres=# \du&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  oder
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;postgres=# SELECT rolname FROM pg_roles;&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Benutzer anlegen/entfernen&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ createuser USER&amp;#10;...&amp;#10;$ dropuser USER&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Bei Angabe der Option &lt;tt class=&quot;sdoc-seg-c&quot;&gt;--superuser&lt;/tt&gt; erhält der Benutzer Admin-Rechte:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ createuser --superuser USER&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Benutzer sind global für alle Datenbanken einer Installation.
  Zunächst existiert nur der Benutzer &lt;tt class=&quot;sdoc-seg-c&quot;&gt;postgres&lt;/tt&gt;. Soll der User
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;USER&lt;/tt&gt; von einem anderen Account als dem entsprechenden
  Unix-Account connecten können, muss ein Passwort vergeben
  werden. Option &lt;tt class=&quot;sdoc-seg-c&quot;&gt;-P&lt;/tt&gt;.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Datenbankzugriff&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Ist ein DB-User erzeugt, kann dieser vom gleichnamigen Unix-Account
  oder per Passwort, falls eins vergeben wurde, von einem anderen
  Account per &lt;tt class=&quot;sdoc-seg-c&quot;&gt;psql&lt;/tt&gt; auf die Datenbank zugreifen.
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;USER$ psql DB&amp;#10;psql (9.4.3)&amp;#10;Type &quot;help&quot; for help.&amp;#10;...&amp;#10;DB=#&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Wurde ein Passwort für User USER vergeben, aber die Anmeldung
  von einem anderen Accout aus schlägt fehl mit der Meldung
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ psql -U USER DB&amp;#10;psql: FATAL:  Peer authentication failed for user &quot;USER&quot;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  dann muss in &lt;tt class=&quot;sdoc-seg-c&quot;&gt;pg_hba.conf&lt;/tt&gt; die Authentisierungsmethode für
  lokale Logins geändert werden von
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;local     all     all      peer&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  in
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;local     all     all      md5&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  und anschließend der Server neu gestartet werden.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Liste der existierenden Objekte&lt;/h1&gt;
&lt;div class=&quot;sdoc-tab-div&quot;&gt;
  &lt;table border=&quot;1&quot; class=&quot;sdoc-tab-table&quot;&gt;
  &lt;tr class=&quot;sdoc-tab-tr-odd&quot;&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;Schemata:&lt;/td&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;&lt;tt class=&quot;sdoc-seg-c&quot;&gt;\dn&lt;/tt&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class=&quot;sdoc-tab-tr-even&quot;&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;Tabellen:&lt;/td&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;&lt;tt class=&quot;sdoc-seg-c&quot;&gt;\dt&lt;/tt&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class=&quot;sdoc-tab-tr-odd&quot;&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;Views:&lt;/td&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;&lt;tt class=&quot;sdoc-seg-c&quot;&gt;\dv&lt;/tt&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class=&quot;sdoc-tab-tr-even&quot;&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;Sequenzen:&lt;/td&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;&lt;tt class=&quot;sdoc-seg-c&quot;&gt;\ds&lt;/tt&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Liste aller interaktiven psql-Kommandos: &lt;tt class=&quot;sdoc-seg-c&quot;&gt;\?&lt;/tt&gt;
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Exportieren/Importieren&lt;/h1&gt;
&lt;div class=&quot;sdoc-tab-div&quot;&gt;
  &lt;table border=&quot;1&quot; class=&quot;sdoc-tab-table&quot;&gt;
  &lt;tr class=&quot;sdoc-tab-tr-odd&quot;&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;Alle Datenbanken:&lt;/td&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;&lt;tt class=&quot;sdoc-seg-c&quot;&gt;pg_dumpall &amp;gt;FILE&lt;/tt&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class=&quot;sdoc-tab-tr-even&quot;&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;Eine Datenbank:&lt;/td&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;&lt;tt class=&quot;sdoc-seg-c&quot;&gt;pg_dump DB &amp;gt;FILE&lt;/tt&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class=&quot;sdoc-tab-tr-odd&quot;&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;Importieren:&lt;/td&gt;
    &lt;td class=&quot;sdoc-tab-td&quot; align=&quot;left&quot;&gt;&lt;tt class=&quot;sdoc-seg-c&quot;&gt;psql -f FILE DB&lt;/tt&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Session-Einstellungen&lt;/h1&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Zeitzone&lt;/h2&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Zeitzone kann für eine Session abweichend gesetzt werden:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;SET TIME ZONE &#039;Europe/Berlin&#039;;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Default-Zeitzone ist in &lt;tt class=&quot;sdoc-seg-c&quot;&gt;postgresql.conf&lt;/tt&gt; definiert:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;timezone = &#039;Europe/Berlin&#039;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Datumsformat&lt;/h2&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Datumsangaben im Format YYYY-MM-DD:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;SET datestyle TO iso, ymd;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Aktueller Zeitpunkt:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;select localtimestamp(0);&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  liefert die Zeit entsprechend dem eingestellten Format
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;2015-06-09 11:44:29&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Zeichensatz&lt;/h2&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Client arbeitet mit ISO-8859-1:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;SET client_encoding TO iso88591&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Client arbeitet mit UTF-8:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;SET client_encoding TO utf8&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Siehe: &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;http://www.postgresql.org/docs/9.4/static/multibyte.html&quot;&gt;http://www.postgresql.org/docs/9.4/static/multibyte.html&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Der clientseitige Zeichensatz kann jederzeit umgeschaltet werden.
  Wenn Daten mit unterschiedlichem Encoding verarbeitet werden,
  besteht die Möglichkeit, vor dem Schreiben auf die Datenbank das
  clientseitige Encoding umzuschalten. Die Konvertierung wird dann
  vom Server übernommen.
&lt;/p&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;\-Escapes in Stringliteralen verbieten&lt;/h2&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;SET standard_conforming_strings TO on&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Server-Zugriff von externen Hosts&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die folgenden Einträge ermöglichen den Zugriff von allen
  Hosts für alle User und alle Datenbanken.
&lt;/p&gt;
&lt;ol class=&quot;sdoc-list-ol&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      In &lt;tt class=&quot;sdoc-seg-c&quot;&gt;pg_hba.conf&lt;/tt&gt; oberhalb der anderen Einträge hinzufügen:
    &lt;/p&gt;
    &lt;div class=&quot;sdoc-code-div&quot;&gt;
      &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# TYPE  DATABASE  USER  CIDR-ADDRESS  METHOD&amp;#10;host    all       all   0.0.0.0/0     md5&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      In &lt;tt class=&quot;sdoc-seg-c&quot;&gt;postgresql.conf&lt;/tt&gt; eintragen:
    &lt;/p&gt;
    &lt;div class=&quot;sdoc-code-div&quot;&gt;
      &lt;pre class=&quot;sdoc-code-pre&quot;&gt;listen_addresses = &#039;*&#039;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Server neu starten&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# /etc/init.d/postgresql-X.Y restart&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Upgrade auf eine neue Version&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Siehe Kapitel &quot;Upgrading&quot; in der Doku.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Links&lt;/h1&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;&lt;a class=&quot;sdoc-seg-u&quot; href=&quot;http://www.postgresql.org/docs&quot;&gt;PostgreSQL Dokumentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Wed, 10 Jun 2015 17:20:00 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/6-guid.html</guid>
    
</item>
<item>
    <title>SSH: Über SSH-Tunnel mit MySQL Datenbank verbinden</title>
    <link>http://fseitz.de/blog/index.php?/archives/97-SSH-UEber-SSH-Tunnel-mit-MySQL-Datenbank-verbinden.html</link>
            <category>MySQL</category>
            <category>Netz</category>
            <category>SSH</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/97-SSH-UEber-SSH-Tunnel-mit-MySQL-Datenbank-verbinden.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=97</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=97</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.openssh.com/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/ssh-logo-90x78.png&quot; width=&quot;58&quot; height=&quot;50&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine MySQL-Datenbank, die von innen (Host oder lokalem Netzwerk),
  jedoch nicht von außen (Internet) per TCP/IP erreichbar ist, kann von
  einem entfernten Rechner über einen SSH-Tunnel erreicht werden, wenn
  man einen SSH-Zugang zu dem Datenbank-Host oder einem Host des
  Netzwerks besitzt.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  1 - SSH-Tunnel zum MySQL Port 3306 aufsetzen:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ ssh &amp;lt;user&amp;gt;@&amp;lt;host&amp;gt; -L &amp;lt;port&amp;gt;:localhost:3306 -f -N&amp;#10;&amp;#10;-L &amp;lt;port&amp;gt;:localhost:3306 : Verbinde lokalen Port &amp;lt;port&amp;gt; remote mit MySQL Port 3306&amp;#10;-f                       : Lege den ssh-Prozess in den Hintergrund&amp;#10;-N                       : Führe remote nichts aus (kein Login, kein Kommando)&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  2 - Mit der Datenbank verbinden:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ mysql --host=localhost --port=&amp;lt;port&amp;gt; --protocol=tcp ...&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  oder
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ mysql --host=127.0.0.1 --port=&amp;lt;port&amp;gt; ...&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Dieser spezielle Fall von SSH-Tunneling kann natürlich auch auf andere
  Dienste (Ports) übertragen werden.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Ein weiterer Artikel zu dem Thema:
  &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;http://www.revsys.com/writings/quicktips/ssh-tunnel.html&quot;&gt;http://www.revsys.com/writings/quicktips/ssh-tunnel.html&lt;/a&gt;
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;phpMyAdmin&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Um mit einer lokalen phpMyAdmin-Applikation über den Tunnel
  auf die Remote-Datenbank zugreifen zu können, wird eine
  entsprechende Server-Definition in der phpMyAdmin-Konfiguration
  vereinbart, z.B. in &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/etc/phpmyadmin/conf.d/&amp;lt;Server-Name&amp;gt;.php&lt;/tt&gt;:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&amp;lt;?php&amp;#10;&amp;#10;$cfg[&#039;Servers&#039;][$i][&#039;verbose&#039;] = &#039;&amp;lt;Server-Name&amp;gt;&#039;;&amp;#10;$cfg[&#039;Servers&#039;][$i][&#039;host&#039;] = &#039;127.0.0.1&#039;;&amp;#10;$cfg[&#039;Servers&#039;][$i][&#039;port&#039;] = &#039;3305&#039;;&amp;#10;$cfg[&#039;Servers&#039;][$i][&#039;connect_type&#039;] = &#039;tcp&#039;;&amp;#10;$i++;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Das Timeout hochsetzen:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$cfg[&#039;LoginCookieValidity&#039;] = &amp;lt;Wert in Sekunden&amp;gt;;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Z.B. ein Tag:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$cfg[&#039;LoginCookieValidity&#039;] = 86400;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  0 bedeutet nicht unendlich, sondern sofortiges Logout!
&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Wed, 10 Apr 2013 17:54:02 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/97-guid.html</guid>
    
</item>
<item>
    <title>Lookup-Trigger für Oracle und PostgreSQL</title>
    <link>http://fseitz.de/blog/index.php?/archives/85-Lookup-Trigger-fuer-Oracle-und-PostgreSQL.html</link>
            <category>Datenbanken</category>
            <category>Oracle</category>
            <category>PostgreSQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/85-Lookup-Trigger-fuer-Oracle-und-PostgreSQL.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=85</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=85</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.postgresql.org/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/postgresql-logo-95x51.png&quot; width=&quot;95&quot; height=&quot;51&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Gegeben ist eine Tabelle &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;table&amp;gt;&lt;/tt&gt; mit einer Kolumne &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;x&amp;gt;&lt;/tt&gt;, deren
  Wert frei manipuliert werden kann, und einer Kolumne &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;y&amp;gt;&lt;/tt&gt;, deren
  Wert funktional von &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;x&amp;gt;&lt;/tt&gt; abhängt (also nicht frei manipuliert werden
  kann). Die Abbildung von &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;x&amp;gt;&lt;/tt&gt; auf &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;y&amp;gt;&lt;/tt&gt; ist in einer Lookup-Tabelle
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;lookup_table&amp;gt;&lt;/tt&gt; definiert, die jedem Wert &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;x&amp;gt;&lt;/tt&gt; den
  entsprechenden Wert &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;y&amp;gt;&lt;/tt&gt; zuordnet.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Aufgabe: Der &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;y&amp;gt;&lt;/tt&gt;-Wert soll in &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;table&amp;gt;&lt;/tt&gt; gespeichert werden und
  stets konstitent zu &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;x&amp;gt;&lt;/tt&gt; sein. Der Wert von &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;y&amp;gt;&lt;/tt&gt; soll &lt;i class=&quot;sdoc-seg-i&quot;&gt;nicht&lt;/i&gt;
  erst bei Abfrage ermittelt werden. Im Prinzip ist das eine unerwüschte
  Redundanz, die aber aus praktischen Gründen sinnvoll sein kann.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Anforderung lässt sich durch einen &lt;tt class=&quot;sdoc-seg-c&quot;&gt;BEFORE INSERT OR
  UPDATE&lt;/tt&gt;-Trigger erfüllen, der beim Einfügen oder Ändern in &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;table&amp;gt;&lt;/tt&gt;
  den &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;y&amp;gt;&lt;/tt&gt;-Wert via &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;x&amp;gt;&lt;/tt&gt; in &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;lookup_table&amp;gt;&lt;/tt&gt; ermittelt und auf
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;table&amp;gt;.&amp;lt;y&amp;gt;&lt;/tt&gt; überträgt.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Es folgt die Lösung für Oracle und PostgreSQL.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Oracle&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 1&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;CREATE OR REPLACE TRIGGER&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;tigger&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;BEFORE INSERT OR UPDATE&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 2&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;ON&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;FOR EACH ROW&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 3&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;BEGIN&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 4&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;SELECT&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 5&lt;/span&gt;         &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;y&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 6&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;INTO&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 7&lt;/span&gt;         &lt;span class=&quot;hl kwc&quot;&gt;:new&lt;/span&gt;.&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;y&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 8&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;FROM&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 9&lt;/span&gt;         &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;lookup_table&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;10&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;WHERE&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;11&lt;/span&gt;         &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;x&lt;span class=&quot;hl opt&quot;&gt;&amp;gt; =&lt;/span&gt; &lt;span class=&quot;hl kwc&quot;&gt;:new&lt;/span&gt;.&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;x&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;12&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;END&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;&amp;#10;&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;PostgreSQL&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 1&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;CREATE FUNCTION&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;trigger_func&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;()&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;RETURNS trigger AS&lt;/span&gt; $$&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 2&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;BEGIN&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 3&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;SELECT&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 4&lt;/span&gt;         &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;y&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 5&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;INTO STRICT&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 6&lt;/span&gt;         &lt;span class=&quot;hl kwa&quot;&gt;NEW&lt;/span&gt;.&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;y&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 7&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;FROM&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 8&lt;/span&gt;         &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;lookup_table&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt; 9&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;WHERE&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;10&lt;/span&gt;         &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;x&lt;span class=&quot;hl opt&quot;&gt;&amp;gt; =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;NEW&lt;/span&gt;.&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;x&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;11&lt;/span&gt; &amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;12&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;RETURN NEW&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;END&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;14&lt;/span&gt; $$ &lt;span class=&quot;hl kwa&quot;&gt;LANGUAGE&lt;/span&gt; plpgsql&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;15&lt;/span&gt; &amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;16&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;CREATE TRIGGER&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;trigger&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;BEFORE INSERT OR UPDATE&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;17&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;ON&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;FOR EACH ROW&lt;/span&gt;&amp;#10;&lt;span class=&quot;sdoc-code-ln&quot;&gt;18&lt;/span&gt;     &lt;span class=&quot;hl kwa&quot;&gt;EXECUTE PROCEDURE&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;trigger_func&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;();&lt;/span&gt;&amp;#10;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Der Code ist bei beiden Datenbanksystemen ähnlich, die Unterschiede sind im
  Wesentlichen:
&lt;/p&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Die Prozedur kann bei Oracle als Teil des Trigger definiert werden, was
      den Code einfach und elegant macht. Bei PostgreSQL ist eine
      spezielle, vom Trigger getrennte Prozedurdefinition erforderlich.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Der Bezeichner für die neue Tabellenzeile ist bei Oracle &lt;tt class=&quot;sdoc-seg-c&quot;&gt;:new&lt;/tt&gt;,
      bei PostgreSQL &lt;tt class=&quot;sdoc-seg-c&quot;&gt;NEW&lt;/tt&gt;. Bei PostgreSQL muss diese Zeile von
      der Trigger-Prozedur zurückgeliefert werden. Bei Oracle wird nichts
      zurückgeliefert.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      PostgreSQL generiert bei &lt;tt class=&quot;sdoc-seg-c&quot;&gt;INTO STRICT&lt;/tt&gt; automatisch eine Exception,
      wenn durch das &lt;tt class=&quot;sdoc-seg-c&quot;&gt;SELECT&lt;/tt&gt; keine oder mehr als eine Zeile getroffen wird.
      Dies ist ein kostenloser Paranoia-Test für die Daten in
      &lt;tt class=&quot;sdoc-seg-c&quot;&gt;&amp;lt;lookup_table&amp;gt;&lt;/tt&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Fri, 23 Mar 2012 14:35:04 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/85-guid.html</guid>
    
</item>
<item>
    <title>PostgreSQL: Notizen zum psql Kommando-Interpreter</title>
    <link>http://fseitz.de/blog/index.php?/archives/81-PostgreSQL-Notizen-zum-psql-Kommando-Interpreter.html</link>
            <category>Datenbanken</category>
            <category>PostgreSQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/81-PostgreSQL-Notizen-zum-psql-Kommando-Interpreter.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=81</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=81</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.postgresql.org/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/postgresql-logo-95x51.png&quot; width=&quot;95&quot; height=&quot;51&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Startup-Datei anlegen/ändern:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ vi ~/.psqlrc&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Kommandos in der Datei führt der Interpreter beim Start aus.
  Hier können persönliche Einstellungen vorgenommen werden. Z.B. kann man
  dort den Pager aus- und die Zeitmessung einschalten.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Pager abschalten:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&amp;lt;db&amp;gt;=# \pset pager off&amp;#10;Pager usage is off.&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Zeitmessung einschalten:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&amp;lt;db&amp;gt;=# \timing on&amp;#10;Timing is on.&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;b class=&quot;sdoc-seg-b&quot;&gt;Nützliche interaktive Kommandos:&lt;/b&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Liste der Schemata:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&amp;lt;db&amp;gt;=# \dn&amp;#10;...&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Liste der Tabellen eines Schemas:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&amp;lt;db&amp;gt;=# \dt &amp;lt;schema&amp;gt;.*&amp;#10;...&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Tabelle, View oder Sequenz beschreiben:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&amp;lt;db&amp;gt;=# \d &amp;lt;object&amp;gt;&amp;#10;...&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;b class=&quot;sdoc-seg-b&quot;&gt;Spezielle SQL-Anweisungen:&lt;/b&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Liste der Runtime-Parameter:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&amp;lt;db&amp;gt;=# show all;&amp;#10;...&lt;/pre&gt;
&lt;/div&gt;
 
    </content:encoded>

    <pubDate>Tue, 28 Feb 2012 14:36:19 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/81-guid.html</guid>
    
</item>
<item>
    <title>SQL: Dubletten finden</title>
    <link>http://fseitz.de/blog/index.php?/archives/66-SQL-Dubletten-finden.html</link>
            <category>Datenbanken</category>
            <category>SQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/66-SQL-Dubletten-finden.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=66</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=66</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/sql-icon-86x100.png&quot; width=&quot;48&quot; height=&quot;56&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;SELECT col1, ..., colN, COUNT(*)&amp;#10;FROM tab&amp;#10;GROUP BY col1, ..., colN&amp;#10;HAVING COUNT(*) &amp;gt; 1&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;col1, ..., colN&lt;/tt&gt; sind die Kolumnen, über denen die
  Dubletten-Eigenschaft geprüft wird.
&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Mon, 05 Sep 2011 14:19:53 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/66-guid.html</guid>
    
</item>
<item>
    <title>MySQL: Data Directory neu aufsetzen</title>
    <link>http://fseitz.de/blog/index.php?/archives/65-MySQL-Data-Directory-neu-aufsetzen.html</link>
            <category>Datenbanken</category>
            <category>MySQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/65-MySQL-Data-Directory-neu-aufsetzen.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=65</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=65</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.mysql.de/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/mysql-logo-170x115.png&quot; width=&quot;74&quot; height=&quot;50&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;ol class=&quot;sdoc-list-ol&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Server herunterfahren
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Inhalt des Datadir löschen
    &lt;/p&gt;
    &lt;div class=&quot;sdoc-code-div&quot;&gt;
      &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ rm -r DATADIR/*&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Datadir initialisieren
    &lt;/p&gt;
    &lt;div class=&quot;sdoc-code-div&quot;&gt;
      &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ mysql_install_db --user=mysql --ldata=DATADIR&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-num&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Server wieder hochfahren
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
 
    </content:encoded>

    <pubDate>Tue, 30 Aug 2011 10:44:14 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/65-guid.html</guid>
    
</item>
<item>
    <title>MySQL: Mehrere Instanzen auf einem Server</title>
    <link>http://fseitz.de/blog/index.php?/archives/64-MySQL-Mehrere-Instanzen-auf-einem-Server.html</link>
            <category>Datenbanken</category>
            <category>MySQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/64-MySQL-Mehrere-Instanzen-auf-einem-Server.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=64</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=64</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.mysql.de/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/mysql-logo-170x115.png&quot; width=&quot;74&quot; height=&quot;50&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine elegante Möglichkeit, mehrere MySQL-Instanzen auf einem Server zu
  betreiben, bietet das Programm &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mysqld_multi&lt;/tt&gt;. Es erweitert die
  Konfigurationsdatei &lt;tt class=&quot;sdoc-seg-c&quot;&gt;/etc/my.cnf&lt;/tt&gt; um Abschnitte für mehrere
  MySQL-Serverinstanzen &lt;tt class=&quot;sdoc-seg-c&quot;&gt;[mysqld#]&lt;/tt&gt; (wobei &lt;tt class=&quot;sdoc-seg-c&quot;&gt;#&lt;/tt&gt; die jeweilige Instanznummer
  bezeichnet). In den Abschnitten werden den Instanzen getrennte
  Datadirs, Sockets, Ports, Pid-Files usw. zugewiesen.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mysqld_multi&lt;/tt&gt; ist das Frontend-Programm zum Starten und Stoppen
  der einzelnen Instanzen, à la
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ mysqld_multi start 2&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine Beispielkonfiguration, die auf die eigenen Verhältnissse
  angepasst und in &lt;tt class=&quot;sdoc-seg-c&quot;&gt;my.cnf&lt;/tt&gt; eingesetzt werden kann, liefert das
  Kommando
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ mysqld_multi --example&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die ausführliche Doku ist auf der Manpage zu finden:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ man mysql_multi&lt;/pre&gt;
&lt;/div&gt;
 
    </content:encoded>

    <pubDate>Mon, 29 Aug 2011 10:12:00 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/64-guid.html</guid>
    
</item>
<item>
    <title>Oracle 11g unter Linux installieren</title>
    <link>http://fseitz.de/blog/index.php?/archives/54-Oracle-11g-unter-Linux-installieren.html</link>
            <category>Datenbanken</category>
            <category>Oracle</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/54-Oracle-11g-unter-Linux-installieren.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=54</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=54</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;https://docs.oracle.com/en/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/database-114x100.png&quot; width=&quot;80&quot; height=&quot;70&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Eine Anleitung zum Installieren von Oracle 11g unter Debian, die
  versucht, mögliche Probleme von vornherein auszuschließen, dafür aber
  umfangreiche Vorarbeiten verlangt, findet sich hier:
  &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;http://edin.no-ip.com/blog/hswong3i/oracle-database-11g-release-1-debian-sid-howto&quot;&gt;http://edin.no-ip.com/blog/hswong3i/oracle-database-11g-release-1-debian-sid-howto&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Meine Anleitung hat das Ziel, die Voraussetzungen für den Aufruf des
  Installers zu schaffen. Da der Installer selbst den Softwarestand und
  die Kernelparameter prüft, können Anpassungen auch bei laufender
  Installation vogenommen werden.
&lt;/p&gt;
&lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/oracle-installer-configuration-600x449.png&quot; width=&quot;508&quot; height=&quot;381&quot; alt=&quot;&quot; /&gt;Abbildung 1: Allgemeine Konfigurationsangaben im Installer
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Schritt 1: Download&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Dateien von Oracle.com herunterladen: &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html&quot;&gt;Download 11g Enterprise Edition&lt;/a&gt; (Hierfür ist ein OTN-Konto nötig)
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Schritt 2: Oracle-Benutzer und DBA-Gruppe erzeugen&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# addgroup --system dba&amp;#10;# adduser --system --home /opt/oracle --shell /bin/bash --ingroup dba&amp;#10;  --gecos &#039;Oracle DBA&#039; oracle&amp;#10;# passwd oracle&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Schritt 3: Dateien entpacken&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Auf Benutzer &lt;tt class=&quot;sdoc-seg-c&quot;&gt;oracle&lt;/tt&gt; wechseln, unter dessen Rechten wird die weitere
  Installation durchgeführt:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;# su - oracle&amp;#10;$ unzip linux_11gR2_database_1of2.zip&amp;#10;$ unzip linux_11gR2_database_2of2.zip&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Dateien werden von &lt;tt class=&quot;sdoc-seg-c&quot;&gt;unzip&lt;/tt&gt; in ein Unterverzeichnis &lt;tt class=&quot;sdoc-seg-c&quot;&gt;database&lt;/tt&gt;
  entpackt. Wo entpackt wird, ist egal. Die entpackten Dateien werden
  nur während der Installation gebraucht. Nach der Installtion kann das
  gesamte Verzeichnis gelöscht werden.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Schritt 4: Installer ausführen&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;b class=&quot;sdoc-seg-b&quot;&gt;Wichtig:&lt;/b&gt; Wurde der Desktop unter einem anderen Benutzer als &lt;tt class=&quot;sdoc-seg-c&quot;&gt;oracle&lt;/tt&gt;
  gestartet, muss der Benutzer den Desktop für den Zugriff des Benutzers
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;oracle&lt;/tt&gt; freigeben, da dieser den Installer aufruft. Geschieht die
  Freigabe nicht, stirbt der Installer nach einigen Sekunden mit der
  wenig aussagekräftigen Fehlermeldung
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;No protocol specified&amp;#10;[Java Stacktrace]&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Freigabe erfolgt mit dem Kommando:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;&amp;lt;user&amp;gt;$ xhost +&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Als Benutzer oracle ausführen:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ cd database&amp;#10;$ ./runInstaller&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Der Installer führt den Benutzer durch die Installation, nimmt
  zahlreiche Prüfungen vor und schreibt ein Logfile, das bei Problemen
  konsultiert werden kann.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Unstimmigkeiten können parallel behoben werden, Prüfungen und
  fehlgeschlagene Schritte können immer wieder neu durchgeführt werden
  bis es klappt.
&lt;/p&gt;
&lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/oracle-installer-prerequisite-checks-600x450.png&quot; width=&quot;508&quot; height=&quot;382&quot; alt=&quot;&quot; /&gt;Abbildung 2: Kernel- und Software-Prüfungen durch den Installer
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Installierte Dateien&lt;/h1&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Konfigurationsdateien in /etc&lt;/h2&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;/etc/oraInst.loc&amp;#10;/etc/oratab&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Die eigentliche Installation&lt;/h2&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;/opt/oracle/app/*&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Hilfsprogramme&lt;/h2&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;/usr/local/bin/oraenv&amp;#10;/usr/local/bin/coraenv&amp;#10;/usr/local/bin/dbhome&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Datenbank-Dateien&lt;/h2&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;/var/opt/oracle/&amp;lt;DATABASE&amp;gt;/*&lt;/pre&gt;
&lt;/div&gt;
 
    </content:encoded>

    <pubDate>Thu, 10 Mar 2011 11:56:43 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/54-guid.html</guid>
    
</item>
<item>
    <title>MySQL: Bessere Antwortzeiten durch bessere Query-Pläne</title>
    <link>http://fseitz.de/blog/index.php?/archives/47-MySQL-Bessere-Antwortzeiten-durch-bessere-Query-Plaene.html</link>
            <category>Datenbanken</category>
            <category>MySQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/47-MySQL-Bessere-Antwortzeiten-durch-bessere-Query-Plaene.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=47</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=47</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.mysql.de/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/mysql-logo-170x115.png&quot; width=&quot;74&quot; height=&quot;50&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Der MySQL Query Optimizer kann bessere Query-Pläne generieren,
  wenn er Informationen über die Tabelleninhalte hat. Diese können per
  SQL mit &lt;tt class=&quot;sdoc-seg-c&quot;&gt;ANALYZE TABLE&lt;/tt&gt; erzeugt werden oder - einfacher - mit dem
  Kommandozeilenprogramm &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mysqlcheck&lt;/tt&gt;. Die Option zum Analysieren
  heißt &lt;tt class=&quot;sdoc-seg-c&quot;&gt;--analyze&lt;/tt&gt;. Bei Angabe der Option &lt;tt class=&quot;sdoc-seg-c&quot;&gt;--all-databases&lt;/tt&gt; werden alle
  Tabellen aller Schemata (in MySQL-Sprechweise: Datenbanken)
  auf einen Schlag analysiert. Das ist meistens das, was man will.
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ mysqlcheck --analyze --all-databases ...&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  bzw. in Kurzform
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ mysqlcheck -a -A ...&lt;/pre&gt;
&lt;/div&gt;
 
    </content:encoded>

    <pubDate>Thu, 04 Nov 2010 10:00:00 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/47-guid.html</guid>
    
</item>
<item>
    <title>MySQL: Remote-Zugriff einrichten</title>
    <link>http://fseitz.de/blog/index.php?/archives/46-MySQL-Remote-Zugriff-einrichten.html</link>
            <category>Datenbanken</category>
            <category>MySQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/46-MySQL-Remote-Zugriff-einrichten.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=46</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=46</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.mysql.de/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/mysql-logo-170x115.png&quot; width=&quot;74&quot; height=&quot;50&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Damit der MySQL-Server &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mysqld&lt;/tt&gt; TCP-Verbindungen annimmt, muss ihm in
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;my.cnf&lt;/tt&gt; im Abschnitt &lt;tt class=&quot;sdoc-seg-c&quot;&gt;[mysqld]&lt;/tt&gt; eine Bind-Adresse zugewiesen
  werden:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;bind-address = &amp;lt;server-ip&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Falls vorhanden, muss die Direktive &lt;tt class=&quot;sdoc-seg-c&quot;&gt;skip-networking&lt;/tt&gt; gleichzeitig
  auskommentiert werden, da diese Priorität hat und forciert, dass
  der Server nur Unix Domain Sockets zulässt.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Per SQL einen neuen User anlegen und ihm den Remote-Zugriff von allen
  Hosts (&#039;%&#039;) auf alle Schemata und Tabellen (*.*) erlauben:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;CREATE USER &amp;lt;user&amp;gt; IDENTIFIED BY &#039;&amp;lt;password&amp;gt;&#039;;&amp;#10;GRANT ALL ON *.* TO &#039;&amp;lt;user&amp;gt;&#039;@&#039;%&#039;;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Login mit mysql-Client:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ mysql -u &amp;lt;user&amp;gt; -h &amp;lt;host&amp;gt; --password=&amp;lt;password&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die User-Zugriffsberechtigungen stehen in der Tabelle &lt;tt class=&quot;sdoc-seg-c&quot;&gt;mysql.user&lt;/tt&gt;.
  Diese  Tabelle kann mit INSERT/UPDATE/DELETE Statements
  auch direkt manipuliert werden.
&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Wed, 03 Nov 2010 14:09:23 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/46-guid.html</guid>
    
</item>
<item>
    <title>ROWNUM unter MySQL</title>
    <link>http://fseitz.de/blog/index.php?/archives/44-ROWNUM-unter-MySQL.html</link>
            <category>Datenbanken</category>
            <category>MySQL</category>
            <category>SQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/44-ROWNUM-unter-MySQL.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=44</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=44</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.mysql.de/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/mysql-logo-170x115.png&quot; width=&quot;74&quot; height=&quot;50&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Oracle kennt die Pseudo-Kolumne &lt;tt class=&quot;sdoc-seg-c&quot;&gt;ROWNUM&lt;/tt&gt;, die die Datensätze einer
  Selektion von 1 an aufsteigend durchnummeriert. In MySQL
  existiert dieses Konzept nicht, es kann aber mittels einer
  Benutzer-definierten Variable simuliert werden.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Implementierung:
&lt;/p&gt;
&lt;table class=&quot;sdoc-code-table&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
&lt;tr class=&quot;sdoc-code-tr-odd&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt;1&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;SELECT&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-even&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt;2&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;    &amp;#64;rownum &lt;span class=&quot;hl opt&quot;&gt;:=&lt;/span&gt; &amp;#64;rownum &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt; ROWNUM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-odd&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt;3&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;    &lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; t.&lt;span class=&quot;hl opt&quot;&gt;*&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-even&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt;4&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;FROM&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-odd&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt;5&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;    &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;SELECT&lt;/span&gt; &amp;#64;rownum &lt;span class=&quot;hl opt&quot;&gt;:=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; r&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;sdoc-code-tr-even&quot;&gt;
  &lt;td class=&quot;sdoc-code-td-ln&quot;&gt;6&lt;/td&gt;
  &lt;td class=&quot;sdoc-code-td-line&quot;&gt;    t&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Einschränkung: Die Lösung ist unzureichend, wenn ein ORDER BY
  verwendet wird, da die Nummerierung &lt;i class=&quot;sdoc-seg-i&quot;&gt;vor&lt;/i&gt; der Sortierung
  stattfindet.
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Unter Oracle wird &lt;tt class=&quot;sdoc-seg-c&quot;&gt;ROWNUM&lt;/tt&gt; auch benutzt, um die Ergebnismenge auf
  die ersten &lt;i class=&quot;sdoc-seg-i&quot;&gt;n&lt;/i&gt; Datensätze zu begrenzen. Dafür hat MySQL ein
  besseres Konzept, die SELECT-Klausel &lt;tt class=&quot;sdoc-seg-c&quot;&gt;LIMIT&lt;/tt&gt;.
&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Wed, 27 Oct 2010 16:39:00 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/44-guid.html</guid>
    
</item>
<item>
    <title>PostgreSQL: TIMESTAMP nach EPOCH wandeln und zurück</title>
    <link>http://fseitz.de/blog/index.php?/archives/19-PostgreSQL-TIMESTAMP-nach-EPOCH-wandeln-und-zurueck.html</link>
            <category>Datenbanken</category>
            <category>PostgreSQL</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/19-PostgreSQL-TIMESTAMP-nach-EPOCH-wandeln-und-zurueck.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=19</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=19</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;http://www.postgresql.org/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/postgresql-logo-95x51.png&quot; width=&quot;95&quot; height=&quot;51&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;TIMESTAMP WITHOUT TIME ZONE nach EPOCH&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Umwandlung eines &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TIMESTAMP WITHOUT TIME ZONE&lt;/tt&gt; in Unix-Epoch
  (Sekunden seit 1.1.1970 0 Uhr) in einer Anwendung, die mit UTC-Zeiten
  arbeitet:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;sql&amp;gt; SELECT EXTRACT(EPOCH FROM TIMESTAMP&amp;#10;        &#039;1970-01-01 00:00:00&#039; AT TIME ZONE &#039;UTC&#039;) AS t;&amp;#10; t&amp;#10;---&amp;#10; 0&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Entscheidend ist hier der Zusatz &quot;&lt;tt class=&quot;sdoc-seg-c&quot;&gt;AT TIME ZONE &#039;UTC&#039;&lt;/tt&gt;&quot;, denn ein
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TIMESTAMP WITHOUT TIME ZONE&lt;/tt&gt; wird als Zeit der &lt;i class=&quot;sdoc-seg-i&quot;&gt;lokalen&lt;/i&gt; Zeitzone
  interpretiert - nicht etwa UTC! Ohne den Zusatz ist das Resultat um
  dem Offset der lokalen Zeitzone verschoben - böse Falle. Hier das
  Ergebnis im Falle von MEZ (+0100):
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;sql&amp;gt; SELECT EXTRACT(EPOCH FROM TIMESTAMP &#039;1970-01-01 00:00:00&#039;) AS t;&amp;#10;   t&amp;#10;-------&amp;#10; -3600&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Erläuterungen&lt;/h2&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      &lt;tt class=&quot;sdoc-seg-c&quot;&gt;EXTRACT(EPOCH FROM t)&lt;/tt&gt; extrahiert die Epoch-Sekunden
    &lt;/p&gt;
    &lt;div class=&quot;sdoc-code-div&quot;&gt;
      &lt;pre class=&quot;sdoc-code-pre&quot;&gt;vom Zeit-Wert C{t}.&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TIMESTAMP &#039;1970-01-01 00:00:00&#039;&lt;/tt&gt; ist die Zeitangabe &lt;tt class=&quot;sdoc-seg-c&quot;&gt;t&lt;/tt&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      &lt;tt class=&quot;sdoc-seg-c&quot;&gt;AT TIME ZONE &#039;UTC&#039;&lt;/tt&gt; interpretiert die Zeitangabe &lt;tt class=&quot;sdoc-seg-c&quot;&gt;t&lt;/tt&gt;
      hinsichtlich Zeitzone UTC.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;EPOCH nach TIMESTAMP WITHOUT TIMEZONE&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Umwandlung von Epoch-Sekunden in einen &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TIMESTAMP WITHOUT TIMEZONE&lt;/tt&gt;
  (die &lt;tt class=&quot;sdoc-seg-c&quot;&gt;0&lt;/tt&gt; steht für den Epoch-Wert):
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;sql&amp;gt; gkss=# SELECT TIMESTAMP &#039;epoch&#039; + 0 * INTERVAL &#039;1 second&#039; AS t;&amp;#10;         t&amp;#10;---------------------&amp;#10; 1970-01-01 00:00:00&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Erläuterungen&lt;/h2&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      &lt;tt class=&quot;sdoc-seg-c&quot;&gt;TIMESTAMP &#039;epoch&#039;&lt;/tt&gt; bzeichnet den Anfang der Zeitrechnung (1.1.1970 0 Uhr).
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      &lt;tt class=&quot;sdoc-seg-c&quot;&gt;0 * INTERVAL &#039;1 second&#039;&lt;/tt&gt; ist der Zeitoffset in Sekunden, der
      hinzuaddiert wird. Er kann auch negativ sein.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;
    &lt;p class=&quot;sdoc-para-p&quot;&gt;
      Das Resultat ist ein Timestamp.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Fri, 22 Jan 2010 16:49:32 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/19-guid.html</guid>
    
</item>

</channel>
</rss>