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

SQL Anywhere 12.0.0 (中文) » MobiLink - 入门 » MobiLink 教程 » 教程:使用脚本版本子句更改模式

 

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

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

 ♦  在统一数据库上执行模式更改
  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;