Über SQL-Funktionen SQL-Funktionen sind in Oracle-Datenbank integriert und sind für die Verwendung in verschiedenen entsprechenden SQL-Anweisungen verfügbar. Verwechseln Sie nicht SQL-Funktionen mit benutzerdefinierten Funktionen in PLSQL geschrieben. Wenn Sie eine SQL-Funktion mit einem Argument eines anderen Datentyps als dem von der SQL-Funktion erwarteten Datentyp aufrufen, versucht Oracle, das Argument in den erwarteten Datentyp umzuwandeln, bevor die SQL-Funktion ausgeführt wird. Die kombinierten Werte der NLSCOMP - und NLSSORT-Einstellungen bestimmen die Regeln, nach denen Zeichen sortiert und verglichen werden. Wenn NLSCOMP auf LINGUISTIC für Ihre Datenbank gesetzt ist, werden alle Entitäten in diesem Kapitel entsprechend den vom NLSSORT-Parameter angegebenen Regeln interpretiert. Wenn NLSCOMP nicht auf LINGUISTIC gesetzt ist. Dann werden die Funktionen ohne Rücksicht auf die NLSSORT-Einstellung interpretiert. NLSSORT kann explizit gesetzt werden. Wenn es nicht explizit gesetzt ist, wird es von NLSLANGUAGE abgeleitet. Weitere Informationen zu diesen Einstellungen finden Sie im Oracle Database Globalization Support Guide. In den Syntaxdiagrammen für SQL-Funktionen werden Argumente durch ihre Datentypen angezeigt. Wenn die Parameterfunktion in der SQL-Syntax erscheint, ersetzen Sie sie durch eine der in diesem Abschnitt beschriebenen Funktionen. Die Funktionen werden durch die Datentypen ihrer Argumente und ihre Rückgabewerte gruppiert. Wenn Sie SQL-Funktionen auf LOB-Spalten anwenden, erstellt Oracle Database temporäre LOBs während der SQL - und PLSQL-Verarbeitung. Sie sollten sicherstellen, dass eine temporäre Tablespace-Quote für die Speicherung dieser temporären LOBs für Ihre Anwendung ausreichend ist. Über benutzerdefinierte Funktionen für Informationen über Benutzerfunktionen und Datenkonvertierung für die implizite Umwandlung von Datentypen Oracle Text Reference für Informationen über Funktionen, die mit Oracle Text Oracle Data Mining Application Developers Guide verwendet werden, um Informationen über häufige Itemset-Funktionen zu verwenden, die mit Oracle Data Mining verwendet werden Die Syntax, die die Kategorien von Funktionen folgen: Die folgenden Abschnitte listen die eingebauten SQL-Funktionen in jeder der in den vorstehenden Diagrammen dargestellten Gruppen mit Ausnahme von benutzerdefinierten Funktionen auf. Alle eingebauten SQL-Funktionen werden dann in alphabetischer Reihenfolge beschrieben. Einzeilige Funktionen Einreihige Funktionen geben für jede Zeile einer abgefragten Tabelle oder Ansicht eine einzelne Ergebniszeile zurück. Diese Funktionen können in Auswahllisten, WHERE-Klauseln, START WITH und CONNECT BY-Klauseln und HAVING-Klauseln erscheinen. Numerische Funktionen Numerische Funktionen akzeptieren numerische Eingaben und geben numerische Werte zurück. Die meisten numerischen Funktionen, die NUMBER-Werte zurückgeben, die auf 38 Dezimalstellen genau sind. Die transzendentalen Funktionen COS. COSH. EXP. LN LOG. SÜNDE. SINH. SQRT BRÄUNEN. Und TANH sind genau auf 36 Dezimalstellen. Die transzendentalen Funktionen ACOS. WIE IN. EINE LOHE. Und ATAN2 sind genau auf 30 Dezimalstellen. Die numerischen Funktionen sind: Zeichenfunktionen Rückgabe von Zeichenwerten Zeichenfunktionen, die Zeichenwerte zurückgeben, geben Werte der folgenden Datentypen zurück, sofern nicht anders dokumentiert: Wenn das Eingabeargument CHAR oder VARCHAR2 ist. Dann ist der zurückgegebene Wert VARCHAR2. Wenn das Eingabeargument NCHAR oder NVARCHAR2 ist. Dann ist der zurückgegebene Wert NVARCHAR2. Die Länge des von der Funktion zurückgegebenen Wertes wird durch die maximale Länge des zurückgegebenen Datentyps begrenzt. Für Funktionen, die CHAR oder VARCHAR2 zurückgeben. Wenn die Länge des Rückgabewertes die Grenze überschreitet, schaltet die Oracle-Datenbank sie ab und gibt das Ergebnis ohne eine Fehlermeldung zurück. Für Funktionen, die CLOB-Werte zurückgeben, wenn die Länge der Rückgabewerte den Grenzwert überschreitet, dann erhöht Oracle einen Fehler und gibt keine Daten zurück. Die Zeichenfunktionen, die Zeichenwerte zurückgeben, sind: NLS-Zeichenfunktionen Die NLS-Zeichenfunktionen geben Informationen über den Zeichensatz zurück. Die NLS-Zeichenfunktionen sind: Zeichenfunktionen Rückgabe von Zahlenwerten Zeichenfunktionen, die Zahlenwerte zurückgeben, können als Argument einen beliebigen Zeichendatentyp aufnehmen. Die Zeichenfunktionen, die Zahlenwerte zurückgeben, sind: Datetime-Funktionen Datetime-Funktionen arbeiten am Datum (DATE), Zeitstempel (TIMESTAMP TIMESTAMP WITH TIME ZONE und TIMESTAMP WITH LOCAL TIME ZONE) und Intervall (INTERVAL DAY TO SECOND INTERVAL JAHR ZUM MONAT) Werte. Einige der Datetime-Funktionen wurden für den Oracle DATE-Datentyp (ADDMONTHS CURRENTDATE, LASTDAY, NEWTIME und NEXTDAY) entworfen. Wenn Sie einen Zeitstempelwert als Argument angeben, konvertiert Oracle Database intern den Eingabetyp in einen DATE-Wert und gibt einen DATE-Wert zurück. Die Ausnahmen sind die MONTHSBETWEEN-Funktion, die eine Zahl zurückgibt, und die ROUND - und TRUNC-Funktionen, die überhaupt keine Zeitstempel - oder Intervallwerte akzeptieren. Die verbleibenden Datetime-Funktionen wurden entworfen, um eine der drei Arten von Daten (Datum, Zeitstempel und Intervall) zu akzeptieren und einen Wert von einem dieser Typen zurückzugeben. Alle Datetime-Funktionen, die aktuelle Systemdatenzeitinformationen wie SYSDATE zurückgeben. SYSTIMESTAMP CURRENTTIMESTAMP Und so weiter, werden einmal für jede SQL-Anweisung ausgewertet, unabhängig davon, wie oft sie in dieser Anweisung referenziert sind. Die datetime-Funktionen sind: Allgemeine Vergleichsfunktionen Die allgemeinen Vergleichsfunktionen bestimmen den größten und / oder den kleinsten Wert aus einem Satz von Werten. Die allgemeinen Vergleichsfunktionen sind: Konvertierungsfunktionen Konvertierungsfunktionen konvertieren einen Wert von einem Datentyp in einen anderen. Im Allgemeinen folgt die Form der Funktionsnamen dem Kontextdatentyp TO-Datentyp. Der erste Datentyp ist der Eingabedatentyp. Der zweite Datentyp ist der Ausgabedatentyp. Die SQL-Conversion-Funktionen sind: Large Object Functions Die großen Objektfunktionen funktionieren auf LOBs. Die großen Objektfunktionen sind: Collection-Funktionen Die Collection-Funktionen arbeiten auf verschachtelten Tabellen und variieren. Die SQL-Auflistungsfunktionen sind: Hierarchische Funktion Die hierarchische Funktion wendet hierarchische Pfadinformationen auf eine Ergebnismenge an. Data Mining-Funktionen Die Data Mining-Funktionen funktionieren auf Modellen, die mit dem DBMSDATAMINING-Paket oder der Oracle Data Mining Java API erstellt wurden. Die SQL-Data-Mining-Funktionen sind: XML-Funktionen Die XML-Funktionen betreiben oder geben XML-Dokumente oder Fragmente zurück. Weitere Informationen zum Auswählen und Abfragen von XML-Daten mit diesen Funktionen, einschließlich Informationen zur Formatierung der Ausgabe, finden Sie im Oracle XML DB Developers Guide. Die SQL-XML-Funktionen sind: Encoding - und Decoding-Funktionen Mit den Codierungs - und Decodierungsfunktionen können Sie Daten in der Datenbank überprüfen und decodieren. NULL-bezogene Funktionen Die NULL-bezogenen Funktionen erleichtern die Nullbehandlung. Die NULL-bezogenen Funktionen sind: Umgebungs - und Identifikationsfunktionen Die Umgebungs - und Identifikationsfunktionen geben Auskunft über die Instanz und die Sitzung. Diese Funktionen sind: Aggregate Functions Aggregate-Funktionen geben eine einzelne Ergebniszeile basierend auf Gruppen von Zeilen und nicht auf einzelne Zeilen zurück. Aggregatfunktionen können in Auswahllisten und in ORDER BY - und HAVING-Klauseln erscheinen. Sie werden häufig mit der GROUP BY-Klausel in einer SELECT-Anweisung verwendet, wobei Oracle Database die Zeilen einer abgefragten Tabelle oder Ansicht in Gruppen aufteilt. In einer Abfrage, die eine GROUP BY-Klausel enthält, können die Elemente der Auswahlliste aggregierte Funktionen sein, GROUP BY Ausdrücke, Konstanten oder Ausdrücke, die eine davon betreffen. Oracle wendet die Aggregatfunktionen auf jede Gruppe von Zeilen an und gibt für jede Gruppe eine einzelne Ergebniszeile zurück. Wenn Sie die GROUP BY-Klausel weglassen, wendet Oracle Aggregatfunktionen in der Auswahlliste auf alle Zeilen in der abgefragten Tabelle oder Ansicht an. Sie verwenden Aggregatfunktionen in der HAVING-Klausel, um Gruppen aus der Ausgabe zu eliminieren, basierend auf den Ergebnissen der Aggregatfunktionen und nicht auf den Werten der einzelnen Zeilen der abgefragten Tabelle oder Ansicht. Verwenden Sie die GROUP BY-Klausel: Beispiele und die HAVING-Klausel für weitere Informationen über die GROUP BY-Klausel und HAVING-Klauseln in Abfragen und Unterabfragen Viele (aber nicht alle) aggregierten Funktionen, die ein einziges Argument nehmen, akzeptieren diese Klauseln: DISTINCT verursacht eine aggregierte Funktion zu berücksichtigen Nur unterschiedliche Werte des Argumentausdrucks. ALLE verursacht eine aggregierte Funktion, um alle Werte, einschließlich aller Duplikate, zu berücksichtigen. Zum Beispiel ist der DISTINCT-Durchschnitt von 1, 1, 1 und 3 2. Der ALL-Durchschnitt beträgt 1,5. Wenn Sie weder angeben, dann ist die Voreinstellung ALL. Einige Aggregatfunktionen erlauben die Fensterklausel. Die Teil der Syntax der analytischen Funktionen ist. Weitere Informationen zu dieser Klausel finden Sie unter windowingclause. Bei der Auflistung von Aggregatfunktionen am Ende dieses Abschnitts folgen die Funktionen, die der Fensterklausel erlauben, ein Sternchen () Alle Aggregatfunktionen außer COUNT (), GROUPING. Und GROUPINGID ignorieren Nullen. Sie können die NVL-Funktion im Argument einer Aggregatfunktion verwenden, um einen Wert für einen Nullpunkt zu ersetzen. COUNT und REGRCOUNT niemals null zurückkehren, sondern auch eine Nummer oder Null zurückgeben. Für alle verbleibenden Aggregatfunktionen, wenn der Datensatz keine Zeilen enthält oder nur Zeilen mit nulls als Argumente für die aggregierte Funktion enthält, gibt die Funktion null zurück. Die aggregierten Funktionen MIN. MAX. SUMME. AVG GRAF. VARIANCE Und STDDEV. Wenn mit dem Schlüsselwort KEEP gefolgt wird, kann in Verbindung mit der FIRST - oder LAST-Funktion verwendet werden, um auf einem Satz von Werten aus einem Satz von Zeilen zu arbeiten, die als FIRST oder LAST in Bezug auf eine gegebene Sortierspezifikation eingestuft sind. Weitere Informationen finden Sie in FIRST. Sie können aggregierte Funktionen verschachteln. Beispielsweise berechnet das folgende Beispiel den Durchschnitt der maximalen Gehälter aller Abteilungen im Beispielschema hr: Diese Berechnung bewertet das innere Aggregat (MAX (Gehalt)) für jede Gruppe, die durch die GROUP BY-Klausel (Abteilung) definiert ist, und Aggregate Die Ergebnisse wieder. Die aggregierten Funktionen sind: Analytische Funktionen Analytische Funktionen berechnen einen Aggregatwert basierend auf einer Gruppe von Zeilen. Sie unterscheiden sich von aggregierten Funktionen dadurch, dass sie für jede Gruppe mehrere Zeilen zurückgeben. Die Gruppe der Zeilen heißt ein Fenster und wird durch die analytische Klausel definiert. Für jede Zeile ist ein Schiebefenster von Zeilen definiert. Das Fenster bestimmt den Bereich der Zeilen, mit denen die Berechnungen für die aktuelle Zeile durchgeführt werden. Fenstergrößen können entweder auf einer physischen Anzahl von Zeilen oder einem logischen Intervall wie z. B. Zeit basieren. Analytische Funktionen sind die letzten Operationen, die in einer Abfrage ausgeführt werden, mit Ausnahme der endgültigen ORDER BY-Klausel. Alle Joins und alle WO. GRUPPIERE NACH. Und HAVING-Klauseln werden abgeschlossen, bevor die analytischen Funktionen verarbeitet werden. Daher können analytische Funktionen nur in der Auswahlliste oder der ORDER BY-Klausel erscheinen. Analytische Funktionen werden häufig verwendet, um kumulative, bewegte, zentrierte und Berichterstattung Aggregate zu berechnen. Oracle GoldenGate 11g - Die Brücke zu überall Oracle GoldenGate 11g in der Enterprise IOUG SELECT Journal 0411 Oracle GoldenGate hat eine Menge Buzz in der Oracle-Community generiert, da dies war Von der Oracle Corporation im Jahr 2015 erworben. Das GoldenGate-Produkt wird von Oracle als Nischenanwendung vermarktet, aber eines, das in fast jeder Oracle-Umgebung eingesetzt werden kann. Darüber hinaus hat Oracle deutlich gemacht, dass sie erwarten, dass GoldenGate die Hauptreplikationsmethode in der Zukunft statt Streams of Advanced Replication sein wird. Die Begründung dahinter ist einfach: GoldenGate ist eine echte heterogene Replikationslösung, die nicht direkt an die Oracle Software gebunden ist. Mit GoldenGate ist es möglich, von fast jeder kommerziellen Datenbank zu einer anderen kommerziellen Datenbank zu replizieren. Verfügbare Plattformen sind: DB2, MySQL, Oracle, SQLMX, SQL Server, Sybase, Teradata, TimesTen, Flatfiles und viele andere Plattformen über Java. Die Software ist in der Lage zu replizieren in Echtzeit in Echtzeit oder mit einer Verzögerung, und kann eine einzige Quelle und Pumpe es zu mehreren Zielen. GoldenGate ist wie das Autobahn-System für Datenbanken, so dass schnelle Transfers zu und von jedem Ort mit vielen zusätzlichen Zielen leicht verfügbar. GoldenGate erfüllt diese Aufgaben durch einen einfachen Satz von Prozessen, die auf Java Message Service (JMS) für die Kommunikation zentriert sind. Bevor wir eintauchen, wie GoldenGate in deiner Oracle-Umgebung eingesetzt werden kann, lass uns die Komponenten von GoldenGate durchgehen, um ein besseres Verständnis der Software zu bekommen. Ein logisches Architekturdiagramm wird unten gezeigt: (Quelle: Oracle GoldenGate Windows und UNIX Administratorhandbuch 11g Release 1 (11.1.1) E17341-01) Der Extraktprozess Der erste Schritt in jedem Replikationsprozess besteht darin, Änderungen an der Quellumgebung zu erfassen. GoldenGate erreicht dies über Extrakt-Prozesse, die in der Lage sind, Transaktionsprotokolle auf dem Quellsystem zu lesen und Änderungsdaten in eine Trail-Datei zu schreiben (wir werden diese weiter abdecken). Es können mehrere Extrakt-Prozesse konfiguriert werden, die verschiedene Datensätze ziehen. Diese Daten können kontinuierlich (24x7 Replikation) gezielt gezogen oder sogar als ereignisbasiertes System konfiguriert werden, bei dem die Erfassung von Daten beginnt, wenn bestimmte Datenänderungen vorgenommen werden. Durch das Lesen aus Transaktionslogs ist GoldenGate in der Lage, Änderungen mit sehr geringem Overhead zum Quellsystem aufzuzeichnen. Noch besser ist es möglich, eine Oracle 11g Active DataGuard-Umgebung als GoldenGate-Quelle zu verwenden, was bedeutet, dass das Quellsystem kaum betroffen ist. Der Extrakt-Prozess ist auch in der Lage, gespeicherte Daten als Quelle anstelle von Transaktionsprotokollen zu verwenden. Dies ist vor allem nützlich, um eine erste Kopie einer Datenbank zu einer Zielumgebung zu machen. Die Spur ist, wo alle extrahierten Änderungen gespeichert sind. Es enthält eine Kombination aus DDL und DML. Trail-Dateien können entweder als lokaler Trail bezeichnet werden, der auf demselben Server wie der Extrakt bleibt oder eine entfernte Spur, die über TCPIP an ein Zielsystem gesendet wird. GoldenGate unterhält die Trail-Dateien die Hauptverantwortung der DBA ist zunächst die Einrichtung der Speicher und Standorte für die Dateien. Wenn Daten extrahiert werden, wird sie in die Trail-Dateien geschrieben. Als die Dateien füllen, werden neue Trail-Dateien gebildet und die Daten werden geschrieben. Da Daten verbraucht sind, ist GoldenGate in der Lage, alte Trailinformationen zu spülen. Die Oracle-Dokumentation empfiehlt die Verwendung von separaten Datenträgern oder LUNs für die Trail-Datei, um eine optimale Leistung für die GoldenGate-Verarbeitung bereitzustellen und sicherzustellen, dass sie nicht mit anderen Ressourcen auf der Umgebung konkurriert. Auch bei leistungsstarken Systemen und Spülen wird die Trail-Datei vor allem im Falle eines Netzwerkausfalls schnell erwachsen und damit die Notwendigkeit, eine solche optimale Leistung zu bieten. Um zu bestimmen, wie viel Platz benötigt wird, empfiehlt Oracle die folgende Formel: Protokollvolumen in einer Stunde x max Anzahl der Stunden Netzausfallzeit x 0,4 Trail Space Dies basiert auf Oracles Schätzung, dass nur 40 Daten in Redo Logs tatsächlich aufgezeichnet werden Durch den GoldenGate Extrakt - das kann mehr oder weniger in deiner Umgebung sein und ist abhängig von Datenmustern. Einer der Faktoren, die GoldenGate so schnell machen, ist die begrenzte Menge an Daten, die für den Extraktprozess erforderlich sind. Zum Beispiel ist GoldenGate in der Lage, begangene Transaktionen zu extrahieren, während die Redo-Logs alle Transaktionen halten, ob gebunden oder ungebunden. Trail-Dateien werden fast immer fern für die Zwecke der Replikation geschrieben. Allerdings kann der Extrakt-Prozess Spuren lokal speichern, so dass sie von einem anderen Prozess namens Data Pump abgeholt werden können, der die Trail-Daten an mehrere Ziele senden wird. Wenn eine Datenpumpe nicht verwendet wird, befinden sich alle geschriebenen Daten auf dem Zielsystem und es ist keine Speicherung für Trail-Dateien in der Quellumgebung erforderlich. Der Collector läuft auf dem Zielsystem und empfängt Trail-Dateiinformationen, die auf die Festplatte geschrieben werden sollen. Wenn Daten extrahiert und über das Netzwerk gesendet werden, platziert der Collector die Daten in die richtigen Dateien, die vom Replikat-Prozess abgeholt werden sollen. Der Replicat-Prozess verbraucht Daten aus Trail-Dateien auf dem Zielsystem. Dieser Prozeß ist in der Lage, alle Trailinformationen zu analysieren, DDL und DML gegen die Zielumgebung zu führen und die schriftlichen Aufzeichnungen in einen Bereich zu verfolgen, der als Checkpoint-Tabelle bezeichnet wird. Um die Konsistenz zu gewährleisten und die Garantiedaten nach Fehlern ordnungsgemäß aufzunehmen, zeichnet die Checkpoint-Tabelle den Fortschritt der Replikatprozesse auf, wenn Daten verbraucht werden. Replikate sind in der Lage, große Summen von Daten sofort oder in einer synchronisierten Konfiguration zu laden. Beispielsweise kann ein Replikat erstellt werden, um eine erste Datenlast aus einer Quellumgebung auszuführen, und ein anderes kann erstellt werden, um die Synchronisierungsänderungen fortzusetzen, sobald die Anfangslast abgeschlossen ist. Wenn der Replikat-Prozess Fehler erhält, wird er seinen Fortschritt aufzeichnen und abbrechen. In GoldenGate wird der Akt des Abbruchs des Prozesses aufgrund eines Fehlers als abend bezeichnet. Wenn ein Prozess abgebrochen wird, wird er aufgrund eines Fehlers abgebrochen und muss behoben werden. GoldenGate verwendet diese Komponenten, um eine vollständige Replikationsumgebung zu erstellen. Extrahieren von Prozessen ziehen Daten und schreiben auf Trail-Dateien, die von Kollektorprozessen verarbeitet und von Replikatprozessen verbraucht werden. Die echte Magie hinter GoldenGate geschieht durch die Ausnutzung dieser Konfiguration auf verschiedene Weise: Mehrere Extraktprozesse können verschiedene Datensätze parallel verschieben und an mehrere Ziele übertragen. Einzelne Extraktprozesse können Daten übertragen und über Datenpumpen senden. Mehrere Systeme können auf ein einzelnes Ziel extrahieren, wo mehrere Replikatprozesse Daten konsolidieren können. Verwenden Sie mehrere Datenbanktypen in beliebiger Kombination für die Quelle (n) oder Ziel (e) Zum Ziel für kundenspezifische Datenanforderungen Auf diese Weise kann GoldenGate verwendet werden, um selbst die kräftigste Replikations - oder ETL-Verarbeitungsstruktur vollständig zu ersetzen. Mit diesen Fähigkeiten im Auge, lass uns über einige der Möglichkeiten sprechen, wie GoldenGate in der durchschnittlichen Oracle-Umgebung verwendet werden könnte. Das Beste aus GoldenGate machen Die GoldenGate-Installation ist einfach genug, dass es auf jedem System eingesetzt werden kann. Es funktioniert auf Unix, Linux und Windows und überträgt Daten über TCPIP. Die Software selbst ist in sich geschlossen und kann buchstäblich innerhalb von Minuten eingerichtet werden. Also mit all dieser Benutzerfreundlichkeit, wie können wir es an die Arbeit vereinfachen Extract, Transform und Load (ETL) Oracle hat viele Optionen für ETL und ELT (Extract, Load, Transform). Am meisten bemerkenswert ist Oracle Data Integrator (ODI), der nun die Integration mit GoldenGate für eine verbesserte Änderungssynchronisation beinhaltet. ODI nutzt einen hocheffizienten ELT-Prozess, um mehrere Sätze von Daten zu sammeln, an einen Staging-Speicherort zu laden und dann die Daten für die Echtzeit-Lagerung zu verwandeln. Auch ohne ODI ist GoldenGate für die Aggregation von Daten für die Lagerbelastung leicht verwendbar. Extrahierte Prozesse können Daten gleichzeitig und in Echtzeit aus Oracle, SQL Server, AS400 Umgebungen, XML, Flat Files und viele weitere Quellen ziehen. Alle diese Daten werden als mehrere Trail-Dateien in die Zielumgebung geschrieben, die dann in das Lager (wieder auf jeder Plattform) durch Replikatprozesse geschrieben werden. Mit dieser Methode kann GoldenGate sogar die Daten während des Prozesses filtern und reinigen, um den Großteil der ETL-Arbeit in einem einzigen Schritt zu erreichen. Oder wenn Sie es vorziehen, können die Daten einfach aggregiert und dann durch andere Methoden auf dem Zielsystem für ELT gereinigt werden. Mit dem Einsatz von Data Pumps, um einzelne Datenquellen an mehrere Standorte zu senden, ist es sehr einfach zu garantieren, dass Daten in Ihrem Unternehmen konsistent und zuverlässig sind. Der Extraktprozess schreibt Daten in eine lokale Trail-Datei, die von einer Datenpumpe abgeholt wird. Die Datenpumpe sendet diese Informationen wiederum an mehrere Ziele (nahe oder weit), die über den Replikatprozess gesammelt und in die Zielumgebung geschrieben werden. In dieser modernen Ära des Plattenspeichers eliminiert die Datenredundanz wie dies die Notwendigkeit kostspieliger Datenbankverbindungen und ermöglicht stattdessen den Echtzeitzugriff auf entfernte Daten durch die Verwendung von Datenvervielfältigung anstelle von Netzwerklesungen. In der Tat ist das Echtzeit-Schlagwort mit GoldenGate riesig, und Oracle benutzt es so viel wie möglich. Das Kernthema hinter GoldenGate ist der Echtzeit-Zugriff auf Echtzeit-Daten, die die Daten, die Sie benötigen, sofort zugänglich sind und immer aktuell sein werden. Das Ersetzen von Datenbankverknüpfungen mit synchronisierten Kopien verbessert die Leistung auf vielen Systemen enorm, solange die Daten garantiert werden, um frisch zu sein. Aktualisieren von Entwicklungs-Servern Einer der größten Ärgernisse für viele DBAs ist erfrischende Entwicklungssysteme mit aktuellen Daten. GoldenGate ist aus wiederverwendbaren Komponenten gebildet, und es ist sehr einfach, erste Datenlasten zu extrahieren und zu replizieren. Durch die Schaffung dieser Prozesse in GoldenGate einmal kann ein DBA einfache On-Demand-Erfrischungen von Entwicklungsumgebungen initiieren. Durch die Verwendung von Datenpumpen kann der DBA eine einzelne Extraktion verwenden und es verwenden, um mehrere Entwicklungsumgebungen, einzelne Umgebungen für verschiedene Entwicklungsteams, DBA-Sandboxen oder DevelopmentQA-Umgebungen parallel zu belegen. Diese Umgebungen können über mehrere Betriebssysteme, Datenbanksysteme oder sogar Versionen verteilt werden. Testen auf 11g (oder 12g bald) wird eine Brise aufgrund der Fähigkeit, nahtlos zu replizieren. Die Fähigkeit, zwischen den Versionen zu wechseln, führt eine weitere logische Verwendung von GoldenGate ein: Upgrade auf neue Releases. GoldenGate kann nahtlos von Server zu Server oder lokal replizieren und kann verwendet werden, um eine Datenbank auf eine neue Version mit vorhandenen Verarbeitungskonfigurationen zu duplizieren. Zum Beispiel, wenn GoldenGate verwendet wird, um Daten zwischen einer 10g-Datenbank und einer anderen 10g-Datenbank zu replizieren, ist ein Upgrade so einfach wie das Stoppen der Replikation auf das Zielsystem vorübergehend, das Upgrade auf 11g und dann die Replikation erneut starten. GoldenGate arbeitet außerhalb des Datenwörterbuchs und kann nahtlos zwischen diesen Versionen arbeiten. Das gleiche gilt für den Umzug auf einen anderen Server oder sogar auf ein anderes Betriebssystem. Rolling-Entwicklung in die Produktion Mehrere Auszüge und Replikate können einfach konfiguriert werden, um Entwicklungsdaten zu ziehen und sie mit Produktionstabellen zusammenzuführen. Alternativ können Entwicklungsdaten von mehreren Standorten gezogen werden, oder Entwicklungs - und Produktionsdaten können aus ihren jeweiligen Datenbanken gezogen und in eine neue Umgebung verschmolzen werden. Unabhängig davon, welche Methode Sie wählen, können die Konfigurationen für die Auszüge und Replikate wiederverwendet werden, um diese Operationen regelmäßig durchzuführen. Migration von Drittanbieter-Utility-Datenbanken Einige Drittanbieter-Dienstprogramme erlauben nur bestimmte Datenbank-Plattformen. Wenn Sie eine Drittanbieteranwendung haben, die nur auf MySQL oder SQL Server ausgeführt werden soll, können die Daten aus diesem System an eine Oracle-Datenbank für die Berichterstattung oder die historische Aufzeichnung gesendet werden. Bei einigen Drittanbieter-Dienstprogrammen kann es sogar möglich sein, Daten aus anderen Systemen in die Drittanbieter-Datenbank zu integrieren. Verwenden von Geschäftsdaten in SharePoint Viele Unternehmen haben mit SharePoint oder anderen Portal-Tools für ihre Unternehmensinfrastruktur begonnen. Mit Hilfe von GoldenGate können Informationen aus Finanz-, Kunden-, HR - oder anderen Datenbanken problemlos in das Firmenportal integriert werden, unabhängig davon, welcher Server die SharePoint-Datenbank beherbergt. Trouble Ticketing-Systeme und Monitoring-Tools Mit GoldenGate ist es möglich, Daten von Trouble-Ticketing-Systemen auf Monitoring-Umgebungen zu migrieren. Zum Beispiel, wenn Ihr Unternehmen ein Ticketing-Tool verwendet, um Trouble-Tickets auf einer kundenorientierten Anwendung und eine Überwachungsumgebung für IT-Personal zu erhalten, kann GoldenGate als Messaging-System durch das Kopieren von Ticket-Informationen in die Überwachungsumgebung fungieren. Alternativ könnte die Strömung umgekehrt werden, und Überwachungsinformationen könnten verwendet werden, um zusätzliche Informationen über Tickets zu liefern. Master Data Management (MDM) Die zentrale Komponente in vielen verteilten Systemen, MDM wird immer beliebter in großen Unternehmensumgebungen. MDM-Lösungen sind zentrale Datenbanken, die wichtige Unternehmensdaten enthalten, um immer genaue Informationen über verteilte Umgebungen zu gewährleisten. Zum Beispiel, wenn ein Unternehmen fünf verschiedene Datenbanken und Anwendungen nutzt, die immer Informationen über Mitarbeiter benötigen, könnte eine MDM-Umgebung ein zentraler Aggregationspunkt für Mitarbeiterdaten sein, die dann in den externen Umgebungen genutzt werden können. Bei diesen Arten von Setups kann GoldenGate sowohl für die Bereitstellung von MDM-Daten in andere Datenbanken als auch für das Laden von MDM-Daten verwendet werden. Daten-Pumpen aus dem MDM-Zentral-Repository können Informationen auf alle abonnierenden Datenbanken verteilen, und die anwendbaren Informationen aus Datenbanken im Unternehmen können Informationen an MDM für die zentrale Speicherung versenden. Oracle GoldenGate 11g ist bereit, große Änderungen in der Art, wie Daten zwischen Umgebungen bewegt werden. Während die Replikation seit langem existiert, ist GoldenGate das erste hochverfügbare Echtzeit-Replikationstool mit voller heterogener Unterstützung über viele Plattformen hinweg. Mit dem erweiterbaren extractreplicat Design ist es einfach, auf vielen verschiedenen Systemen für viele Bedürfnisse einzusetzen und wiederzuverwenden. Holen Sie sich die Complete Oracle SQL Tuning Informationen Das Landmark Buch quotAdvanced Oracle SQL Tuning Das Definitive Referencequot ist mit wertvollen Informationen über Oracle SQL Tuning gefüllt. Dieses Buch enthält Skripte und Tools, um die Leistung von Oracle 11g zu verdoppeln, und Sie können es für 30 off direkt aus dem Publisher kaufen. Leverage Ihre Oracle 11g Fähigkeiten zu lernen DB2 9.7 für Linux, UNIX und Windows Einleitung Ein früherer EntwicklerWorks Artikel sprach darüber, wie zu nutzen Ihre MS SQL Server 2000 Fähigkeiten, um DB2 zu lernen. Ist dein Hintergrund in Oracle statt SQL Server Wenn ja, lesen Sie weiter. In diesem Artikel zeigen wir Ihnen, wie Sie Ihr aktuelles Wissen über Oracle 11g nutzen können, um schnell mit DB2 9.7 IBM DB2 e-Kit für Datenbank-Profis zu finden. Erfahren Sie, wie einfach es ist, für DB2 für Linux, UNIX, Und Windows mit dem IBM DB2 e-Kit für Datenbank Professionals. Jetzt registrieren. Und erweitern Sie Ihr Leistungsportfolio, oder erweitern Sie Ihre DBMS-Anbieterunterstützung, um DB2 einzuschließen. DB2 9.7 wurde mit neuen Funktionen geliefert, um Kosten zu verwalten und die Anwendungsentwicklung zu vereinfachen. Es gab Verbesserungen in mehreren Bereichen wie Komprimierung, pureXML, Verwaltbarkeit und Leistung. Dieser Artikel konzentriert sich auf den Vergleich von DB2- und Oracle-Grundkonzepten sowie die Einführung neuer Funktionen in DB2 9.7 Hinweis: Für den Rest dieses Artikels verwenden wir den Begriff Oracle, um auf Oracle 11g und DB2 zu verweisen, um auf DB2 zu verweisen 9.7 für Linux, UNIX und Windows. Überblick über Systemstrukturen Um zu beginnen, müssen wir die von Oracle verwendete Architektur verstehen und wie sie mit DB2 verglichen werden. Abbildung 1 zeigt die Systemstruktur von Oracle. Vergleichen Sie es mit Abbildung 2., die die Systemstruktur von DB2 zeigt. Verweise auf diese Zahlen zum Verständnis, wie Sie den Artikel lesen. Abbildung 1. Oracle-Systemstruktur auf Linux, UNIX und Windows Abbildung 2. DB2 auf Linux-, UNIX - und Windows-Systemstruktur Das Konzept einer Instanz ähnelt sowohl in Oracle als auch in DB2. In beiden Fällen ist eine Instanz eine Kombination aus Hintergrundprozessen und gemeinsamem Gedächtnis. Der Hauptunterschied zwischen den beiden ist, dass in Oracle kann es nur eine Datenbank pro Instanz, während in DB2 mehrere Datenbanken können eine Instanz zu teilen. Da es eine Eins-zu-eins-Korrespondenz zwischen Datenbank und Instanz gibt, erstellen Sie im Oracle eine Instanz implizit, indem Sie eine Datenbank mit dem Befehl CREATE DATABASE erstellen. Alternativ können Sie zum Erstellen einer Oracle-Instanz auf Ihrem Computer den Datenbankkonfigurationsassistenten verwenden oder das mit Oracle 9i verfügbare ORADIM-Dienstprogramm mit der Option NEU verwenden. Sie müssen auch bestimmte Informationen einschließlich eines System Identifier (SID) oder eines Dienstnamens, Instanzpasswort, maximale Anzahl von Benutzern, Startmodus und so weiter bereitstellen. Ähnlich, um die Instanz zu löschen, kann das ORADIM-Dienstprogramm mit der Option DELETE verwendet werden. Sie müssten entweder die SID oder den Servicenamen übergeben. Es gibt keine Standardinstanz, die mit einer Neuinstallation von Oracle erstellt wurde, es sei denn, Sie erstellen eine neue Datenbank während des Installationsvorgangs. In DB2 wird nach der Installation des Produkts auf der Windows-Plattform die Instanz-DB2 standardmäßig erstellt. Unter Linux und UNIX heißt der Standardinstanzname db2inst1. Um eine andere Instanz in derselben Maschine zu erstellen, führen Sie einfach den Befehl db2icrt ltinstance namegt aus. Abbildung 3 zeigt eine Instanz namens DB201, die mit dem Befehl db2icrt aus der DB2 Control Center-GUI erstellt wurde. Abbildung 3. DB2-Control Center-GUI mit DB2-Instanzen Um eine bestimmte DB2-Instanz über eine Befehlszeilenschnittstelle zu verweisen, verwenden Sie die Umgebungsvariable DB2INSTANCE. Mit dieser Variablen können Sie die aktuelle aktive Instanz angeben, auf die alle Befehle zutreffen würden. Wenn z. B. DB2INSTANCE auf PROD gesetzt ist und dann die Befehlsdatenbank MYDB1 ausgeben. Sie erstellen eine mit Instanz verbundene Datenbank. Wenn du diese Datenbank auf Instanz-DB2 stattdessen erstellen wolltest, dann musst du zuerst den Wert der DB2INSTANCE-Variablen in DB2 ändern. Dies ähnelt der ORACLESID (System Identifier), die auch verwendet wird, wenn Benutzer zwischen Instanzen wechseln möchten. Eine weitere einfache Möglichkeit, die Instanz zu identifizieren, mit der Sie arbeiten möchten, ist die Verwendung der DB2 Control Center-GUI, wie in Abbildung 3 gezeigt. Um einen Eintrag für die neue Instanz in diesem Tool zu sehen, müssen Sie die Instanz der GUI nach rechts hinzufügen Klicken Sie auf Instanzen und wählen Sie Hinzufügen. Um eine Instanz in DB2 zu löschen, kannst du den Befehl db2idrop ltinstance namegt ausführen. Zusammenfassend kann in Oracle der Datenbankkonfigurationsassistent verwendet werden, um die Instanz zu erstellen, zu modifizieren, zu starten, zu stoppen und zu löschen, während in DB2 die Control Center-GUI für einen ähnlichen Zweck verwendet werden kann. Auch eine Oracle-Instanz kann nur eine Eins-zu-eins-Beziehung zu einer Datenbank haben, während im DB2 das nicht der Fall ist. Es können mehrere Datenbanken existieren und gleichzeitig in einer DB2-Instanz verwendet werden. In Oracle kann eine Datenbank entweder manuell über den Befehl CREATE DATABASE oder über den Database Configuration Assistant erstellt werden. Wenn Sie die Datenbank manuell erstellen, müssen Sie eine Reihe von Schritten befolgen, einschließlich der Einstellung von OS-Variablen, der Vorbereitung der Parameterdatei und der Erstellung einer Passwortdatei, bevor der Befehl CREATE DATABASE ausgeführt werden kann. Metadateninformationen werden von dem Datenwörterbuch gespeichert und verwaltet, das aus Basistabellen und entsprechenden Ansichten besteht. Die Basistabellen werden bei der Erstellung der Datenbank automatisch erstellt und die Ansichten werden konstruiert, indem die Skripts catalog. sql und catproc. sql ausgeführt werden. Die Oracle-Datenbank wird daher als eine Sammlung von drei Dateitypen betrachtet: Datendatei. Enthält aktuelle Daten, physische Implementierung der Datenbank. (Ähnlich wie Container in DB2) Redo File. Dies entspricht den Transaktionsprotokollen in DB2. Steuerdatei. Enthält Informationen zur Aufrechterhaltung und Überprüfung der Datenbankintegrität. In DB2 kann eine Instanz mehrere Datenbanken enthalten, wie in Abbildung 2 dargestellt. Jede Datenbank ist eine wirklich geschlossene und unabhängige Einheit. Jede Datenbank verfügt über einen eigenen Katalogtabellenbereich, temporären Tabellenbereich und Benutzertabellenbereich, die bei erfolgreicher Datenbankerstellung standardmäßig erstellt werden. DB2 enthält eine Binärdatei, die als Systemdatenbankverzeichnis bekannt ist und Einträge aller Datenbanken enthält, die Sie von Ihrem DB2-Rechner anschließen können. Dieses Verzeichnis wird auf der Instanzebene gehalten. Wenn eine Instanz erstellt wird, werden standardmäßig keine Datenbanken erstellt. Sie müssen explizit eine Datenbank mit dem Befehl create database erstellen. Sie können auch eine Datenbank mit dem Control Center erstellen, wie in den Abbildungen 4 und 5 gezeigt. Figure 4. Creating a DB2 database using the Control Center GUI Figure 5. Creating a DB2 database using the Control Center GUI (continued) In Figure 5. you can also see what happens when you click Show Command . All DB2 Control Center GUI screens let you see the SQL statement or command that is actually executed in the background. These commands can be saved in scripts for execution at a later time, or can be copied and executed from the Command Line Processor (CLP) tool or Command Center GUI tool. These tools are equivalent to Oracles SQLPlus and iSQL Plus respectively. A DB2 database can be dropped by using the DROP DATABASE command or from the DB2 Control Center GUI. In Oracle there is no such command a database is deleted by deleting all the associated datafiles. Databases within an instance normally dont interact with each other. However, if your application needs to interact with more than one database, this requirement can be supported by enabling federation support. See the resources section for an article about federation. Containers, table spaces, bufferpools and pages In Oracle, data is physically stored in files called Data Files. This is similar to DB2s containers where data is physically stored. Every Oracle database contains a table space named SYSTEM, which Oracle creates automatically when the database is created. Other table spaces for user, temporary and index data need to be created after the database has been created, and a user needs to be assigned to these table spaces before they can be used. In DB2, a table space is the logical object used as a layer between logical tables and physical containers. When you create a table space, you can associate it with a specific buffer pool (database cache) as well as to specific containers. This gives you flexibility in managing performance. For example, if you have a hot table, you can define it in its own table space associated with its own buffer pool. This helps ensure the data for this table is continuously cached in memory. In DB2 three default table spaces are created automatically upon database creation when using default values for the CREATE DATABASE command. Table 1 describes the default DB2 table spaces: Table 1. DB2 table spaces created by default when a database is created with default values User table space. By default, USERSPACE1 is normally created after database creation As indicated earlier, Oracles data buffer concept is equivalent to DB2s bufferpool however, DB2 allows for multiple bufferpools to exist. There is no predefined number of bufferpools that you can create, and they can have any name. The concept of an Oracle block is most similar to DB2s page. A DB2 page can have a size of 4k, 8k, 16k or 32k. A table row must fit in only one page it cannot span to other pages as in Oracle. Object names An Oracle object name takes the following form: In DB2, objects also have a two-part structure: As in Oracle, the DB2 schema name is used to group objects logically. An important difference, however, is that in DB2, a schema name does not have to match to a user id. Any user with a privilege called IMPLICITSCHEMA can create an object using a non-existing schema. For example, suppose that Peter has IMPLICITSCHEMA privilege and executes this command: CREATE TABLE WORLD. TABLEA (lastname char(10)) In this case, the table WORLD. TABLEA is created, where WORLD is the newly created schema. If Peter had not explicitly indicated the schema, then the table PETER. TABLEA would have been created, because the connection ID is used by default. In DB2 you always connect to a database before issuing database specific commands therefore, under this architecture, object names need not include the database name. Tables, views, and indexes Tables, views, and indexes are basically the same in both Oracle and DB2. DB2 provides a utility called Design Advisor which you can use to recommend indexes for a particular query or workload. You can invoke the Design Advisor from the DB2 Control Center or from the DB2 CLP using the db2advis command. In DB2, indexes are directly tied to the table definition. For example, when using DMS table spaces you can specify in which table space the indexes can reside as follows: CREATE TABLE mytable (col1 integer, col2 char(10)) in tbls1 index in tbls2 The above example shows that the data for the table will be stored in table space tbls1, while the index pages will be stored in table space tbls2. This is in contrast to Oracle syntax where the CREATE INDEX statement provides an option to specify in which table space the index will reside. Also, once an index has been created in DB2, you cannot alter any clause of the index definition. You would need to drop the index and create it again in order to implement changes. As in Oracle, DB2 tables, views and indexes in different databases can have the same names. Tables and views within the same database must have distinct names, but creating an index with the same name as either an existing table or view is allowed. Stored procedures, triggers and user-defined functions (UDFs) DB2 stored procedures can be written in any language supported by the DB2 precompilers, including Java, C, C, REXX, Fortran, and COBOL. However, the recommended language to use is the SQL Procedural Language (SQL PL), which is fairly similar to Oracles PLSQL. SQL PL stored procedures are easy to create and have good performance. DB2 stored procedure development also supports SQLJ and Java using JDBC drivers type 2 and 4. Type 3 is discontinued. Development of triggers and functions can use inline SQLPL, a subset of SQL PL. The Data Studio tool can be used to easily create, build, debug and deploy DB2 stored procedures and user-defined functions. Configuration files Traditionally Oracle stores all session and system-related parameters in a text file, normally referred to as initSID. ora. However due to the non-persistent nature of this text file, starting from Oracle 9i, Oracle introduced Server Parameter File (SPFILE), which is a binary parameter file stored on the server. This persists across instance shutdown and startup. The initSID. ora file is still used, however, when an SPFILE is not available. Prior to the introduction of SPFILE, any ALTER SYSTEM and ALTER SESSION commands that affected parameters would only persist during that instance or that session. The DBA would have had to manually modify the initSID. ora text file whenever a rebound of a database instance was intended. Network access configurations are typically stored in listener. ora for listener and tnsnames. ora for client access. With DB2, configuration parameters are stored at the instance level, known as the database manager configuration file, and at the database level, known as the database configuration file. Most of these parameters can be changed dynamically, that is, there is no need to stop and restart the instance or force all connections from a database before the change to the parameter value takes effect. The files where DB2 stores its configuration information cannot be edited directly. If you would like to manually change a specific database manager parameter from the CLP, use the command UPDATE DBM CFG USING ltparameter namegt ltnew valuegt . If you would like to manually change a specific database parameter from the CLP, use the command UPDATE DB CFG FOR ltdatabase namegt USING ltparameter namegt ltnew valuegt. These commands would be the equivalent to Oracles ALTER SYSTEM and ALTER SESSION. Alternatively, using the Control Center, you can review and change values for these parameters if you right click on a given instance and choose Configure Parameters . you will see the window shown in Figure 6 . Figure 6. DB2 Database Manager configuration parameters (instance level) At the database level, right clicking on a given database, and choosing Configure Parameters displays the window shown in Figure 7 . Figure 7. Database configuration parameters (database level) DB2 provides many parameters you can use to configure your system. However, if you would like an easy way to configure the system automatically, use the autoconfigure command (or the Configuration Advisor GUI) which sets the database manager and database configuration parameters to optimal values based on some information you provide. Figure 8 shows the Configuration Advisor. Figure 8. - DB2 Configuration Advisor In addition to configuration files, DB2 also uses DB2 Registry variables normally for platform-specific configurations. Note, the DB2 Registry variables have no relationship whatsoever to the Windows registry . Use the command db2set to review and change these variables. Connectivity (network access) information is stored in the system database directory, local database directory and node directory. These are binary files and can only be modified with the CATALOG and UNCATALOG commands. Memory architecture, background processes and threads Next well look at the memory architecture, background processes and threads, and will compare and contrast the way they are used in Oracle and DB2. Figure 9: Oracle memory architecture and background processes The System Global Area (SGA) in Oracle is a group of shared memory areas that stores information for the instance. Examples include statement cache, redo log buffers, and data buffer cache. The Program Global Area (PGA) and the User Global Area (UGA) shared memory areas contain data and control information for server processes and user sessions. Oracle supports multiple instances within the same machine but background processes are not shared. For example, three instances in one machine will require three set of background processes. Therefore it is generally recommended to have one database, one instance and multiple schemas within the same machine. Figure 10: DB2 Memory architecture and background processes and threads Both DB2 and Oracle use shared memory areas, but DB2s memory architecture is implemented in a slightly different way than Oracles. Since a DB2 instance can contain more than one database, two levels of configuration exist. As we mentioned in the previous section, instance level configuration can be done in the DBM CFG file while the database level configuration is done in the DB CFG file. Configuration parameters at both levels can be adjusted to tune memory usage. The section below provides a bit more detail on DB2s memory structures and different background processes. Unlike Oracle where memory is allocated to both the instance and the database upon startup, DB2 allocates memory at different levels. This is primarily due to the fact that a DB2 instance can contain multiple databases. There are three main memory structures in DB2: Instance shared memory . This refers to the database manager global shared memory, which is allocated when the instance is started using the db2start command, and remains allocated until a db2stop command is issued to stop the instance. Database shared memory . This refers to the database global memory, which is allocated when the database is activated or connected to for the first time. Memory allocated includes buffer pools, locklist, database heap, utility heap, package cache and catalog cache. Application shared memory . This refers to the memory allocated when an application connects to a database and is used by agents that do the work requested by the connected clients. Each application connected to the database has memory allocated to it therefore accurate configuration of the parameters affecting the application shared memory becomes crucial. The DB2 database server must perform many different tasks, such as processing database application requests or ensuring that log records are written out to disk. Each task is typically performed by a separate engine dispatchable unit (EDU). In DB2 for Windows, Linux and UNIX. server activities are conducted in the form of threads. DB2 threads and processes operate in the following levels. Note that this is a non-exhaustive list but we do highlight the important threads and processes: Instance Level: These are processes and threads that are initialized when an instance is started: DB2 Daemon Spawner (db2gds): Global daemon processor started for each instance (only in UNIX) DB2 System Controller (db2sysc): Main DB2 process DB2 Watchdog (db2wdog): Parent process for all other processes DB2 Format Log (db2fmtlg): Similar to the ARCn process in Oracle, pre-allocates log files in the log path Autonomic computing daemon (db2acd): Hosts the health monitor, automatic maintenance utilities, and the administrative task scheduler. This process was formerly known as db2hmon. Database Level: These are processes that are initialized when a connection is made to a database. DB2 Log Reader (db2loggr): Similar to the subset of Oracles PMON process. This process reads log files during rollback, restart recovery and roll forward. DB2 Log Writer (db2loggw): Flushes log from log buffer to the transaction log files on disk. Equivalent to LGWR process in Oracle. DB2 Page Cleaner (db2pclnr): Equivalent to DBWR process in Oracle, this process cleans the buffer pool before pages from the disk are moved into the BP. DB2 Prefetcher (db2pfchr): Retrieves pages from disk and places into the buffer pool before it is needed. DB2 Deadlock Detector (db2dlock): Deadlock detector process. DB2 Self-Tuning Memory Manager (db2stmm): for the autonomic self-tuning memory management feature. Application Level: Each application connecting to the database would have its own share of application-level background processes associated with it. These are as follows: DB2 Communication Manager (db2ipccm): Inter-process communication process for each locally connected client. DB2 TCP Manager (db2tcpcm): TCP communication manager process for remote clients connecting using TCPIP. DB2 Coordinating Agent (db2agent): Thread that handles all requests on behalf of an application. DB2 Pooled Gateway Agent (db2agntgp and db2agntgp): An agent pooled on a remote database and local database respectively. For a comprehensive explanation of DB2s processes please refer to the article Everything you wanted to know about DB2 processes . Locking mechanisms Locking in Oracle can be either manual or automatic. The Oracle Lock Manager can implicitly lock table data at the row level, or default locks can be overridden at transaction or session level using the following SQL statements: 1. SET TRANSACTION ISOLATION LEVEL 2. LOCK TABLE 3. SELECT FOR UPDATE Oracle supports a mechanism called Multi-Version Read Consistency which is implemented by undo data in the undo segments. DB2 implements ANSI standard Isolation levels such as Uncommitted Read, Cursor stability, Read stability and Repeatable Read. A user will only see committed data unless the Uncommitted Read isolation level is used. Row locks are acquired implicitly according to the isolation level. Database objects that are lockable are table spaces, tables and rows, however, only tables and table spaces can be explicitly locked. The LOCK TABLE command can be used to lock a table instead of using the default row locking. Unlike Oracle, in DB2, locks are stored in the memory and not in data pages. The LOCKLIST database configuration parameter can be used to configure the memory available for locks, while the MAXLOCKS configuration parameter defines the maximum amount of memory for a particular applications locks. In DB2 9.7 lock event reporting has been enhanced. The new lock event monitor collects information about lock timeouts, deadlocks, and lock waits that are more than a specified duration. This data can be accessed from either a XML document, from database tables or using a java based tool (db2evmonfmt) to read from an xml or text document. A new database configuration parameter curcommit has been introduced which basically allows only committed data to be returned, as was the case previously, but now readers do not wait for writers to release row locks. Instead, readers return data that is based on the currently committed version that is, data prior to the start of the write operation. Both Oracle and DB2 are secure databases with basic and advanced security features. In Oracle, there are 4 different user authentication methods, as follows: Database . The database performs both identification and authentication of users. External . The operating system or network service performs authentication Global authentication and authorization . The user is authenticated globally by SSL Proxy authentication and authorization . The middle-tier server performs authentication. The authentication method is specified when creating the user using the CREATE USER command. There are several Data Dictionary views that contain information about these users. In DB2, users do not exist within the database, but are rather managed by the operating system. No database login information is kept in any database table. Any operating system user can potentially access DB2 however, unless they have been granted a given DB2 authority or privilege, there is not much they can do. Granting and revoking authorities and privileges can easily be handled through the Control Center GUI. You first may have to add a user or group to the Control Center from the available operating system users or groups. Also in DB2 the term roles is not used instead, DB2 uses the term authorities, which are similar to Oracles database roles, whereby privileges are granted to certain groups or users. The authorities supported with DB2 are: SYSADM, SYSCTRL, SYSMAINT, SYSMON, SECADM, DBADM and LOAD. The SYSADM, SYSCTRL and SYSMAINT authorities cannot be granted using the GRANT SQL statement. These special authorities can only be set by modifying the specific database manager configuration parameters. DB2 also uses the term privilege which is similar to Oracles system and schema object privileges. There are database privileges (connect, createtab, and so on) and database object privileges (schema, table, view, and so on). Figure 11 shows DB2 security information obtained from the Control Center GUI. Most of the tabs shown on the Change User window correspond to the privileges supported by DB2. Figure 11. DB2 security Authentication in DB2 does not only involve encrypting user names and passwords but also allows for encryption of data as it travels across the network between the clients and the server. The location of the authentication process is determined by the value of the database manager configuration parameter AUTHENTICATION. The following are the valid options for enabling authentication for DB2: SERVERENCRYPT - This value specifies that the authentication occurs on the server. The user id and password specified during connection are encrypted and sent to the server where they are compared with the user and password on the server side. If the match is successful, the user is allowed to access the database. KRBSERVERENCRYPT - This specifies that the server accepts KERBEROS authentication or encrypted SERVER authentication schemes. DATAENCRYPT - This setting specifies that the server allows for SERVER authentication, and also that the data traveling over the network between the client and server is encrypted. DATAENCRYPTCMP - This specifies that the server accepts encrypted SERVER authentication schemes and the encryption of user data. This authentication type allows for compatibility with down-level products not supporting the DATAENCRYPT authentication type. GSSSERVERENCRYPT - This specifies that the server accepts GSS API-based plug-in authentication or encrypted server authentication schemes. To update the AUTHENTICATION instance parameter, for example to a value of DATAENCRYPT, use the commands shown below: Listing 1. Updating AUTHENTICATION instance parameter DB2 further extends security by offering a Label Based Access Control (LBAC) mechanism. The LBAC feature provides for greater granularity for controlling read and write access to individual rows and table columns. A security administrator role (SECADM) has been provided in DB2 which is needed to manipulate LBAC objects. Users attempting to access an object must have its security label granted to them. When theres a match, access is permitted without a match, access is denied. There are other aspects of database security beyond privileges and authorities. Briefly, here are some of the differences and similarities between Oracle and DB2: User authentication and authorization Oracle uses an encrypted password stored in the dictionary once a user is created. DB2 supports passwords for user authentication and uses the underlying operating user for authentication. Both Oracle and DB2 support LDAP (Oracle Internet Directory and IBM Directory Server). Both Oracle and DB2 support single sign on (SSO). Oracle supports data encryption where sensitive data such as credit card numbers and some highly sensitive business data can be encrypted. You have the following options for encrypting DB2 data in storage: You can use the encryption and decryption built-in functions ENCRYPT, DECRYPTBIN, DECRYPTCHAR, and GETHINT to encrypt your data within database tables. You can use IBM Database Encryption Expert to encrypt the underlying operating system data and backup files. If you are running a DB2 Enterprise Server Edition system on the AI operating system, and you are interested in file-level encryption only, you can use encrypted file system (EFS) to encrypt your operating system data and backup files. Oracle provides network encryption with its Oracle Advanced Security. Oracle uses DES, 3DES and RC4 industry standard encryptions. To encrypt data in-transit between clients and DB2 databases, you can use the DATAENCRYPT authentication type, or, the DB2 database system support of Secure Sockets Layer (SSL). Oracle allows you to audit trail users and objects. Log miner can also be used for investigating and analyzing suspicious queries. DB2 provides a similar auditing facility. The db2audit utility can be used for this purpose. XML support This section compares Oracles support for XML to DB2s. Shipped with Oracle 9i Release 2, Oracle XML DB feature provided a way to manage XML storage, retrieval and schema by defining XMLTYPE tables and columns which are stored as CLOB or shredded (decomposed) to small pieces into relational tables. Oracle 10g came with some improvements to manage XML documents for example, changes in schema can be dynamically reflected by mapping existing data without the need to re-import. In Oracle 11G, a third kind of XML support called binary XML was introduced. So Oracle now has the following ways of storing XML data: Unstructured storage using CLOBs (also know as schema-less storage) Structured storage which maps XML to object relational Binary XML storage DB2s pureXML technology, stores XML documents natively, that is, internally in tree format. It also allows for the use of SQL with XML extensions, Xquery and Xpath to access relational and XML data. Storing XML documents natively is a better approach, and IBMs research indicates that there is a better performance for search and retrieval of XML documents, and reduction in the lines of codes for certain programs. Support for the DB2 XML data type is available in the DB2 Control Center, command line processor, IBM Data Studio, and IBM Database Add-Ins for Microsoft Visual Studio. In order to use the pureXML feature in your database, create the database as UNICODE (for example using codeset UTF-8). Failure to create a UNICODE database prior to creating a table will result in an error as shown below: DB2 stores relational data as in previous versions. However, XML data is stored in hierarchical format (as a tree using the Xquery Data Model, XDM). There is tight integration between both XML and relational services. To store XML documents, a user needs to create a table, and specify a column to use a new data type, XML, as shown in the example below. Listing 2. Create a DB2 table with XML datatype As XML documents are stored in parsed hierarchical format natively in the XQuery Data Model (XDM), there is no need for translation or mapping the format used to store XML documents is the format used to process it. This allows for greater performance. Utilities such as backup, restore and import apply to tables with XML columns the same as in any other tables. XML data can be inserted into the XML column either by using the INSERT statement or by using the DB2 IMPORT utility. Prior to importing XML documents received from third parties, it is a good idea to validate these documents against a pre-defined XML schema. To register against an XML schema, DBAs are required to issue the REGISTER XML SCHEMA command, ended with COMPLETE XML SCHEMA to complete the registration process. DB2 also supports indexes to be created on a subset of an XML document, or on the entire document. An XPATH needs to be specified when creating an index which would point to that particular elementattribute to be indexed. With DB2 you now have four ways to access relational and XML data: Plain SQL (no XQuery involved) SQLXML, that is, XQuery embedded in SQL XQuery as a stand-alone language (no SQL involved) Xquery with embedded SQL In DB2 9.7 additional XML features were included such as support for the XML type in User Defined Funcions. Important enhancements in DB2 9.7 are that the LOAD utility can now be used to load XML data. Also, On partitioned tables, indexes over XML data that you create with DB2 V9.7 or earlier are nonpartitioned. Starting in DB2 Version 9.7 Fix Pack 1, you can create an index over XML data on a partitioned table as either partitioned or nonpartitioned. There are more developerWorks articles on IBM pureXML capabilities such as Query DB2 XML data with XQuery. Query DB2 XML Data with SQL amongst others for more in-depth discussions. Partitioning Oracle Partitioning offers several partitioning strategies that control how the database places data into partitions. The basic strategies are range, list, and hash partitioning. DB2s table partitioning (a. k.a Range partitioning), is similar to Oracles partitioning. It basically allows a single logical table to be broken up into multiple physical storage objects across one or more table spaces. Each of the objects would correspond to a partition and would allow each table space to contain a range of data which can be accessed very easily. In DB2 there are several ways to partition your data, and you can apply these methods simultaneously on the same data. To avoid confusion, here is a short explanation about the different ways to provide this partitioning: DATABASE PARTITIONING - distributing data by key hash across logical nodes of the database (DPF). RANGETABLE PARTITIONING (Available with DB2 9) - splitting data by key range over multiple physical objects within a logical database partition. MULTI DIMENSIONAL CLUSTERING (MDC) - organizing data in table (or range of a table) by multiple key values. In Version 9.7, you can have indexes that refer to rows of data across all partitions in a data partitioned table (known as nonpartitioned indexes), or you can have the index itself partitioned such that each data partition has an associated index partition. You can have both nonpartitioned and partitioned indexes for partitioned tables. The following example creates a table customer where rows with lshipdate gt 01012006 and lshipdate lt 03312006 are stored in table space ts1, rows with lshipdate gt 04012006 and lshipdate lt 06302006 are in table space ts2, etc. More exhaustive explanation can be obtained from developerWorks article, Table partitioning in DB2 9 . Listing 3. Range partitoning a table A comparison of Oracle and DB2 partitioning terminology can be found in Table 1 of the article Migrate from Oracle or Sybase to DB2 in weeks. Compression There are three compression features provided by Oracle index, table and row level compression. Improper planning of these features may have adverse effect in performance. Oracle introduced index compression since version 8i. Indexes that can be compressed are bitmap, btree and index organized tables. To use index compression is straightforward for example, to create an index with the compression feature, use: Listing 4. Create index with compression For indexes that were not created initially with compression, you can turn them to compression by altering them. Listing 5 shows an example of how you can alter an index to include compression. Listing 5. Alter index with compression Currently, Oracle doesnt provide any automated advisor to pinpoint which indexes should be compressed. Most of the benefits gained by index compression requires proper planning by seasoned DBAs who with intimate knowledge of Oracle CBO. Table compression on the other hand, was introduced in Oracle 9i release 2. It can be used to compress entire tables, table partitions, and materialized views. The compression can be applied to all partitions or some partitions. Though table compression works for a non-partitioned table, its usage for non-partitioned tables in OLTP workloads may not be desirable as insert and update performance may suffer. In Oracle table compression, duplicate values are removed in a database block, and information is stored to recreate the uncompressed data within the block. The following example shows how to create partition table with compression. Listing 6. Create table with compression To turn a table into a compressed table, use alter table lttable namegt move compress . A compressed table, however, does not allow adding or dropping of columns. In DB2 9.7, row compression, also referred to as deep compression, compresses data rows by replacing patterns of values that repeat across rows with shorter symbol strings. Of the various data compression techniques available in DB2 9.7, row compression offers the biggest possibilities for storage savings. Row compression requires the creation of a dictionary which stores a mapping between repetitive patterns or entries and numeric keys. The compression algorithm is intelligent enough not to compress rows that will not realize in any significant disk-space saving. DB2s row compression, unlike Oracles key compression, does not require keys to be specified. Compression is enabled at individual table level via the CREATE TABLE or ALTER TABLE commands. For example: Listing 7. CreateAlter table with COMPRESSION YES To achieve the same effect using the DB2 Control Center, during the column definition (second step in the table creation wizard), ensure that you choose the checkbox, Store table data in a compressed format located at the bottom of the panel (as the following diagram shows). Figure 12. DB2 Control Center - Creating table with compression The table dictionary is built only when a REORG is performed, after which the data in the table can be compressed. The dictionary gets updated for every subsequent REORG operation. The compressed data is kept both on disk and memory and DB2 also compresses user data stored in log files, thereby reducing log file size. Note that each partition of a partitioned table can have a different compression dictionaries and each partition of a table in DPF can have a different compression dictionaries. Besides, data row compression, other compression mechanisms offered by DB2 9.7 include: NULL and Default Value Compression (V8 GA): Compression for null, zero length data in variable length columns and system default value. Multidimensional Clustering (V8 GA): Implements a form of index compression by using block indexes, one index entry for thousands of records. Database Backup Compression (V8 FP4): Compression to result in smaller backup images. XML Parsing Autonomic Features There are a few tuning improvements provided in Oracle 11g. Oracle automated the following tuning areas: Redo Logfile Sizing Advisor - This feature recommends the optimal size of redo log files in order to avoid excessive disk IOs due to frequent checkpointing. Automatic Checkpoint Tuning - The Oracle Database can now self-tune checkpointing to achieve good recovery times with low impact on normal throughput. You no longer have to set any checkpoint-related parameters. Automatic Shared Memory Tuning - Automatic Shared Memory Tuning automates the configuration of System Global Area (SGA) memory-related parameters (buffer cache, shared pool) through self-tuning algorithms. It simplifies database configuration, ensures most efficient utilization of available memory and improves performance. Transaction Rollback and Recovery Monitoring - This feature enables you estimate how long it will take to roll back a transaction. You can also monitor the progress of transactions being recovered and estimate the average speed of transaction recovery. SQL Tuning - The SQL Tuning Advisor automatically tunes high cost SQL statements. Automatic Storage manager - The automatic storage manager (ASM) simplifies the managment or Oracle related files. Oracle also provides some advisors such as segment and undo advisors. The segment advisor is based on the level of space fragmentation within an object, and as result, gives advice on whether an object is a good candidate for the new online shrink operation. As well, this advisor give reports on the historical growth trend of segments, and proved to be especially informative for capacity planning. Undo Advisor, on the other hand, helps administrators to make the right judgement in sizing the undo table space in both flash back and non-flashback features. It advises administrators in setting UNDORETENTION appropriately to avoid the age-old snapshot too old problem. DB2 9.7 has several autonomic features to assist in managing its environment that are self-configuring, self-healing, self-optimizing, and self-protecting. By sensing and responding to situations that occur, autonomic computing shifts the burden of managing a computing environment from database administrators to technology. Automatic memory tuning DB2 9.7 features a self-tuning memory feature called the Self Tuning Memory Manager that simplifies the task of memory configuration by automatically setting values for several memory configuration parameters. When enabled, the automatic tuner acting as dispatcher will figure out the memory resources available and distribute them to several memory consumers for the database dynamically. Self-tuning memory only applies to single partition databases. Automatic configuration With the AUTOCONFIGURE command you can calculate and displays initial values for the buffer pool size, database configuration and database manager configuration parameters, with the option of applying these recommended values. Automatic storage management Automatic storage automatically grows the size of your database across disk and file systems and since it automatically grows the size of the database, it removes the need to managing storage containers by DBAs. When you create databases in DB2 9.7 the automatic storage management feature is enabled by default. Automatic Maintenance DB2 9.7 has automatic maintenance capabilities that are used for automatically performing maintenance functions such as: Automatic database backups which provide the capability of a full database backup performed as needed. Automatic statistics collection. DB2 determines which statistics are required and need to be updated and then automatically executes the RUNSTATS utility in the background. Automatic table and index reorganisation. DB2 determines if a table or index reorganization by periodically checking tables and indexes that have had their statistics updated, and schedules such operations whenever they are necessary. We shall look at tools from different areas such as database creation and maintenance, network, administration GUI, performance tuning, data movement and backup-recovery tools. Figure 13 shows the DB2 9.7 GUI tools. Figure 13. DB2 9.7 GUI Tools Lets take a look at how similar tasks are performed in Oracle and DB2 9.7. Database Creation and Maintenance Oracle provides the Database Configuration Assistant (dbca) as the GUI tool to create databases. For database maintenance, Oracle provides the Oracle Enterprise Manager. DB2 databases can be created and maintained from the DB2 Control Center. Oracle provides the Network Configuration Assistant (netca) for network configuration. Alternatively, you can use the Oracle Network Manager to configure service naming, listener, profile and Oracle name servers. DB2 uses the CATALOG command to catalog nodes and databases. Cataloging can also be done using either the DB2 command line or DB2 Configuration Assistant GUI. The Oracle Enterprise Manager provides a wide range of administrative capabilities for the day-to-day tasks of administrators. DB2 Control Center provides similar functions as Oracle Enterprise Manager. Apart from the DB2 Control Center, you can also use the DB2 command line processor to issue DDL and DML statements. This utility is similar to the Oracle SQLPLUS utility. Figure 14 shows the DB2 command line processor. Figure 14. DB2 Command Line Processor Commands can also be issued from the Command Center, shown in Figure 15 . Figure 15. Command Center GUI (GUI version of DB2 Command Line Processor) Oracle Enterprise Manager comes with Change Management pack, Tuning Pack, and Diagnostic Pack. DB2 provides the Activity Monitor, Event Analyzer, Health Center, Indoubt Transaction Manager and Memory Visualizer as GUI tools for performance tuning tasks. Oracle provides SQL Loader (sqlldr) for loading data in delimited text format. Import (imp) and export (exp) can be used to perform logical import and export. DB2 provides similar import, export and load utilities. For cross platform data movement, DB2 provides the db2move utility. Backup and Recovery Oracle provides Recovery Manager as an option for hot backup. Backing up databases in DB2 can be accomplished using the backup command or the DB2 Control Center. Oracle 11g Enteprise Manager comes with new performance overview charts. The enhanced Oracle Enterprise Manager HTML interface provides a central point of access to all database performance-related statistics and facilitates complete monitoring and diagnostics. Apart from interfaces that are shipped with DB2 9.7 there is a no-charge application development tool, based on the Eclipse framework called tbe IBM Data Studio (Data Stuidio). Data Stuidio is a one-stop center for creating, editing, debugging, deploying, and testing DB2 stored procedures and user-defined functions. You can also use the Data Stuidio to develop SQLJ applications, and create, edit, and run SQL statements and XML queries. You can download IBM Data Studio from the Developerworks web site. For more details about IBM Data Studio review this tutorial tutorial in developerWorks. For examples and features, refer to the IBM Data Studio Features and Benefits web page. article in developerWorks. In this article weve introduced you to DB2 9.7 for Linux, UNIX and Windows by using your current knowledge of Oracle 11g as leverage. We briefly described the DB2 architecture, background processes, memory model, security, tools, and so on. There are many similarities between Oracle and DB2 9, and we have pointed out some of the differences so you can use your current knowledge to become successful with DB2 9.7. Table 3 summarizes the differences and similarities between Oracle and DB2 that weve discussed. Table 3. Summary of Oracle vs. DB2 concepts The article Migrate from Oracle or Sybase to DB2 in weeks (Data Management Magazine, Oct 2010) contains some helpful comparisons of DB2 and Oracle terminology and technology. The article DB2 9.7: Run Oracle applications on DB2 9.7 for Linux, UNIX, and Windows (developerWorks, May 2010) describes the out-of-the-box support for Oracles SQL and PLSQL dialects in DB2 9.7. IBM Data Movement Tool (developerWorks, Nov 2010): Move data from source databases to DB2 the easy way. An inside look at IBM DB2 Advanced Enterprise Servier Edition (developerWorks, March 2011): Learn about a software bundle that packages DB2 with optimization, development, and management tools. The Redbooks174 publication Oracle to DB2 Conversion Guide: Compatibility Made Easy is an Oracle to DB2 migration guide. It describes the new DB2 Oracle Database compatibility features, new technology, best practices for moving to DB2, and how to handle some common scenarios. The article Everything you wanted to know about DB2 processes (developerWorks, Apr 2003) describes the processes that DB2 uses on Linux, UNIX, and Windows, and details their functions. The IBM Redbooks publication Oracle to DB2 Conversion Guide for Linux, UNIX, and Windows is a step-by-step guide for migrating from Oracle to DB2. Visit the developerWorks resource page for DB2 for Linux, UNIX, and Windows to read articles and tutorials and connect to other resources to expand your DB2 skills. Learn about DB2 Express-C. the no-charge version of DB2 Express Edition for the community. Get products and technologies Download a free trial version of DB2 for Linux, UNIX, and Windows . Now you can use DB2 for free. Download DB2 Express-C. a no-charge version of DB2 Express Edition for the community that offers the same core data features as DB2 Express Edtion and provides a solid base to build and deploy applications. Download IBM product evaluation versions and get your hands on application development tools and middleware products from DB2, Lotus174, Rational174, Tivoli174, and WebSphere174. developerWorks: Sign in Required fields are indicated with an asterisk ( ). The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, countryregion, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name . You may update your IBM account at any time. All information submitted is secure. Choose your display name The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks. Please choose a display name between 3-31 characters . Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons. Required fields are indicated with an asterisk ( ). All information submitted is secure. Dig deeper into Information management on developerWorks Exclusive tools to build your next great app. Mehr erfahren. Ask a technical question Tutorials amp training to grow your development skills ArticleTitleLeverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX, and Windows
Gt gt gt gt gt gt gt gt gt gt gt gt gt LAN gt gt gt IPv6 gt gt gtIP gt gt PPPoEIP gt gt gt gt gt gt LAN gt IP100 LAN PCltgtltgtgtPC2 WHR-HP-AMPGWZR-600DHP3 gt gt gt PCIP gt Gt GT gt IP gt gt gt IP gt NTT192.168.1.1 gt NEC192.168.10.1 gt 192.168.11.1 gt gt gt gt gt gt gt gt IP gt gt gt gt gt Wifi gt gt gt gt WifiLAN gt gt gt Gt acer Aspire E11OSWindows8.1 gt ipv6ipv6OKDNSquotquotIP gt 231 cmd IPPC gt gt 231 gt cmd
Comments
Post a Comment