在本课中,您将建立统一数据库进行同步。
前提条件
本课假定您拥有在本教程(教程:使用脚本版本子句更改模式)开头的“特权”部分中列出的角色和特权。
运行以下命令创建统一数据库,并启动以使其运行。
md c:\cons cd c:\cons dbinit -dba DBA,sql consol.db dbsrv16 consol.db |
运行以下命令定义统一数据库的 ODBC 数据源。
dbdsn -w dsn_consol -y -c "UID=DBA;PWD=sql;DBF=consol.db;SERVER=consol" |
要将数据库用作统一数据库,必须运行一个安装脚本,此脚本添加 MobiLink 使用的系统表、视图和存储过程。以下命令将 consol.db 设置为统一数据库。
dbisql -c "DSN=dsn_consol" %SQLANY16%\MobiLink\setup\syncsa.sql |
打开 Interactive SQL 并使用 dsn_consol ODBC 数据源连接到 consol.db。
dbisql -c "DSN=dsn_consol" |
执行以下 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 语句。
运行以下命令以启动 MobiLink 服务器。
start mlsrv16 -c "DSN=dsn_consol" -v+ -ot mlsrv.txt -zu+ |
![]() |
使用DocCommentXchange讨论此页。
|
版权 © 2013, SAP 股份公司或其关联公司. - SAP Sybase SQL Anywhere 16.0 |