Wednesday 5 July 2017

Sybase Iq Binary Optionen


Binäre Datentypen Beschreibung Zur Speicherung von rohen Binärdaten, wie zB Bilder, in einer hexadezimalen Notation bis zu einer Länge von (32K 1) Bytes. Der Datentyp UNIQUEIDENTIFIER wird für die Speicherung von UUID (auch GUID) verwendet. Die Binärdaten beginnen mit den Zeichen 0x oder 0X und können eine beliebige Ziffernkombination und die Groß - und Kleinbuchstaben A bis F enthalten. Sie können die Spaltenlänge in Bytes angeben oder die Standardlänge von 1 Byte verwenden. Jedes Byte speichert 2 hexadezimale Ziffern. Obwohl die Standardlänge 1 Byte beträgt, empfiehlt Sybase, dass Sie immer eine gerade Anzahl von Zeichen für BINARY und VARBINARY Spaltenlänge angeben. Wenn Sie einen Wert eingeben, der länger als die angegebene Spaltenlänge ist, schneidet Sybase IQ den Eintrag auf die angegebene Länge ohne Warnung oder Fehler ab. BINARY Binärdaten der Länge Länge Bytes. Wenn die Länge weggelassen wird, ist die Voreinstellung 1 Byte. Die maximal zulässige Größe beträgt 255 Byte. Verwenden Sie den BINARY für die feste Länge BINARY für Daten, bei denen alle Einträge annähernd gleich lang sind. Da die Einträge in BINARY-Spalten auf die Spaltenlängenlänge null aufgefüllt sind. Sie benötigen möglicherweise mehr Speicherplatz als Einträge in VARBINARY Spalten. VARBINARY Binärdaten bis zu einer Länge von max-length Bytes. Wenn max-length weggelassen wird, ist die Voreinstellung 1 Byte. Die maximal zulässige Größe beträgt (32K 1) Bytes. Verwenden Sie den Binärtyp VARBINARY mit variabler Länge für Daten, von denen erwartet wird, dass er in der Länge stark variiert. Als separat lizenzierte Option unterstützt Sybase IQ binäre Großobjekt - (BLOB-) Daten mit einer Länge von null (0) bis 512TB (Terabyte) für eine IQ-Seitengröße von 128KB oder 2PB (Petabyte) für eine IQ-Seitengröße von 512KB. Die maximale Länge ist gleich 4GB multipliziert mit der Datenbankseitengröße. Siehe Großes Objektmanagement in Sybase IQ. Informationen zu den Datentypen LONG BINARY und IMAGE finden Sie unter Binärdatentypen. Behandlung von nachlaufenden Nullen Alle BINARY Säulen sind mit Nullen auf die volle Breite der Säule gepolstert. Nachlaufende Nullen werden in allen VARBINARY-Spalten abgeschnitten. Im folgenden Beispiel wird eine Tabelle mit allen vier Variationen von BINARY - und VARBINARY-Datentypen erstellt, die mit NULL und NOT NULL definiert wurden. Die gleichen Daten werden in alle vier Spalten eingefügt und nach dem Datentyp der Spalte gepolstert oder abgeschnitten. Plattformabhängigkeit Die genaue Form, in der Sie einen bestimmten Wert eingeben, hängt von der Plattform ab, die Sie verwenden. Daher können Berechnungen mit binären Daten unterschiedliche Ergebnisse auf verschiedenen Maschinen erzeugen. Für plattformunabhängige Konvertierungen zwischen hexadezimalen Strings und Integern verwenden Sie die Funktionen INTTOHEX und HEXTOINT und nicht die plattformspezifische CONVERT-Funktion. Weitere Informationen finden Sie im Abschnitt Datentypumwandlungsfunktionen. String-Operatoren Die Verknüpfungs-String-Operatoren und beide unterstützen Binär-Typ-Daten. Eine explizite Umwandlung von binären Operanden in Zeichen-Datentypen ist beim Operator nicht erforderlich. Eine explizite und implizite Datenkonvertierung ergibt jedoch unterschiedliche Ergebnisse. Einschränkungen für BINARY - und VARBINARY-Daten Für Spalten, die BINARY - und VARBINARY-Daten enthalten, gelten folgende Einschränkungen: Sie können die Aggregatfunktionen SUM nicht verwenden. AVG STDDEV Oder VARIANCE mit den binären Datentypen. Die aggregierten Funktionen MIN. MAX. Und COUNT unterstützen die Binärdatentypen BINARY und VARBINARY. HNG WD DATE. ZEIT . Und DTTM-Indizes unterstützen keine BINARY - oder VARBINARY-Daten. Nur die Standardindex - und CMP-Indextypen werden für VARBINARY-Daten mit einer Länge von mehr als 255 Bytes unterstützt. Bit-Operationen werden auf BINARY - und VARBINARY-Daten unterstützt, die 8 Bytes oder weniger lang sind. Kompatibilität Die Behandlung von nachlaufenden Nullen in binären Daten unterscheidet sich zwischen Sybase IQ, SQL Anywhere und Adaptive Server Enterprise: Tabelle 3-4: Behandlung von nachlaufenden Nullen Trunkierte, nicht gepolsterte Adaptive Server Enterprise, SQL Anywhere und Sybase IQ unterstützen die STRINGRTRUNCATION-Datenbank Option, die die Fehlermeldung berücksichtigt, wenn eine INSERT - oder UPDATE-Zeichenfolge abgeschnitten wird. Bei Transact-SQL-kompatiblen Zeichenfolgenvergleichen setzen Sie die Option STRINGRTRUNCATION auf denselben Wert in beiden Datenbanken. Sie können die STRINGRTRUNCATION-Option auch beim Laden von Daten in eine Tabelle einstellen, um Sie darauf aufmerksam zu machen, dass die Daten zu groß sind, um in das Feld zu laden. Der Standardwert ist EIN. Bitoperationen auf Binärtypdaten werden von Adaptive Server Enterprise nicht unterstützt. SQL Anywhere unterstützt nur Bitoperationen gegen die ersten vier Bytes von Binärtypdaten. Sybase IQ unterstützt Bitoperationen gegen die ersten acht Bytes von Binärtypdaten. UNIQUEIDENTIFIER Wird für die Speicherung von UUID (auch GUID) verwendet. Der UNIQUEIDENTIFIER-Datentyp wird häufig für einen Primärschlüssel oder eine andere eindeutige Spalte verwendet, um UUID-Werte (Universally Unique Identifier) ​​zu halten, die verwendet werden können, um Zeilen eindeutig zu identifizieren. Die NEWID-Funktion erzeugt UUID-Werte so, dass ein auf einem Rechner erzeugter Wert nicht mit einer UUID übereinstimmt, die auf einem anderen Rechner erzeugt wird. UNIQUEIDENTIFIER-Werte, die mit NEWID generiert wurden, können daher als Schlüssel in einer Synchronisationsumgebung verwendet werden. Beispielsweise aktualisiert die folgende Anweisung die Tabelle mytab und setzt den Wert der Spalte uidcol auf einen eindeutigen Bezeichner, der von der NEWID-Funktion erzeugt wird, wenn der aktuelle Wert der Spalte NULL ist. Wenn Sie die folgende Anweisung ausführen, wird der eindeutige Bezeichner als BINARY (16) zurückgegeben. Beispielsweise könnte der Wert 0xd3749fe09cf446e399913bc6434f1f08 sein. Sie können diese Zeichenfolge mit der Funktion UUIDTOSTR () in ein lesbares Format umwandeln. UUID-Werte werden auch als GUIDs (Globally Unique Identifier) ​​bezeichnet. Mit den Funktionen STRTOUUID und UUIDTOSTR werden Werte zwischen UNIQUEIDENTIFIER und Stringdarstellungen konvertiert. UNIQUEIDENTIFIER-Werte werden gespeichert und als BINARY (16) zurückgegeben. Da die UNIQUEIDENTIFIER-Werte groß sind, ist die Verwendung von UNSIGNED BIGINT - oder UNSIGNED INT-Identitätsspalten anstelle von UNIQUEIDENTIFIER effizienter, wenn Sie keine standardmäßigen Identifikationsdaten für die Datenbank benötigen. Standards und Kompatibilität für UNIQUEIDENTIFIER SQL92 Erweiterung des Herstellers Sybase Unterstützt von SQL Anywhere. Wird von Adaptive Server Enterprise nicht unterstützt. Rückwärtskompatibilität In Datenbanken, die vor der Sybase IQ Version 12.7 erstellt wurden, ist die STRTOUUID. UUIDTOSTR Und NEWID-Funktionen wurden durch CIS-Funktionskompensation unterstützt. In den Versionen 15.1 und später ist die STRTOUUID. UUIDTOSTR Und NEWID-Funktionen sind native Sybase IQ-Funktionen. Weitere Informationen zum UNIQUEIDENTIFIER: Die SAP Sybase IQ Unstructured Data Analytic (UDA) Option erweitert die Möglichkeiten von SAP Sybase IQ, Textanalyse (Data Mining) durchzuführen. Diese Option ermöglicht die Erstellung von Zeichen Large Objects (CLOB) und Binary Large Objects Spalten, die zum Speichern und Bearbeiten von binären Dokumenten (wie MS Excel, MS Wort usw.) und Langtextspalten (gefilterter Inhalt der binären Objekte) verwendet werden. Um Einblicke aus diesen CLOB zu erhalten, müssen wir diese Spalten indizieren und String-Funktionen verwenden, um Informationen abzurufen, zu vergleichen und zu extrahieren. Ein Fall-sensitive Datenbanken können: Komplexität des Abbauprozesses hinzufügen, indem es komplexe Abfrageprädikate erfordert und bei Auslassungen aufgrund möglicher Groß - und Kleinbuchstaben-Kombination (fehlerhaft oder nicht) Platz macht. Es gibt mehrere Möglichkeiten, die genutzt werden können, um die Auswirkungen der Fallempfindlichkeit während des Data Mining zu minimieren, lassen Sie einige von ihnen: Verwenden Sie jede mögliche Kombination von Groß - und Kleinschreibung in den Prädikaten Ihrer Fragen (viele Möglichkeiten, nicht empfohlen). Verwenden Sie die Funktion im Prädikat der Abfragen, um den Inhalt der Spalte in den oberen oder unteren Fall zu konvertieren, bevor Sie einen Vergleichsoperator verwenden. Wählen Sie aus MyUser. Mytable Wo lcase (mycolum) wie lsquoterm8217 Diese Arbeit gut für String-Spalten, die nicht CLOB die LCASE, UCASE, LOWER und UPPER-Funktion sind nicht auf CLOB Datentyp Spalten unterstützt. Konvertieren Sie den vor gefilterten Text in den oberen oder unteren Fall, bevor Sie ihn auf der CLOB-Spalte speichern, verwenden Sie denselben Fall in dem gesamten Prädikat Ihrer Abfragen. Erstellen Sie die Datenbank mit der Option CASE IGNORE Diese Option kann nach dem Erstellen der Datenbank nicht geändert werden. Wenn die SAP-Sybase-IQ-Datenbank primär für den Data Mining verwendet wird und der Fall ignoriert werden kann, empfiehlt es sich, die Datenbank mit CASE IGNORE-Eigenschaft standardmäßig zu erstellen. Alle SAP Sybase IQ-Datenbank wird mit CASE RESPECT erstellt property. LOAD TABLE-Anweisung DATETIME ( MMDDYY hh: mm: ssaa) Sybase IQ verfügt über integrierte Lastoptimierungen für gemeinsame Datums-, Zeit - und datetime-Formate. Wenn Ihre Daten, die geladen werden sollen, mit einem dieser Formate übereinstimmen, können Sie die Ladezeit erheblich verringern, indem Sie das entsprechende Format verwenden. Eine Liste dieser Formate und Details zur Optimierung der Leistung beim Laden von Datums - und Datumsdaten finden Sie in Kapitel 7, Verschieben von Daten in und aus Datenbanken im Sybase IQ Systemverwaltungshandbuch. Sie können auch das Datetime-Feld als ASCII-Feld mit fester Breite (wie oben beschrieben) angeben und mit der Option FILLER (1) das Spaltenbegrenzer überspringen. Weitere Informationen zum Festlegen von Datums - und Zeitdaten finden Sie unter Datums - und Zeitdatentypen oder Kapitel 7, Verschieben von Daten in und aus Datenbanken im Sybase IQ Systemverwaltungshandbuch. Der NULL-Teil der Spalten-Spezifikation gibt an, wie man bestimmte Eingabewerte als NULL-Werte beim Laden in die Tabellenspalte behandelt. Diese Zeichen können BLANKS, ZEROS oder jede andere Liste von Literalen, die Sie definieren, enthalten. Wenn Sie einen NULL-Wert angeben oder einen NULL-Wert aus der Quelldatei lesen, muss die Zielspalte NULLs enthalten. ZEROS werden wie folgt interpretiert: Die Zelle wird auf NULL gesetzt, wenn (und nur wenn) die Eingabedaten (vor der Umwandlung, wenn ASCII) alle binären Nullen (und nicht Zeichen-Nullen) sind. Wenn die Eingabedaten Zeichen Null sind, dann: NULL (ZEROS) verursacht niemals die Zelle NULL. NULL (0) bewirkt, dass die Zelle NULL ist. Wenn die Eingabedaten binär Null sind (alle Bits löschen), dann: NULL (ZEROS) bewirkt, dass die Zelle NULL ist. NULL (0) verursacht niemals die Zelle NULL. Zum Beispiel, wenn Ihre LOAD-Anweisung col1 date (yymmdd) null (Nullen) und das Datum 000000 enthält, erhalten Sie einen Fehler, der angibt, dass 000000 nicht in ein DATE (4) konvertiert werden kann. Um die Last zu laden, um einen NULL-Wert in col1 einzufügen, wenn die Daten 000000 sind, schreibe die NULL-Klausel als null (000000). Oder ändern Sie die Daten auf gleich binäre Nullen und verwenden Sie NULL (ZEROS). Wenn die Länge einer VARCHAR-Zelle Null ist und die Zelle nicht NULL ist, bekommt man eine Zelle mit null Länge. Für alle anderen Datentypen, wenn die Länge der Zelle Null ist, fügt Sybase IQ einen NULL ein. Das ist das ANSI-Verhalten. Für die Nicht-ANSI-Behandlung von Null-Länge-Zeichendaten legen Sie die Option NonAnsiNullVarchar-Datenbank fest. Ein weiterer wichtiger Teil der Last-Spezifikation ist die FILLER-Option. Es bedeutet, dass Sie über ein bestimmtes Feld in der Quell-Eingabedatei überspringen möchten. Zum Beispiel können Zeichen am Ende von Zeilen oder sogar ganze Felder in den Eingabedateien vorhanden sein, die Sie nicht zur Tabelle hinzufügen möchten. Wie bei der Spaltenspezifischen Definition können Sie mit FILLER die feste ASCII-Länge von Bytes, Variablenlängenzeichen, die durch einen Trennzeichen begrenzt sind, und Binärfelder mit PREFIX-Bytes angeben. Dateiname-String Der Dateiname-String wird als String an den Server übergeben. Der String unterliegt daher denselben Formatierungsanforderungen wie andere SQL-Strings. Insbesondere: Um Verzeichnispfade in Windows-Systemen anzugeben, muss das Backslash-Zeichen durch zwei Backslashs dargestellt werden. Daher ist die Anweisung zum Laden von Daten aus der Datei c: tempinput. dat in die Mitarbeiter-Tabelle: Der Pfadname bezieht sich auf den Datenbankserver, nicht auf die Client-Anwendung. Wenn Sie die Anweisung auf einem Datenbankserver auf einem anderen Computer ausführen, beziehen sich die Verzeichnisnamen auf Verzeichnisse auf dem Server, nicht auf dem Clientcomputer. Im Folgenden wird jede der Klauseln der Anweisung beschrieben: WORD SKIP Ermöglicht die Fortsetzung der Last, wenn sie länger als die bei der Erstellung des Wortindex angegebene Grenze auftritt. Wenn eine Zeile nicht geladen wird, weil ein Wort die maximal zulässige Größe überschreitet, wird eine Warnung in die. iqmsg-Datei geschrieben. WORD-Größenverletzungen können optional in der MESSAGE-LOG-Datei protokolliert und die in der LOAD TABLE-Anweisung angegebenen ROW-LOG-Datei abgelehnt werden. Wenn die Option nicht angegeben ist, meldet LOAD TABLE einen Fehler und rollt beim ersten Auftreten eines Wortes zurück, das länger als das angegebene Limit ist. Zahl gibt an, wie oft die Wörter, die die maximal zulässige Wortlänge überschreiten, nicht unterstützt Fehler ignoriert wird. 0 (Null) bedeutet, dass es keine Begrenzung gibt. QUOTEN Dieser Parameter ist optional und die Voreinstellung ist EIN. Wenn QUOTES eingeschaltet ist, erwartet LOAD TABLE, dass Input-Strings in Anführungszeichen eingeschlossen werden. Das Zitatzeichen ist entweder ein Apostroph (einfaches Zitat) oder ein Anführungszeichen (doppeltes Zitat). Der erste Charakter, der in einem String angetroffen wird, wird als Anführungszeichen für den String behandelt. String-Daten müssen mit einem passenden Angebot beendet werden. Mit QUOTEN AN. Spalten - oder Zeilenbegrenzerzeichen können in den Spaltenwert aufgenommen werden. Führende und beendende Anführungszeichen werden davon ausgegangen, dass sie nicht Teil des Wertes sind und vom geladenen Datenwert ausgeschlossen sind. Um ein Zitatzeichen in einen Wert mit QUOTES ON einzufügen. Benutze zwei Zitate. Beispielsweise enthält die folgende Zeile einen Wert in der dritten Spalte, der ein einziges Anführungszeichen ist: Bei eingeschaltetem STRIP (Standardeinstellung) werden nachfolgende Leerzeichen von Werten abgezogen, bevor sie eingefügt werden. Schleppende Leerzeichen werden nur für nicht zitierte Zeichenfolgen abgezogen. Zitierte Strings behalten ihre nachlaufenden Leerzeichen bei. Führende Leerzeichen oder TAB-Zeichen werden nur dann beschnitten, wenn die QUOTES-Einstellung eingeschaltet ist. Die Datenextraktionsanlage bietet Optionen zur Handhabung von Anführungszeichen (TEMPEXTRACTQUOTES, TEMPEXTRACTQUOTESALL und TEMPEXTRACTQUOTE). Wenn Sie planen, die extrahierte Datei mit Zeichenfolgenfeldern, die Spalten - oder Zeilenbegrenzer enthalten, unter Standard-ASCII-Extraktion zurückzuladen, verwenden Sie die Option TEMPEXTRACTBINARY für die Auszugs - und FORMAT-Binär - und QUOTEN-AUS-Optionen für LOAD TABLE. Die Option QUOTES ON gilt nur für spaltenbegrenzte ASCII-Felder. Mit QUOTEN AN. Das erste Zeichen eines Spaltenbegrenzers oder Reihenabschlusses kann kein einzelnes oder doppeltes Anführungszeichen sein. Die QUOTES-Option gilt nicht für das Laden von Binär-Großobjekt - (BLOB-) oder Zeichen-Großobjekt - (CLOB-) Daten aus der Sekundärdatei, unabhängig von ihrer Einstellung. Ein führendes oder nachlaufendes Angebot wird als Teil der CLOB-Daten geladen. Zwei aufeinander folgende Anführungszeichen zwischen umschließenden Anführungszeichen werden als zwei aufeinanderfolgende Anführungszeichen mit der Option QUOTES ON geladen. Adaptive Server Enterprise BCP unterstützt die Option QUOTES nicht. Alle Felddaten werden gleich oder gleich der QUOTES OFF-Einstellung kopiert. Da QUOTES ON die Standardeinstellung für die Sybase IQ LOAD TABLE-Anweisung ist, müssen Sie QUOTES OFF beim Import von ASE-Daten aus BCP-Ausgabe in eine Sybase IQ-Tabelle angeben. Wenn LOAD TABLE nach dem Ende des Anführungszeichens für ein eingeschlossenes Feld auf beliebige nicht weiße Zeichen trifft, wird der folgende Fehler gemeldet und der Ladevorgang wird zurückgesetzt: Nicht-SPACE-Text, der nach dem Ende des Anführungszeichens für ein eingeschlossenes Feld gefunden wurde. SQLSTATE: QTA14 SQLCODE: -1005014L Mit QUOTES ON. Wenn ein einzelnes oder doppeltes Anführungszeichen als erstes Zeichen des Spaltenbegrenzers angegeben ist, wird ein Fehler gemeldet und der Ladevorgang fehlschlägt: Einzelne oder doppelte Anführungszeichen können nicht das 1. Zeichen des Spaltenbegrenzers oder Zeilenabschlusses mit QUOTES-Option EIN sein. SQLSTATE: QCA90 SQLCODE: -1013090L CHECK CONSTRAINTS Diese Option ist standardmäßig auf ON gesetzt. Wenn Sie CHECK CONSTRAINTS ON angeben. Check-Constraints werden ausgewertet und du kannst sie frei ignorieren oder protokollieren. Einstellung CHECK CONSTRAINTS OFF bewirkt, dass Sybase IQ alle Check-Constraint-Verletzungen ignoriert. Dies kann z. B. beim Datenbankumbau nützlich sein. Wenn eine Tabelle Check-Constraints hat, die benutzerdefinierte Funktionen aufrufen, die noch nicht erstellt wurden, schlägt die Neuerstellung fehl, solange diese Option nicht auf OFF gesetzt ist. Diese Option schließt sich gegenseitig aus. Wenn eine dieser Optionen in derselben Last angegeben ist, ergibt sich ein Fehler: IGNORE CONSTRAINT ALL IGNORE CONSTRAINT CHECK DEFAULTS Wenn die Option DEFAULTS aktiviert ist (die Voreinstellung) und die Spalte einen Standardwert hat, wird dieser Wert verwendet. Wenn die Option DEFAULTS ausgeschaltet ist, wird jede Spalte, die nicht in der Spaltenliste vorhanden ist, NULL zugewiesen. Die Einstellung für die Option DEFAULTS gilt für alle Spalten-DEFAULT-Werte, einschließlich AUTOINCREMENT. Detaillierte Informationen zur Verwendung von Spalten-DEFAULT-Werten mit Lasten und Einsätzen finden Sie unter Verwenden von Spaltenvorgaben in Kapitel 9, Sicherstellen der Datenintegrität im Sybase IQ Systemverwaltungshandbuch. ESCAPES Wenn Sie eine Spaltenspezifische Definition für ein Eingabefeld auslassen und ESCAPES eingeschaltet ist (die Voreinstellung), werden Zeichen, die dem Backslash-Zeichen folgen, als Sonderzeichen vom Datenbankserver erkannt und interpretiert. Newline-Zeichen können als Kombination n aufgenommen werden, andere Zeichen können in Daten als hexadezimale ASCII-Codes, wie z. B. x09 für das Tab-Zeichen, aufgenommen werden. Eine Sequenz von zwei Backslash-Zeichen () wird als einziger Backslash interpretiert. Für Sybase IQ müssen Sie diese Option ausschalten. FORMAT Sybase IQ unterstützt ASCII - und Binäreingabefelder. Das Format wird in der Regel durch die oben beschriebene Spaltenspezifikation definiert. Wenn Sie diese Definition für eine Spalte weglassen, verwendet Sybase IQ standardmäßig das von dieser Option definierte Format. Input-Zeilen werden angenommen, dass ascii (die Standard-) oder Binärfelder, eine Zeile pro Zeile, mit Werten, die durch das Spaltenbegrenzungszeichen getrennt sind. DELIMITED BY Wenn Sie in der Spaltenspezifischen Definition ein Spaltentrennzeichen weglassen, ist das Standard-Spaltentrennzeichen ein Komma. Sie können einen alternativen Spaltenbegrenzer angeben, indem Sie ein einzelnes ASCII-Zeichen oder die hexadezimale Zeichendarstellung bereitstellen. Die DELIMITED BY-Klausel lautet wie folgt: Um das Newline-Zeichen als Trennzeichen zu verwenden, können Sie entweder die Sonderkombination n oder ihren ASCII-Wert x0a angeben. Obwohl Sie bis zu vier Zeichen in der Spalte-spec delimiter-string angeben können. Sie können in der DELIMITED BY-Klausel nur ein einzelnes Zeichen angeben. STRIP Bei eingeschaltetem STRIP (Standardeinstellung) werden nachfolgende Leerzeichen von Werten abgezogen, bevor sie eingefügt werden. Dies gilt nur für VARCHAR-Daten, die nicht für ASCII-Fixbreiten-Einsätze gilt. Um die STRIP-Option auszuschalten, ist die Klausel wie folgt: Schleppende Leerzeichen werden nur für nicht zitierte Zeichenfolgen abgezogen. Zitierte Strings behalten ihre nachlaufenden Leerzeichen bei. Alternativ können Sie mit der Option FILLER die Anzahl der Bytes, die anstelle aller nachlaufenden Leerzeichen streifen, spezifischer sein. Es ist effizienter für Sybase IQ, diese Option auszuschalten, und es haftet beim ANSI-Standard beim Umgang mit nachlaufenden Leerzeichen. (Char-Daten werden immer gepolstert, so dass diese Option nur die Varchar-Daten beeinflusst.) MIT CHECKPOINT Die Standardeinstellung ist OFF. Wenn auf ON gesetzt, wird nach dem erfolgreichen Abschluss und der Protokollierung der Anweisung ein Checkpoint ausgegeben. Wenn WITH CHECKPOINT ON nicht angegeben ist und anschließend eine Wiederherstellung erforderlich ist, wird die zum Laden der Tabelle verwendete Datendatei benötigt, damit die Wiederherstellung erfolgreich abgeschlossen wird. Wenn WITH CHECKPOINT ON angegeben ist und die Wiederherstellung nachträglich erforderlich ist, beginnt sie nach dem Checkpoint und die Datendatei muss nicht vorhanden sein. BLOCK FACTOR Gibt den Sperrfaktor oder die Anzahl der Datensätze pro Block an, der bei der Erstellung eines Bandes verwendet wird. Diese Option gilt nicht für Einfügungen aus Eingabefeldern mit variabler Länge. Verwenden Sie stattdessen die Option BLOCKSIZE. Allerdings wirkt sich dies auf alle Dateieinsätze (einschließlich von Festplatte) mit festen Längen-Eingabefeldern aus und kann die Leistung drastisch beeinflussen. Sie können diese Option nicht zusammen mit der Option BLOCK SIZE angeben. Der Standardwert ist 10.000. BLOCK SIZE Gibt die Standardgröße in Bytes an, in denen die Eingabe gelesen werden soll. Diese Option wirkt sich nur auf die eingegebenen Daten der variablen Länge aus, die nicht für feste Längeneingabefelder gültig ist. Es ist ähnlich wie BLOCK FACTOR. Aber es gibt keine Beschränkungen für die Beziehung der Rekordgröße zu Blockgröße. Sie können diese Option nicht zusammen mit der Option BLOCK FACTOR angeben. Die Voreinstellung ist 500.000. BYTE ORDER Gibt die Byte-Reihenfolge während der Lesevorgänge an. Diese Option gilt für alle binären Eingabefelder. Wenn keine definiert ist, wird diese Option ignoriert. Sybase IQ liest immer Binärdaten im Format nativ auf die Maschine, auf der es läuft (Standard ist NATIVE). Sie können auch angeben: HIGH, wenn Multibyte-Mengen das High-Order-Byte zuerst haben (für Big-Endian-Plattformen wie Sun, IBM AIX und HP). LOW, wenn Multibyte-Mengen das niedrige Order-Byte zuerst haben (für kleine Endian-Plattformen wie Windows). LIMIT Gibt die maximale Anzahl von Zeilen an, die in die Tabelle eingefügt werden sollen. Die Voreinstellung ist 0 für kein Limit. Das Maximum ist 2GB - 1. NOTIFY Gibt an, dass Sie jedes Mal mit einer Nachricht benachrichtigt werden, wenn die angegebene Anzahl von Zeilen erfolgreich in die Tabelle eingefügt wurde. Die Voreinstellung ist jede 100.000 Zeilen. Der Wert dieser Option überschreibt den Wert der NOTIFYMODULUS-Datenbankoption. ON FILE ERROR Gibt die Aktion an, die Sybase IQ annimmt, wenn eine Eingabedatei nicht geöffnet werden kann, da sie nicht existiert oder Sie falsche Berechtigungen zum Lesen der Datei haben. Sie können eine der folgenden Optionen angeben: ROLLBACK bricht die gesamte Transaktion ab (die Voreinstellung). FINISH beendet die bereits abgeschlossenen Einfügungen und beendet den Ladevorgang. CONTINUE gibt einen Fehler zurück, überspringt aber nur die Datei, um den Ladevorgang fortzusetzen. Sie können diese Option nicht mit Teilbreiteneinsätzen verwenden. Es ist nur eine ON FILE ERROR-Klausel zulässig. PREVIEW Zeigt das Layout der Eingabe in die Zieltabelle einschließlich Startposition, Name und Datentyp jeder Spalte an. Sybase IQ zeigt diese Informationen zu Beginn des Ladevorgangs an. Wenn Sie in eine Protokolldatei schreiben, sind diese Informationen auch im Protokoll enthalten. Diese Option ist besonders bei Teilbreiteneinsätzen sinnvoll. ROW DELIMITED BY Gibt einen String mit einer Länge von bis zu 4 Bytes an, der das Ende eines Eingabesatzes anzeigt. Sie können diese Option nur verwenden, wenn alle Felder innerhalb der Zeile eine der folgenden sind: Abgegrenzt mit Spaltenabschlüssen Daten, die durch die DATE - oder DATETIME-Spalten-Spezifizierungsoptionen definiert sind ASCII-feste Längenfelder Sie können diese Option nicht verwenden, wenn alle Eingabefelder binäre Daten enthalten. Mit dieser Option bewirkt ein Zeilenende, dass fehlende Felder auf NULL gesetzt werden. Alle Zeilen müssen die gleichen Zeilenbegrenzer haben, und sie müssen sich von allen Spaltenbegrenzern unterscheiden. Die Zeilen - und Feldbegrenzungszeichenfolgen können keine Anfangssatzung voneinander sein. Zum Beispiel können Sie nicht als Feldbegrenzer und als Zeilenbegrenzer angeben, aber Sie können als Feldbegrenzer mit diesem Zeilenbegrenzer angeben. Wenn eine Zeile ihre Trennzeichen fehlt, gibt Sybase IQ einen Fehler zurück und rollt die gesamte Lasttransaktion zurück. Die einzige Ausnahme ist die endgültige Aufzeichnung einer Datei, in der sie diese Zeile zurücksetzt und eine Warnmeldung zurückgibt. Unter Windows wird ein Zeilenbegrenzer in der Regel durch das Zeilenumbruchzeichen gefolgt von dem Wagenrücklaufzeichen angezeigt. Möglicherweise müssen Sie dies als Trennzeichen-String (siehe oben für Beschreibung) für diese Option oder FILLER angeben. SKIP Hier können Sie eine Anzahl von Zeilen definieren, die zu Beginn der Eingabetabellen für diese Last übersprungen werden sollen. Die Voreinstellung ist 0. START ROW ID Gibt die Datensatz-Identifikationsnummer einer Zeile in der Sybase IQ-Tabelle an, wo sie mit dem Einfügen beginnen soll. Diese Option wird für Teilbreiteneinsätze verwendet, die Einsätze in eine Teilmenge der Spalten in der Tabelle sind. Standardmäßig werden neue Zeilen eingefügt, wo Platz in der Tabelle vorhanden ist, und jeder Eintrag startet eine neue Zeile. Partial-Breite-Einsätze müssen in einer vorhandenen Zeile beginnen. Sie müssen auch Daten aus der Quelldatei in die Zieltabelle punktuell nach Spalte einfügen, also müssen Sie die Zielspalten in der gleichen Reihenfolge wie ihre entsprechenden Quellspalten angeben. Definieren Sie das Format jeder Eingabespalte mit einer Spaltenspezifikation. Die Standardeinstellung ist 0. Weitere Informationen zu Einsätzen der Teilbreite finden Sie in Kapitel 7, Verschieben von Daten in und aus Datenbanken im Sybase IQ Systemverwaltungshandbuch. Verwenden Sie die Option START ROW ID nur für Teilbreiteneinsätze. Wenn die zu ladenden Spalten bereits Daten enthalten, schlägt die Einfügung fehl. UNLOAD FORMAT Gibt an, dass die Datei Sybase IQ interne Entladeformate für jede Spalte hat, die von einer früheren Version von Sybase IQ (vor Version 12.0) erstellt wurde. Diese Lastoption hat folgende Einschränkungen: Sie können keine Spaltenspezifikation (wie ASCII oder PREFIX) für eine andere Spalte als BINARY angeben. Dazu gehören die NULL-Spezifikationen. Wenn Sie mit der BINARY-Spaltenspezifikation Nullwerte für eine Spalte laden müssen. Sie müssen das Schlüsselwort WITH NULL BYTE angeben oder Sybase IQ gibt einen Fehler zurück. Sie können die DELIMITED BY oder ROW DELIMITED BY nicht mit UNLOAD FORMAT verwenden. ON PARTIAL INPUT ROW Gibt die zu ergreifende Aktion an, wenn während einer Last eine partielle Eingangszeile angetroffen wird. Sie können eine der folgenden Optionen angeben: WEITER gibt eine Warnung aus und setzt den Ladevorgang fort. Dies ist die Voreinstellung. ROLLBACK bricht den gesamten Ladevorgang ab und meldet den Fehler. Teileingabeaufzeichnung bei EOF übersprungen. SQLSTATE: QDC32 SQLSTATE: -1000232L IGNORE CONSTRAINT Gibt an, ob die CHECK-, UNIQUE-, NULL-, DATA-VALUE - und FOREIGN-KEY-Integritätseinschränkungsverletzungen, die während einer Last auftreten, und die maximale Anzahl von Verstößen ignoriert werden, bevor ein Rollback eingeleitet wird. Die Angabe jedes Constrainttyps hat folgendes Ergebnis: CHECK-Limit Wenn Limit Null angibt, ist die Anzahl der UNIQUE Constraint-Verstöße, die ignoriert werden sollen, unendlich. Wenn CHECK nicht angegeben ist, führt das erste Auftreten einer CHECK-Einschränkungsverletzung dazu, dass die LOAD-Anweisung zurück rollt. Wenn die Grenze ungleich Null ist, führt das Limit 1-Auftreten einer CHECK-Einschränkungsverletzung dazu, dass die Last zurück rollt. EINZIGARTIGE Grenze Wenn Limit Null angibt, dann ist die Anzahl der UNIQUE Constraint-Verletzungen zu ignorieren unendlich. Wenn das Limit ungleich Null ist, führt das Limit 1-Auftreten einer UNIQUE Constraint-Verletzung dazu, dass die Last zurück rollt. NULL-Grenzwert Wenn Limit Null angibt, ist die Anzahl der zu ignorierenden NULL-Einschränkungsverletzungen unendlich. Wenn das Limit ungleich Null ist, führt das Limit 1-Auftreten einer NULL-Einschränkungsverletzung dazu, dass die Last zurück rollt. FOREIGN KEY-Limit Wenn Limit Null angibt, ist die Anzahl von FOREIGN KEY-Constraint-Verletzungen zu ignorieren unendlich. Wenn die Grenze null ist, führt das Limit 1-Auftreten einer FOREIGN KEY-Einschränkungsverletzung dazu, dass die Last zurück rollt. DATA VALUE-Limit Wenn die Datenbank-Option CONVERSIONERROR ON ist, wird ein Fehler gemeldet und die Anweisung rollt zurück. Wenn Limit Null angibt, dann ist die Anzahl der DATA VALUE-Constraint-Verletzungen (Datentyp-Umwandlungsfehler) zu ignorieren unendlich. Wenn die Grenze ungleich Null ist, führt das Limit 1-Auftreten einer DATA VALUE-Einschränkungsverletzung dazu, dass die Last zurück rollt. ALL-Limit Wenn die Datenbank-Option CONVERSIONERROR ON. Ein Fehler wird gemeldet und die Anweisung rollt zurück. Wenn Limit Null angibt, dann ist die kumulative Summe aller Integritätsbeschränkungsverletzungen, die ignoriert werden, unendlich. Wenn die Grenze ungleich Null ist, rollt die Ladung zurück, wenn die kumulative Summe aller ignorierten UniVUE-, NULL-, DATA VALUE - und FOREIGN-KEY-Integritäts-Constraint-Verletzungen den Grenzwert überschreitet. Beispielsweise geben Sie die folgende IGNORE CONSTRAINT-Option an: Die Gesamtzahl der Integritätseinschränkungsverletzungen darf 200 nicht überschreiten, während die Gesamtzahl der NULL - und UNIQUE-Constraint-Verletzungen 50 bzw. 100 nicht überschreiten darf. Wenn eine dieser Grenzwerte überschritten wird, rollt die LOAD TABLE-Anweisung zurück. Eine einzelne Zeile kann mehr als eine Integritätsbeschränkungsverletzung haben. Jedes Vorkommen einer Integritätsbeschränkungsverletzung zählt zu der Grenze dieser Art von Verletzung. Sybase empfiehlt dringend, das IGNORE CONSTRAINT-Optionslimit auf einen Wert ungleich Null zu setzen, wenn Sie die ignorierten Integritätseinschränkungsverletzungen protokollieren. Die Protokollierung einer übermäßigen Anzahl von Verstößen wirkt sich auf die Leistung der Last aus. Wenn CHECK, UNIQUE, NULL oder FOREIGN KEY in der IGNORE CONSTRAINT-Klausel nicht angegeben ist, rollt die Last beim ersten Auftreten jeder dieser Arten von Integritätsbeschränkungsverletzungen zurück. Wenn DATA VALUE in der IGNORE CONSTRAINT-Klausel nicht angegeben ist, rollt die Last beim ersten Auftreten dieser Art von Integritätseinschränkungsverletzung zurück, es sei denn, die Datenbankoption CONVERSIONERROR OFF. Wenn CONVERSIONERROR AUS ist. Eine Warnung wird für jede DATA VALUE-Einschränkungsverletzung gemeldet und die Last wird fortgesetzt. Wenn die Last abgeschlossen ist, wird eine Informationsnachricht bezüglich Integritätsbeschränkungsverletzungen in der. qq-Datei protokolliert. Diese Nachricht enthält die Anzahl der Integritätsbeschränkungsverletzungen, die während der Ladung aufgetreten sind, und die Anzahl der übersprungenen Zeilen. MESSAGE LOG Gibt die Namen von Dateien an, in denen Informationen über Integritätsbeschränkungen und die Arten von Verletzungen protokolliert werden sollen. Zeitstempel, die den Start und die Beendigung der Last angeben, werden sowohl im MESSAGE LOG als auch in den ROW LOG Dateien protokolliert. Es müssen sowohl MESSAGE LOG als auch ROW LOG angegeben werden oder es werden keine Informationen über Integritätsverletzungen protokolliert. Wenn die NUR LOG-Klausel nicht angegeben ist, werden keine Informationen über Integritätsbeschränkungsverletzungen protokolliert. Nur die Zeitstempel, die den Start und die Beendigung der Last angeben, werden protokolliert. Informationen werden bei allen in der ONLY-LOG-Klausel festgelegten Integritäts-Constraint-Typ-Verletzungen oder bei allen Wortindex-Längen-Verstößen protokolliert, wenn das Schlüsselwort WORD angegeben ist. Wenn Constraint-Verstöße protokolliert werden, erzeugt jedes Vorkommen einer Integritäts-Constraint-Verletzung genau eine Zeile von Informationen in der MESSAGE LOG-Datei. Die Anzahl der Zeilen (Fehler gemeldet) in der MESSAGE LOG-Datei kann die Optionsgrenze von IGNORE CONSTRAINT überschreiten, da die Last von mehreren parallel laufenden Threads ausgeführt wird. Mehr als ein Thread könnte berichten, dass die Anzahl der Constraint-Verstöße das angegebene Limit überschritten hat. Wenn Constraint-Verstöße protokolliert werden, wird genau eine Zeile von Informationen in der ROW-LOG-Datei für eine gegebene Zeile protokolliert, unabhängig von der Anzahl der Integritäts-Constraint-Verletzungen, die in dieser Zeile auftreten. Die Anzahl der verschiedenen Fehler in der MESSAGE LOG-Datei stimmt möglicherweise nicht genau mit der Anzahl der Zeilen in der ROW LOG-Datei überein. Der Unterschied in der Anzahl der Zeilen ist auf die Parallelverarbeitung der oben beschriebenen Last für das MESSAGE LOG zurückzuführen. Die MESSAGE LOG - und ROW-LOG-Dateien können keine rohen Partitionen sein. Wenn die MESSAGE LOG oder ROW LOG Datei bereits vorhanden ist, werden neue Informationen an die Datei angehängt. Die Angabe eines ungültigen Dateinamens für die MESSAGE LOG - oder ROW LOG-Datei erzeugt einen Fehler. Die Angabe des gleichen Dateinamens für die MESSAGE LOG und ROW LOG Dateien erzeugt einen Fehler. Verschiedene Kombinationen der Optionen IGNORE CONSTRAINT und MESSAGE LOG führen zu unterschiedlichen Protokollierungsaktionen, wie in Tabelle 6-11 angegeben. Tabelle 6-11: LOAD TABLE Logging Aktionen IGNORE CONSTRAINT angegeben Nichts wird protokolliert. Die erste Integritätsbeschränkungsverletzung verursacht einen Rollback. Sybase empfiehlt dringend, das IGNORE CONSTRAINT-Optionslimit auf einen Wert ungleich Null zu setzen, wenn Sie die ignorierten Integritätseinschränkungsverletzungen protokollieren. Wenn eine einzelne Zeile mehr als eine Integritätsbeschränkungsverletzung hat, wird eine Zeile für jede Verletzung in die MESSAGE LOG-Datei geschrieben. Die Protokollierung einer übermäßigen Anzahl von Verstößen wirkt sich auf die Leistung der Last aus. LOG DELIMITED BY Gibt den Trennzeichen zwischen Datenwerten in der ROW LOG-Datei an. Der Standard-Trennzeichen ist ein Komma. Side effects SQL92 Vendor extension. Sybase Not applicable. Permissions The permissions required to execute a LOAD TABLE statement depend on the database server - gl command line option, as follows: If the - gl option is set to ALL, you must be the owner of the table, have DBA authority, or have ALTER permission. If the - gl option is set to DBA, you must have DBA authority. If the - gl option is set to NONE, LOAD TABLE is not permitted. LOAD TABLE also requires an exclusive lock on the table. Chapter 7: Moving Data In and Out of Databases Bulk loading data using the LOAD TABLE statement The LOAD TABLE statement is used for efficient importing of data from a text or binary file into an existing database table. It loads data into any column indexes you have defined, as well as any created automatically. The permissions needed to execute a LOAD TABLE statement are set on the server command line, using the - gl option. Sybase recommends the - gl all setting, which allows any user to load or unload a table. This is the default setting set by startasiq . If the - gl option is set to ALL, you must be the owner of the table, have DBA authority, or have ALTER permission, in order to use the LOAD TABLE statement. You also need INSERT permission on the table. See the description of the ON FILE ERROR load option for what happens when input file errors occur during a load. Using command files to load data To load large amounts of data, most users create command files. To create a command file, follow the instructions in the chapter entitled Getting Started with DBISQL in the Introduction to Sybase IQ . Transaction processing and LOAD TABLE When you issue the LOAD TABLE statement for an IQ table, a savepoint occurs automatically before the data is loaded. If the load completes successfully, Sybase IQ releases the savepoint. If the load fails, the transaction rolls back to the savepoint. This approach gives you flexibility in committing transactions. For example, if you issue two LOAD TABLE commands, you can ensure that either both commit or neither. When you issue LOAD TABLE for a Catalog Store table, there is no automatic savepoint. If the load succeeds, it commits automatically. If the load fails, it rolls back. You cannot roll back a successful load of a Catalog Store table. Integrity constraints and LOAD TABLE LOAD TABLE allows you to control load behavior when integrity constraints are violated and to selectively log information about the violations. You can specify whether to ignore UNIQUE, NULL, DATA VALUE, andor FOREIGN KEY constraint violations that occur during a load and the maximum number of violations to ignore before initiating a rollback. You can also direct the load to log information about specific types of integrity constraint violations both per violation in a message log and per row in a row log. For information on the contents and format of the message and row logs, see Logging integrity constraint violations . Summary of LOAD TABLE syntax The basic form of the LOAD TABLE statement is: For usage and syntax details of all of the LOAD TABLE parameters, see LOAD TABLE statement in Chapter 6, SQL Statements of the Sybase IQ Reference Manual . Load specification The load-specification does the following: Lists each column to be loaded and describes the data in it. A column can contain fixed-length data, variable-length characters delimited by a separator, or data that uses a binary prefix to represent the number of bytes being read. Specifies FILLER format for any fields you want to skip. The syntax for load-specification is as follows: For each column, you can specify a column-spec . If you omit this option, the format information in the load-options applies to this column. The column-spec and load-options format information tell Sybase IQ what type of data to expect, and how to convert it into a compatible data format if necessary. Syntax for the column-spec is: You can specify the following types of data in the column-spec : Data with bytes of fixed length. Although specified by the keyword ASCII, any 8-bit characters may be used, and for 16-bit character sets, two 8-bit characters are used for each 16-bit character. No code conversion is performed for char and varchar fields except truncation, blank stripping, or blank padding. ASCII is also used to fill numeric data, time, and datetime fields. In each case, the conversion is the same if the value were first inserted as a character field, then cast to the data type of the column in the table. The input-width value is an integer value indicating the fixed width in bytes of the input field in every record. Binary fields that use a number of PREFIX bytes (1, 2, or 4) to specify the length of the binary input. The BINARY keyword indicates that data is already converted to the internal form (except for when the byte-order load option is specified. Note that if the data is unloaded using the extraction facility with the TEMPEXTRACTBINARY option set ON, then you must use the BINARY WITH NULL BYTE parameter for each column when you load the binary data. Variable-length characters delimited by a separator. You specify the delimiter-string as a string of one to four ASCII characters, or any 8bit hexadecimal ASCII code that represents a single, non-printing character. The delimiter-string must be enclosed in single quotes. For example, you specify: x09 to represent a tab as the terminator. x00 for a null terminator (no visible terminator as in C strings). x0a for a newline character as the terminator. You can also use the special character combination of n for newline. DATE or DATETIME string as ASCII characters. You must define the input-date-format or input-datetime-format of the string using one of the corresponding formats for the date and datetime data types supported by Sybase IQ. Use DATE for date values and DATETIME for datetime and time values. For information about these data types, see the Sybase IQ Reference Manual . The column-spec is for IQ tables only. If you specify a column-spec for a Catalog Store table, you get an error. The NULL portion of the column-spec indicates how to treat certain input values as NULL values when loading into the table column. These characters can include BLANKS, ZEROS, or any other list of literals you define. When you specify a NULL value or read a NULL value from the source file, the destination column must be able to contain NULLs. ZEROS are interpreted as follows: the cell is set to NULL if (and only if) the input data (before conversion, if ASCII) is all binary zeros (and not character zeros). If the input data is character zero, then: a) NULL(ZEROS) never causes the cell to be NULL b) NULL(0) causes the cell to be NULL If the input data is binary zero (all bits clear), then: a) NULL(ZEROS) causes the cell to be NULL b) NULL(0) never causes the cell to be NULL For example, if your LOAD statement includes col1 date(yymmdd) null(zeros) and the date is 000000, you will receive an error indicating that 000000 cannot be converted to a DATE(4). To get the load statement to insert a NULL value in col1 when the data is 000000, you must write the NULL clause as null(000000). or modify the data to equal binary zeros and use NULL(ZEROS). The FILLER clause indicates you want to skip over a specified field in the source input file. For example, there may be characters at the end of rows or even entire fields in the input files that you do not want to add to the table. As with the column-spec definition, FILLER allows you to specify ASCII fixed length of bytes, variable length characters delimited by a separator, and binary fields using PREFIX bytes. The maximum length of a variable-length FILLER column is 512 bytes. FILLER clause syntax is as follows: For more information on how to use data conversion options, see Converting data on insertion . Specifying files to load You specify one or more files from which to load data. In the FROM clause, you specify each filename-string . and separate multiple strings by commas. The files are read one at a time, and processed in a left-to-right order as specified in the FROM clause. Any SKIP or LIMIT value only applies in the beginning of the load, not for each file. If a load cannot complete, for example due to insufficient memory, the entire load transaction is rolled back. filename-string The filename-string is passed to the server as a string. The string is therefore subject to the same formatting requirements as other SQL strings. In particular: If a backslash () precedes the characters n. X or it is considered an escape character. For this reason, to indicate directory paths in Windows systems, you must represent the backslash character by two backslashes if the next character is any of those listed. (It is always safe to double the backslashes.) Therefore, the statement to load data from the file c:newinput. dat into the employee table is: The pathname is relative to the database server, not to the client application. If you are running the statement on a database server on some other computer, the directory name refers to directories on the server machine, not on the client machine. The input file for the load must be on the server machine. Named pipes The file specification can be a named pipe. When you load from a named pipe (or FIFO) on Windows, the program writing to the pipe must close the pipe in a special way. The pipe writer must call FlushFileBuffers( ) and then DisconnectNamedPipe( ). (If you do not, Sybase IQ reports an exception from hosio::Read( ).) This issues a PIPENOTCONNECTED error, which notifies Sybase IQ that the pipe was shut down in an orderly manner rather than an uncontrolled disconnect. See Microsoft documentation for details on these calls. Specifying table-wide format options You can specify several options that describe the format of input data. FORMAT option You can specify a default format for table columns, which applies if you omit the column-spec . The same formats that can appear in the column-spec can appear here. If you also omit the FORMAT load option, the file is assumed to be binary. DELIMITED BY option If you omit a column delimiter in the column-spec definition, the default column delimiter character is a comma. You can specify an alternative column delimiter by providing a single ASCII character or the hexadecimal representation. In particular, to specify tab-delimited values use the hexadecimal ASCII code of the tab character (9), as follows: To use the newline character as a delimiter, you can specify either the special combination n or its ASCII value x0a. Although the delimiter-string in the column-spec may be a string of up to four characters, the DELIMITED BY option allows only a single ASCII character or its hexadecimal representation. STRIP option With STRIP turned on (the default), trailing blanks are stripped from values before they are inserted. This is effective only for VARCHAR data. To turn the STRIP option off, enter the clause as follows: Trailing blanks are stripped only for non-quoted strings. Quoted strings retain their trailing blanks. If you dont require blank sensitivity, you may use the FILLER option allows you to be more specific in the number of bytes to strip instead of just all the trailing spaces. This option does not apply to ASCII fixed-width inserts. For example, the STRIP option in the following statement is ignored: QUOTES option The QUOTES parameter is optional and the default is ON . With QUOTES turned on, LOAD TABLE expects input strings to be enclosed in quote characters. The quote character is either an apostrophe (single quote) or a quotation mark (double quote). The first such character encountered in a string is treated as the quote character for the string. String data must be terminated with a matching quote. With QUOTES ON . column or row delimiter characters can be included in the column value. Leading and ending quote characters are assumed not to be part of the value and are excluded from the loaded data value. With QUOTES OFF . Sybase IQ does not strip off apostrophes (single quotes) or quotation marks (double quotes). When it encounters these characters in your input file, it treats them as part of the data. With QUOTES OFF . you cannot include column delimiter characters in column values. QUOTES option example Consider a table defined as: with the following input data: The result of loading this data is displayed by running the following query: The following output displays the result of the query enclosed by lt and gt and the values of the LOAD TABLE options QUOTES and STRIP : Notes on the results: With QUOTES ON and STRIP ON . both leading space and trailing space for the non-enclosed field c2 row 1 are trimmed. With QUOTES ON and STRIP OFF . only the leading space for the non-enclosed field c2 row 1 is trimmed. With QUOTES OFF and STRIP ON . only the trailing space for the non-enclosed field c2 row 1 is trimmed. With QUOTES OFF and STRIP OFF . neither leading space nor trailing space for the non-enclosed field c2 row 1 is trimmed. With QUOTES ON and STRIP ON . both leading space and trailing space within quotes for the enclosed fields c2 and c3 row 3 are NOT trimmed. ESCAPES option Currently, you must specify ESCAPES OFF . The default of ESCAPES ON is provided for compatibility with Adaptive Server Anywhere this option may be supported in a future version. With ESCAPES turned on, if you omit a column-spec definition for an input field, characters following the backslash character are recognized and interpreted as special characters by the database server. Newline characters can be included as the combination n, and other characters can be included in data as hexadecimal ASCII codes, such as x09 for the tab character. A sequence of two backslash characters ( ) is interpreted as a single backslash. WORD SKIP option Allows the load to continue when it encounters data longer than the limit specified when the word index was created. For details, see LOAD TABLE statement, Chapter 6, SQL Statements, in the Sybase IQ Reference Manual. The following UNIX example specifies a BLOCK FACTOR of 50,000 records along with the PREVIEW option: Specifying load options You can specify a wide range of load options. These options tell Sybase IQ how to interpret and process the input file, and what to do when errors occur. You can specify load options in any order. Syntax for load-options is as follows: The syntax for the parameters is as follows: Each of these options is described briefly below. For details of all options of the LOAD TABLE statement, see the Sybase IQ Reference Manual . BLOCK FACTOR option Specifies blocking factor, or number of records per block, used when a source was created. This option is not valid for insertions from variable length input fields use the BLOCK SIZE option instead. However, it does affect all file inserts (including from disk) with fixed length input fields, and it can affect performance dramatically. The default setting for BLOCK FACTOR is 10,000. Higher block factors generally improve the speed of IO operations. However, consider the following when setting this option: If your source is a disk file, memory considerations will determine the best setting for your system. If your source is a tape, either use the same blocking factor that was used when creating the tape (for best performance) or a blocking factor that is evenly divisible into it. Sybase IQ rejects the insert operation if you specify a BLOCK FACTOR of zero. You cannot specify BLOCK FACTOR along with BLOCK SIZE or with any variable-width input fields. If you are loading very wide varchar data, reduce the BLOCK FACTOR to 10. ESCAPE CHARACTER option Specifies an alternative escape character. The default escape character for characters stored as hexadecimal codes and symbols is a backslash (), so that x0A is the linefeed character, for example. This can be changed using the ESCAPE CHARACTER clause. For example, to use the exclamation mark as the escape character, you would enter: Only one single-byte character can be used as an escape character. Because you must specify ESCAPES OFF in this version of Sybase IQ, the ESCAPE CHARACTER option has no effect. It is provided for compatibility with Adaptive Server Anywhere. WITH CHECKPOINT ON clause If this option is set to ON . a checkpoint is issued when the LOAD TABLE statement completes and is logged. In the event recovery is required, it is guaranteed even if the data file is then removed from the system. If WITH CHECKPOINT ON is not specified, the file used for loading must be retained in case recovery is required. BLOCK SIZE option Specifies the default size in bytes in which input should be read. This option only affects variable-length input data read from files it is not valid for fixed-length input fields. It is similar to BLOCK FACTOR . but there are no restrictions on the relationship of record size to block size. You cannot specify this option along with the BLOCK FACTOR option. The default setting for BLOCK SIZE is 500,000, which is high enough for input from disk files. For tape files, you should specify the same block size that was used when creating the tape. You cannot specify BLOCK SIZE along with BLOCK FACTOR or with any fixed width input fields. The following UNIX example specifies a BLOCK SIZE of 200,000 bytes: BYTE ORDER option Specifies the byte ordering during reads. This option applies to all binary input fields, including those defined as PREFIX 2 or PREFIX 4. If none are defined, this option is ignored. Sybase IQ always reads prefix binary data in the format native to the machine it is running on (default is NATIVE ). You can also specify: HIGH when multibyte quantities have the high order byte first (for big endian platforms like Sun, IBM AIX, and HP). LOW when multibyte quantities have the low order byte first (for little endian platforms like Windows). Here is a Windows example: LIMIT option Specifies the maximum number of rows to insert into the table. The default is 0 for no limit. The maximum is 2GB-1. LIMIT works together with the SKIP option. SKIP indicates where to begin reading from the input file, and LIMIT specifies how many of those rows to insert. SKIP takes precedence over LIMIT . If you specify multiple input files, these options only affect the first file . The following table shows how these options work together: Table 7-1: SKIP and LIMIT insert options If the SKIP value is Reads 10 rows and inserts 5 rows. If the input file has only 8 rows, then zero rows are inserted. In the following Windows example, no rows are skipped and up to 1,000,000 rows are inserted. NOTIFY option Specifies that you be notified with a message each time the specified number of rows is inserted successfully into the table. The default is every 100,000 rows. Very frequent notifications can slow down your insert operation. To turn off NOTIFY entirely, set NOTIFY 0. See Interpreting notification messages for an explanation of messages. ON FILE ERROR option Specifies the action Sybase IQ takes when an input file cannot be opened, either because it does not exist or because you have incorrect permissions to read the file. For all other reasons or errors, it aborts the entire insertion. You can specify one of the following: ROLLBACK aborts the entire transaction (the default). FINISH finishes the insertions already completed and ends the load operation. CONTINUE returns an error but only skips the file to continue the load operation. You cannot use this option with partial-width inserts. PREVIEW option Displays the layout of input into the destination table including starting position, name, and data type of each column. Sybase IQ displays this information at the start of the load process. If you are writing to a log file, this information is also included in the log. This option is especially useful with partial-width inserts. It can help you diagnose failed or skewed insertions due to incompatible data types, or destination column alignment that does not match source columns. Look at the expected column data type and starting position information to determine if you need to use an insert conversion option on a column andor where and how much filler to use. PREVIEW ON helps you determine if a load is correct. It does not stop the load from occurring. ROW DELIMITED BY option Specifies a string up to 4 bytes in length that indicates the end of an input record. You can use this option only if all fields within the row are any of the following: Delimited with column terminators Data defined by the DATE or DATETIME column-spec options ASCII fixed length fields The row delimiter can be any string of from 1 to 4 8-bit codes, including any combination of printable characters, andor any 8bit hexadecimal code that represents a non-printing character. For example, you specify x09 to represent a tab as the terminator. For a null terminator (no visible terminator as in C strings), you specify x00. To use the newline character as a row delimiter, you can specify either the special combination n or its ASCII value x0a. You cannot use this option if any input fields contain binary data. With this option, a row terminator causes any missing fields to be set to NULL. All rows must have the same row delimiters, and it must be distinct from all column delimiters. The row and field delimiter strings cannot be an initial subset of each other. For example, you cannot specify as a field delimiter and as the row delimiter, but you could specify as the field delimiter with that row delimiter. If a row is missing its delimiters, Sybase IQ returns an error and rolls back the entire load transaction. The only exception is the final record of a file where it rolls back that row and returns a warning message. On Windows, a row delimiter is usually indicated by the newline character followed by the carriage return character. You may need to specify this as the delimiter-string for either this option or FILLER. The following Windows example sets the column delimiter for the lorderkey column to tab, and the row delimiter to newline (x0a) followed by carriage return (x0d): SKIP option Lets you define a number of rows to skip at the beginning of the input file(s) for this load. The default is 0. This option works in conjunction with the LIMIT option, and takes precedence over it. In this UNIX example, Sybase IQ reads 9,000 rows from the input file, skips the first 5,000, and loads the next 4,000. If there are only 8,000 rows in the input file, then only 3,000 rows are loaded. START ROW ID option Specifies the id number of a row in the table where insertions should begin. This option is used for partial-width insertions . which insert into a subset of the columns in the table. If you are inserting data into an existing row, you must define the format of each input column with a column-spec . and use START ROW ID to identify the row where you want to insert it. The default is 0, which causes data to be inserted in a new row wherever there is space in the table. Be sure to read Partial-width insertions before using this option and performing partial-width inserts. UNLOAD FORMAT option Specifies that the data in the input file is in the format produced by the UNLOAD command in Sybase IQ 11.5.1, specifically for upgrading to Sybase IQ 12.x. This format places certain restrictions on other load options you specify: The format in the column specifications must be BINARY . the default. Specifying ASCII . PREFIX . FILLER . or string-delimiter causes an error. You must not use the load options DELIMITED BY and ROW DELIMITED BY . To allow NULLs in the data you must specify BINARY WITH NULL BYTE in the column specification. You cannot include NULL in the column-spec in any other way. For the sake of consistency with the data being loaded, you can specify BINARY WITH NULL BYTE even when loading into a table column that does not allow NULLs (as specified in CREATE TABLE or ALTER TABLE ). However, if you try to load any data into a column that does not allow NULLs, you receive an error. See the Sybase IQ Installation and Configuration Guide for more information on upgrading. ON PARTIAL INPUT ROW option Specifies the action to take when a partial input row is encountered during a load. You can specify one of the following: CONTINUE issues a warning and continues the load operation. This is the default. ROLLBACK aborts the entire load operation and reports the error IGNORE CONSTRAINT option Specifies whether to ignore UNIQUE, NULL, CHECK, DATA VALUE, andor FOREIGN KEY integrity constraint violations that occur during a load and the maximum number of violations to ignore before initiating a rollback. Specifying each constrainttype has the following result: UNIQUE limit If limit specifies zero, then the number of UNIQUE constraint violations to ignore is infinite. If limit is non-zero, then the limit 1 occurrence of a UNIQUE constraint violation causes the load to rollback. NULL limit If limit specifies zero, then the number of NULL constraint violations to ignore is infinite. If limit is non-zero, then the limit 1 occurrence of a NULL constraint violation causes the load to rollback. FOREIGN KEY limit If limit specifies zero, then the number of FOREIGN KEY constraint violations to ignore is infinite. If limit is non-zero, then the limit 1 occurrence of a FOREIGN KEY constraint violation causes the load to rollback. DATA VALUE limit If the database option CONVERSIONERROR ON, then an error is reported and the statement rolls back. If limit specifies zero, then the number of DATA VALUE constraint violations (data type conversion errors) to ignore is infinite. If limit is non-zero, then the limit 1 occurrence of a DATA VALUE constraint violation causes the load to rollback. ALL limit If the database option CONVERSIONERROR ON, then an error is reported and the statement rolls back. If limit specifies zero, then the cumulative total of all integrity constraint violations to ignore is infinite. If limit is non-zero, then load rolls back when the cumulative total of all ignored UNIQUE, NULL, DATA VALUE, and FOREIGN KEY integrity constraint violations exceeds the value of limit . For example, you specify the following IGNORE CONSTRAINT option: The total number of integrity constraint violations cannot exceed 200, while the total number of NULL and UNIQUE constraint violations cannot exceed 50 and 100, respectively. Whenever any of these limits is exceeded, the LOAD TABLE statement rolls back. A single row can have more than one integrity constraint violation. Every occurrence of an integrity constraint violation counts towards the limit of that type of violation. Sybase strongly recommends setting the IGNORE CONSTRAINT option limit to a non-zero value, if you are logging the ignored integrity constraint violations. Logging an excessive number of violations affects the performance of the load. CHECK limit If limit specifies zero, then the number of check constraint violations to ignore is infinite. If limit is non-zero, then the limit 1 occurrence of a CHECK constraint violation causes the load to roll back. A single row can have more than one integrity constraint violation. Every occurrence of an integrity constraint violation counts towards the limit of that type of violation. Sybase strongly recommends setting the IGNORE CONSTRAINT option limit to a non-zero value, if you are logging the ignored integrity constraint violations. Logging an excessive number of violations affects the performance of the load. If UNIQUE, NULL, CHECK, or FOREIGN KEY is not specified in the IGNORE CONSTRAINT clause, then the load rolls back on the first occurrence of each of these types of integrity constraint violation. If DATA VALUE is not specified in the IGNORE CONSTRAINT clause, then the load rolls back on the first occurrence of this type of integrity constraint violation, unless the database option CONVERSIONERROR OFF. If CONVERSIONERROR OFF, then a warning is reported for any DATA VALUE constraint violation and the load continues. When the load completes, an informational message regarding integrity constraint violations is logged in the. iqmsg file. This message contains the number of integrity constraint violations that occurred during the load and the number of rows that were skipped. MESSAGE LOG option Specifies the names of files in which to log information about integrity constraint violations and the types of violations to log. Timestamps indicating the start and completion of the load are logged in both the MESSAGE LOG and the ROW LOG files. Both MESSAGE LOG and ROW LOG must be specified, or no information about integrity violations is logged. If the ONLY LOG clause is not specified, then no information on integrity constraint violations is logged. Only the timestamps indicating the start and completion of the load are logged. Information is logged on all integrity constraint type violations specified in the ONLY LOG clause. If constraint violations are being logged, then every occurrence of an integrity constraint violation generates exactly one row of information in the MESSAGE LOG file. The number of rows (errors reported) in the MESSAGE LOG file can exceed the IGNORE CONSTRAINT option limit, because the load is performed by multiple threads running in parallel. More than one thread may report that the number of constraint violations has exceeded the specified limit. If constraint violations are being logged, then exactly one row of information is logged in the ROW LOG file for a given row, regardless of the number of integrity constraint violations that occur on that row. Note that the number of distinct errors in the MESSAGE LOG file may not exactly match the number of rows in the ROW LOG file. The difference in the number of rows is due to the parallel processing of the load described above for the MESSAGE LOG . The MESSAGE LOG and ROW LOG files cannot be raw partitions. If the MESSAGE LOG or ROW LOG file already exists, then new information is appended to the file. Specifying an invalid filename for the MESSAGE LOG or ROW LOG file generates an error. Specifying the same filename for the MESSAGE LOG and ROW LOG files generates an error. Various combinations of the IGNORE CONSTRAINT and MESSAGE LOG options result in different logging actions, as indicated in the following table: Nothing is logged. The first integrity constraint violation causes a rollback. Sybase strongly recommends setting the IGNORE CONSTRAINT option limit to a non-zero value, if you are logging the ignored integrity constraint violations. If a single row has more than one integrity constraint violation, a row for each violation is written to the MESSAGE LOG file. Logging an excessive number of violations affects the performance of the load. LOG DELIMITED BY option Specifies the separator between data values in the ROW LOG file. The default separator is a comma. For more details on the contents and format of the MESSAGE LOG and ROW LOG files, see Logging integrity constraint violations . LOAD TABLE adds rows The LOAD TABLE statement appends the contents of the file to the existing rows of the table it does not replace the existing rows in the table, unless you specify the START ROW ID load option. See Partial-width insertions for examples of how you use this option to insert data into existing rows. If you want to empty out an existing table and reload it, you can use the TRUNCATE TABLE statement to remove all the rows from a table. Simple LOAD TABLE example The following statement loads the data from the file dept. txt into all columns of the department table. This example assumes that no explicit data conversion is needed, and that the width of input columns matches the width of columns in the department table. Copyright 2006. Sybase Inc. All rights reserved.

No comments:

Post a Comment