UltraLite Database Management Tutorial
You can now work with UltraLite databases just like you can work with SQL Anywhere databases, making the design and development of UltraLite applications easier than ever. This tutorial points you to the places in Sybase Central where you can carry out common UltraLite tasks.
For more information about the UltraLite plug-in for Sybase Central, refer to the online documentation: SQL Anywhere 10 Help | SQL Anywhere UltraLite Help.
You can run this sample under Windows only.
Create an UltraLite database
- Start Sybase Central. From the Start menu, choose Programs | SQL Anywhere 10 | Sybase Central.
- In the tasks list, click Create a database. If you do not see a list of tasks on the left pane, click the Tasks button on the toolbar.
If the wizard Welcome page appears, click Next.
- Select Windows desktop and Symbian OS as the target platforms. UltraLite databases are portable subject to operating system limitations.
- Click Next. Save the database file as ul_custdb.udb in a temporary directory.
Click Finish to create the database. If necessary, click Close when the operation completes. Sybase Central connects to the UltraLite database.
Copy table definitions from a SQL Anywhere database
- Connect to the SQL Anywhere 10 CustDB sample database:
- Switch to the Folders view and right-click on SQL Anywhere 10.
- From the popup menu, select Connect.
- Select ODBC Data Source name and browse to SQL Anywhere 10 CustDB.
- Click OK. Sybase Central connects to the CustDB sample database. If you are asked to include the ml_server owned objects, click Yes.
- Open the Tables folder, showing the tables owned by ml_server in the right pane.
- While holding the Ctrl key, click the ULCustomer, ULOrder, and ULProduct tables.
- From the Edit menu, choose Copy.
- In the toolbar, click the Back button until you are at the UltraLite database.
- Open the Tables folder and from the Edit menu choose Paste.
Some warnings are displayed for columns where UltraLite does not support the full SQL Anywhere definition. Click Continue when these warnings appear and click OK to create the tables.
- We need to remove the column "last_modified" from the ULCustomer and ULOrder tables. In the left pane, expand Tables and select the ULCustomer table. Now on the right pane select the last_modified column.
- Right-click the selection and choose Delete from the popup menu.
- Now switch to the ULOrder table by clicking its name on the left pane. If you see a message asking to save the changes, click Yes.
- You will see the columns of the ULOrder table on the right pane. Select the last_modified column, right-click the selection and choose Delete from the popup menu.
- Click the Save Table button on the toolbar to accept the changes.
Create foreign keys
- The UltraLite database does not contain foreign key definitions. To see this, open the UltraLite ul_custdb database and click the ER Diagram tab to show the tables in the database. There are no foreign key lines joining the tables.
- Create a foreign key from the ULOrder table (using cust_id as the foreign key column) to the ULCustomer table (where cust_id is the primary key):
- Open the UltraLite ul_custdb database, then open the Tables folder, and then open the ULOrder table.
- Click the Foreign Keys tab, and then choose File | New | Foreign Key. The Foreign Key wizard appears.
- Click the ULCustomer table, and then click Next.
- Accept the default reference columns, and click Finish to create the foreign key.
Notice the change in the ER diagram; a link is present between the ULOrder and the ULCustomer tables, indicating that a foreign key has been added.
Synchronize the database
- Open a Command Prompt and start the MobiLink synchronization server by issuing the following command:
mlsrv10 -v+ -zu+ -c "dsn=SQL Anywhere 10 CustDB"
- From Sybase Central, click the Contents tab and then right-click on the UltraLite ul_custdb.udb database. Choose Synchronize Database from the popup menu.
- The Synchronization wizard appears. Click Next on the welcome page.
- On the Database to synchronize page, choose the database you are currently connected to. Click Next.
- On the Synchronization parameters page, enter the following values:
- Version: custdb 10.0
- User name: 50
- Password: 50
- Remove the file ul_custdb.udb from the temporary directory you specified in step 2 of the walkthrough.