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

SQL Anywhere 12.0.1 » MobiLink - 入门 » MobiLink 教程 » 教程:使用脚本版本子句更改模式

 

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

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

在本课中,将在统一数据库上执行模式更改。

 ♦ 在统一数据库上执行模式更改
  1. 在 customer 表中添加新列来存储客户的手机号码。首先,在连接到统一数据库的 Interactive SQL 实例中执行以下 SQL 语句,以便在统一数据库中添加新列。

    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;
  3. 前进至第 6 课:对远程数据库执行模式更改