Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » UltraLite - Database Management and Reference » Working with UltraLite Databases » Working with UltraLite tables and columns

Using allsync and nosync suffixes Next Page

Adding a column to an UltraLite table

You can add a new column easily if the table is empty. However, if the table already holds data, you can only add a column if the column definition includes a default value or allows NULL values.

You can use either Sybase Central or directly execute a SQL statement (for exmaple, Interactive SQL) to perform this task.

Sybase Central

In Sybase Central, you can perform these tasks while working with a selected table.

To add a new column to an UltraLite table (Sybase Central)
  1. Connect to the UltraLite database.

  2. Open the Tables folder.

  3. In the Columns tab, right-click the background and select New > Column.

  4. Set all new attributes for the column. You must declare a name, a data type, constraints, whether or not the table allows null values, and so on.

  5. Choose File > Save Table when finished.

Interactive SQL

In Interactive SQL, you can only declare columns while creating or altering a table.

To add columns to a new UltraLite table (Interactive SQL)
  1. Connect to the UltraLite database.

  2. Execute a CREATE TABLE statement or ALTER TABLE, ensuring that you define columns by declaring the name, and other attributes accordingly.

    Examples    The following example creates a table for a library database to hold information on borrowed books. The default value for date_borrowed indicates that the book is borrowed on the day the entry is made. The date_returned column is NULL until the book is returned.

    CREATE TABLE borrowed_book (
       loaner_name CHAR(100)      PRIMARY KEY,
       date_returned       DATE,
       book                CHAR(20)

    The following example modifies the customer table to now include a column for addresses that can hold up to 50 characters:

    ALTER TABLE customer
    ADD address CHAR(50)
  3. See also