Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 (中文) » MobiLink - 入门 » MobiLink 教程 » 教程:使用 ScriptVersion 扩展选项更改模式

 

第 4 课:对统一数据库执行模式更改

在本课中,您将在 customer 表中添加新列来存储客户的手机号码。

前提条件

本课假定您拥有在本教程(教程:使用 ScriptVersion 扩展选项更改模式)开头的“特权”部分中列出的角色和特权。

本课假定您已完成前面的所有课程。 请参见第 1 课:创建并配置统一数据库

 任务
  1. 使用连接到统一数据库的 Interactive SQL 实例执行以下 SQL 语句,以便在 customer 表中插入行。

    ALTER TABLE customer ADD cell_phone VARCHAR(12) DEFAULT NULL;
  2. 创建一个名为 my_ver2 的新版脚本,用于处理新模式远程数据库的同步。旧模式的远程数据库将继续使用旧版脚本 my_ver1。

    对统一数据库执行以下 SQL 语句:



    CALL ml_add_column('my_ver2', 'customer', 'id', null );
    CALL ml_add_column('my_ver2', 'customer', 'name', null );
    CALL ml_add_column('my_ver2', 'customer', 'phone', null );
    CALL ml_add_column('my_ver2', 'customer', 'cell_phone', null );
    
    CALL ml_add_table_script( 'my_ver2', 'customer', 'upload_insert',
          'INSERT INTO customer ( id, name, phone, cell_phone ) ' 
          || 'VALUES ({ml r.id}, {ml r.name}, {ml r.phone}, {ml r.cell_phone})' );
    
    CALL ml_add_table_script( 'my_ver2', 'customer', 'download_cursor',
           'SELECT id, name, phone, cell_phone from customer' );
    
    CALL ml_add_table_script( 'my_ver2', 'customer', 'download_delete_cursor', '--{ml_ignore}' );
    
    COMMIT;

结果

已对统一数据库进行更改,并创建用于处理模式更改的新脚本版本。