Use the following procedure to create a table named Products.
In the right pane of Sybase Central, double-click Tables.
Right-click Tables and click New » Table.
In the What Do You Want To Name The New Table field, type Products.
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 a prompt waits for you 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.
When creating a table, you can create a primary key that is made up of more than one columns by creating the columns and placing a checkmark in each PKey column. See Primary keys.
In the Data Type list, click Integer.
Click the ellipsis (three dots) button.
Click the Value tab and click Default Value » System-Defined » Autoincrement.
An AUTOINCREMENT value increments for each row added to the table. This ensures that values in the column are unique—a requirement for primary keys. See Primary keys.
Click File » New » Column.
Complete the following fields:
Add the following tables to your database.
Customers table Add a table named Customers with the following columns:
CustomerID An identification number for each customer. Make sure 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 An identification number for each sales order. Set the DataType to Integer, and make sure PKey is selected. 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 of which the item is a part. Set the DataType to Integer, and make sure PKey is selected.
LineID An identification number for each sales order. Set the DataType to Integer, and make sure PKey is selected.
Since PKey is set for both SalesOrderItemsID and LineID, this means the primary key for the table comprises the concatenated values of these two columns.
ProductID The identification number for the product being ordered. Set the DataType to Integer.
Click File » Save.
Discuter à propos de cette page dans DocCommentXchange.
|Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1|