Lesson 2: Creating and populating a table in the MobiLink consolidated database

This lesson assumes you have completed all preceding lessons. See Lesson 1: Setting up a MobiLink consolidated database.

In this lesson, you create the Product table and insert sample data in the MobiLink consolidated database. The Product table contains the following columns:

Column Description

name

The name of the product.

quantity

The number of items sold.

last_modified

The last modification date of a row. You use this column for timestamp-based downloads, a common technique used to filter rows for efficient synchronization.

 Create and populate the Product table
  1. Connect to the consolidated database in Interactive SQL.

    You can start Interactive SQL from Sybase Central or at a command prompt.

    • From Sybase Central, right-click the MLconsolidated - DBA database and click Open Interactive SQL.

    • At a command prompt, run the following command:

      dbisql -c "DSN=mlintro_consdb"
  2. Execute the following SQL statement in Interactive SQL to create the Product table:

    CREATE TABLE Product (
        name            VARCHAR(128) NOT NULL PRIMARY KEY,
        quantity        INTEGER,
        last_modified   TIMESTAMP DEFAULT TIMESTAMP
    );

    Interactive SQL creates the Product table in your consolidated database.

    After creating the tables, you populate the Product table with sample data.

  3. Execute the following SQL statements in Interactive SQL to populate the Product table with sample data:



    INSERT INTO Product(name, quantity)
        VALUES ( 'Screwmaster Drill', 10);
    
    INSERT INTO Product(name, quantity)
        VALUES ( 'Drywall Screws 10lb', 30);
    
    INSERT INTO Product(name, quantity)
        VALUES ( 'Putty Knife x25', 12);
    
    COMMIT;
  4. Verify that the Product table contains the data inserted from the previous step.

    Execute the following SQL statement to verify the contents:

    SELECT * FROM Product

    The contents of the Product table should appear in Interactive SQL.

  5. Proceed to Lesson 3: Creating a MobiLink project and synchronization model.

 See also