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 (中文) » SQL Remote » 教程:创建 SQL Remote 系统

 

第 8 课:将数据从远程数据库发送到统一数据库

使用 Interactive SQL 将数据从远程数据库 (field) 复制到统一数据库 (hq)。

前提条件

您必须具有 SYS_REPLICATION_ADMIN_ROLE 系统角色。

上下文和注释

多个。

 任务
  1. 如果目前尚未连接到远程数据库 (field),则运行以下命令:

    dbisql -c "UID=DBA;PWD=sql;SERVER=server_hq;DBF=c:\tutorial\field.db"
  2. 执行以下语句,在远程数据库 (field) 中插入一行:

    INSERT INTO Customers ( cust_key, name, rep_key )
    VALUES ( 'cust5', 'North Land Trading', 'rep1' );
    COMMIT;
  3. c:\tutorial 目录针对远程数据库 (field) 运行 dbremote 实用程序:

    dbremote -c "UID=DBA;PWD=sql;SERVER=server_field;DBF=c:\tutorial\field.db"

    c:\tutorial\hq 目录中,文件 field.1 出现。

  4. 如果目前尚未连接到统一数据库 (hq),则运行以下命令:

    dbisql -c "UID=DBA;PWD=sql;SERVER=server_hq;DBF=c:\tutorial\hq.db
    
  5. 在统一数据库 (hq) 上,从 c:\tutorial 目录运行消息代理:

    dbremote -c "UID=DBA;PWD=sql;SERVER=server_hq;DBF=c:\tutorial\hq.db"
  6. 当消息代理窗口显示 [已执行完毕] 时,单击 [关闭]。

  7. 浏览至 c:\tutorial\field

    hq.1 文件已被名为 hq.2 的文件取代。hq.2 文件中包含接收确认信息。

  8. 执行以下语句,查看统一数据库 (hq) 中 Customers 表的数据:

    SELECT * FROM Customers;

    此查询会返回以下结果:

    cust_key name rep_key
    cust1 Ocean Sports rep1
    cust2 Sports Plus rep2
    cust3 Land Sports rep1
    cust4 Air Plus rep2
    cust5 North Landing Trading rep1

结果

数据已从远程数据库复制到统一数据库。

下一个

无。