Create tables to store the information in your database.
Prérequis
This lesson assumes that you have completed all preceding lessons. See Lesson 1: Creating a database file.
This lesson assumes that you have the roles and privileges listed in the Privileges section at the start of this tutorial: Tutorial: Creating a SQL Anywhere database.
Start the Create Table Wizard. In the left pane of Sybase Central, right-click Tables and click New » Table.
In the What do you want to name the new table field, type Products.
Click Finish.
The database server creates the table using defaults, and then displays the Columns tab in the right pane. The Name field for the new column is selected and you are prompted to specify a name for the new column.
Type ProductID as the name for the new column.
Since this is the first column in the table, PKey is selected, indicating that the column is the primary key for the table.
In the Data Type list, click Integer.
Click the ... button.
Click the Value tab and click Default value » System-defined » autoincrement.
An AUTOINCREMENT value increments for each row added to the table. This value ensures that values in the column are unique—a requirement for primary keys.
Click OK.
Click File » New » Column.
In the Name field, type ProductName.
In the Data Type list, click Char.
In the Size list, click 15.
Repeat the previous steps to add the following tables to your database:
Customers table Add a table named Customers with the following columns:
CustomerID The identification number of each customer. Ensure that PKey is selected, set the Data Type to Integer, and set the Default value to autoincrement.
CompanyName The name of each company. Set the DataType to Char with a maximum length of 35 characters.
SalesOrders table Add a table named SalesOrders with the following columns:
SalesOrderID The identification number of each sales order. Ensure that PKey is selected, set the Data Type to Integer, and set the Default value to autoincrement.
OrderDate The date on which the order was placed. Set the DataType to Date.
CustomerID The identification number of the customer who placed the sales order. Set the DataType to Integer.
SalesOrderItems table Add a table named SalesOrderItems with the following columns:
SalesOrderItemsID The identification number of the sales order that the item belongs to. Ensure that PKey is selected and set the Data Type to Integer.
LineID The identification number of each sales order. Ensure that PKey is selected and set the Data Type to Integer.
Since PKey is set for both SalesOrderItemsID and LineID, the primary key for the table comprises the concatenated values of these two columns.
ProductID The identification number of the product being ordered. Set the DataType to Integer.
Click File » Save.
![]() |
Discuter à propos de cette page dans DocCommentXchange.
|
Copyright © 2013, SAP AG ou société affiliée SAP - SAP Sybase SQL Anywhere 16.0 |