Creating a table and adding columns with Sybase Central

In this tutorial we create a table in the sample database. The new table will describe different offices for the fictitious company.

StepsCreating a table

  1. Expand the server and database containers, then click the Tables folder to open it.

  2. Click the New Table toolbar button Shown is the new table toolbar button or choose File > New > Table (Alt+F, N, T). This starts the Table Creation wizard.

  3. Type the new table name in the dialog box. In this case, use the name office.

  4. From the dropdown menu, select the owner for the table. By default, the asiqdemo database has only one user, DBA. Click Next.

  5. For this tutorial, click or arrow to the dbspace IQ_SYSTEM_MAIN to store the new table there. (On a query server in a multiplex database, this would not be possible.) Click Next.

  6. Click in the Comment field and type:

    Company offices
    

    in the Comment text box. Comments are optional.

  7. Click Finish.

    The office table appears in the left pane, and the column tab in the right pane. Follow the steps below to add columns to the new table.

StepsCreating columns for a table

  1. The Create Table wizard adds each new table to the hierarchy and displays a columns tab for you to complete.

  2. To use the new column as a primary key, leave the PKey box checked.

    NoteIf a check box appears under Allow Nulls column, or if duplicate values are stored in the office_id column, the column cannot be changed to a primary key.

  3. In the Name box in the first row of columns, type the name of the first column in the table. For this tutorial, use the name office_id.

  4. Select the Data Type integer. Leave the ID, Size, Scale, Nulls, Unique and Comments columns blank for the office_id column.

  5. Tab to a new row or use Alt+F, N for a new column. Add rows for the following columns, following steps 3 and 4 and tabbing to the Size/Precision column to add the sizes below. Leave the Allow Nulls column checked for each:

    • region char(7)

    • street char(40)

    • city char(20)

    • state char(2)

    • zip char(9)

  6. Finish creating the table by clicking the Save Table toolbar button Shown is the Save Table toolbar button. The office table is now visible on the tables tab in the right pane of Sybase Central.

The table is now present in the database, although it has no data. To enter data, use the Interactive SQL utility or the Data tab.

The following section describes how to edit an existing table.