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 - Getting Started » MobiLink tutorials » Tutorial: Using MobiLink with a SQL Anywhere consolidated database


Lesson 2: Preparing the consolidated database

This lesson assumes you have completed all preceding lessons. See Lesson 1: Designing the schemas.

This lesson guides you through the following steps to set up your SQL Anywhere consolidated database:

  1. Connect to the consolidated database.

  2. Create the CustomerProducts tables and alter the Customers table to include regional information.

 Prepare the consolidated database
  1. Click Start » Programs » SQL Anywhere 12 » Administration Tools » Sybase Central.

  2. Click Connections » Connect With SQL Anywhere 12.

  3. Perform the following tasks in the Connect window:

    1. In the Action dropdown list, choose Connect With An ODBC Data Source.

    2. In the ODBC Data Source Name field, type SQL Anywhere 12 Demo.

    3. Click Connect.

  4. Connect to your consolidated database in Interactive SQL.

    At a command prompt, run the following command:

    dbisql -c "DSN=SQL Anywhere 12 Demo"
  5. In Interactive SQL, execute the following statements to create and insert data in the CustomerProducts table:

    CREATE TABLE CustomerProducts
        (ID int default AUTOINCREMENT PRIMARY KEY,
        SalesOrderID int NOT NULL, 
        CustomerID int NOT NULL, 
        ProductID int);
    INSERT INTO CustomerProducts (SalesOrderID,CustomerID,ProductID)
        SELECT SalesOrders.ID, SalesOrders.CustomerID, SalesOrderItems.ProductID
        FROM SalesOrders, SalesOrderItems
        WHERE SalesOrders.ID = SalesOrderItems.ID;
  6. In Interactive SQL, execute the following statements to add regional information for each customer to the Customers table:

    ALTER TABLE Customers
        ADD Region VARCHAR(255);
    UPDATE Customers
        SET Region = (SELECT TOP 1 SalesOrders.Region
        FROM SalesOrders 
        WHERE Customers.ID = SalesOrders.CustomerID
        ORDER BY Region);
 Adding unique primary keys
 See also