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 教程 » 教程:使用脚本版本子句更改模式

 

第 1 课:创建并配置统一数据库

在本课中,您将建立统一数据库进行同步。

前提条件

本课假定您拥有在本教程(教程:使用脚本版本子句更改模式)开头的“特权”部分中列出的角色和特权。

 任务
  1. 运行以下命令创建统一数据库,并启动以使其运行。

    md c:\cons
    cd c:\cons
    dbinit -dba DBA,sql consol.db
    dbsrv16 consol.db
  2. 运行以下命令定义统一数据库的 ODBC 数据源。

    dbdsn -w dsn_consol -y -c "UID=DBA;PWD=sql;DBF=consol.db;SERVER=consol"
  3. 要将数据库用作统一数据库,必须运行一个安装脚本,此脚本添加 MobiLink 使用的系统表、视图和存储过程。以下命令将 consol.db 设置为统一数据库。

    dbisql -c "DSN=dsn_consol" %SQLANY16%\MobiLink\setup\syncsa.sql
  4. 打开 Interactive SQL 并使用 dsn_consol ODBC 数据源连接到 consol.db

    dbisql -c "DSN=dsn_consol"
  5. 执行以下 SQL 语句。这些语句在统一数据库上创建 customer 表,然后创建所需的同步脚本。



    CREATE TABLE customer (
       id      unsigned integer primary key,
       name    varchar( 256),
       phone   varchar( 12 )
    );
    
    CALL ml_add_column('my_ver1', 'customer', 'id', null );
    CALL ml_add_column('my_ver1', 'customer', 'name', null );
    CALL ml_add_column('my_ver1', 'customer', 'phone', null );
    
    CALL ml_add_table_script( 'my_ver1', 'customer', 'upload_insert',
          'INSERT INTO customer ( id, name, phone ) ' 
          || 'VALUES ({ml r.id}, {ml r.name}, {ml r.phone} )' );
    
    CALL ml_add_table_script( 'my_ver1', 'customer', 'download_cursor',
           'SELECT id, name, phone from customer' );
    
    CALL ml_add_table_script( 'my_ver1', 'customer', 'download_delete_cursor', '--{ml_ignore}' );
    COMMIT;
    

    执行此 SQL 后,使 Interactive SQL 处于运行状态,并连接到数据库,因为随着课程的深入您将对此数据库执行更多的 SQL 语句。

  6. 运行以下命令以启动 MobiLink 服务器。

    start mlsrv16 -c "DSN=dsn_consol" -v+ -ot mlsrv.txt -zu+

结果

统一数据库创建完成并设置为使用 MobiLink。