Dieses Beispiel zeigt, wie Sie Tabellendefinitionen ändern. In diesem Szenario wird eine Invoice-Tabelle geändert, um eine Spaltenlänge von 50 auf 100 Zeichen zu erweitern.
Wechseln Sie zum folgenden Verzeichnis: Beispielverzeichnis\UltraLiteJ.
Hinweise zum Speicherort von Beispielverzeichnis finden Sie unter Beispielverzeichnis.
Führen Sie das CreateSales-Beispiel aus:
rundemo CreateSales |
Führen Sie den folgenden Befehl aus (mit Berücksichtigung der Groß- und Kleinschreibung):
rundemo Reorg |
// ***************************************************** // Copyright (c) 2006-2010 iAnywhere Solutions, Inc. // Portions copyright (c) 2006-2010 Sybase, Inc. // All rights reserved. All unpublished rights reserved. // ***************************************************** // This sample code is provided AS IS, without warranty or liability // of any kind. // // You may use, reproduce, modify and distribute this sample code // without limitation, on the condition that you retain the foregoing // copyright notice and disclaimer as to the original iAnywhere code. // // ********************************************************************* package com.ianywhere.ultralitej.demo; import com.ianywhere.ultralitej12.*; /** Reorganize the Invoice table to have a name with an increased size * * <p>This shows a possible strategy which can be used to reorganize * tables, since UltraLiteJ has no table-altering API. * <p>The (contrived) example expands the name column to 100 characters. * */ public class Reorg { /** * mainline for program. * * @param args command-line arguments * */ public static void main ( String[] args ) { try { Configuration config = DatabaseManager.createConfigurationFile( "Sales.ulj" ); Connection conn = DatabaseManager.connect( config ); PreparedStatement ps = conn.prepareStatement( "ALTER TABLE Invoice ALTER name VARCHAR(100)" // was VARCHAR(50) ); ps.execute(); ps.close(); conn.release(); } catch( ULjException exc ) { Demo.displayException( exc ); } } } |
![]() |
Kommentieren Sie diese Seite in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |