本示例演示如何更改表定义。在本方案中,对 Invoice 表进行修改,使其中一列的长度从 50 个字符扩展到 100 个字符。
转到以下目录:samples-dir\UltraLiteJ。
有关 samples-dir 缺省位置的信息,请参见示例目录。
运行 CreateSales 示例:
rundemo CreateSales |
请参见示例:创建销售数据库。
运行以下命令(此命令区分大小写):
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 ); } } } |
![]() |
使用DocCommentXchange 讨论此页。
|
版权 © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |