Help Center > > User Guide> GaussDB(for MySQL) DB Instance Management (Development Tool)> Database Management> Table Management> Creating a Table

Creating a Table

Updated at: Jun 09, 2021 GMT+08:00

Scenarios

A GaussDB(for MySQL) database table consists of basic information, fields or columns, virtual columns, indexes, and foreign keys, among which virtual columns, indexes, and foreign keys are optional. Configure these items as required.

Procedure

  1. On the top menu bar, choose Database Management. On the displayed Objects tab, choose Tables and click Create Table.

    Figure 1 Create Table

  2. On the displayed page, specify the table details on the Basic Information page (Table Name is mandatory). Click Next.

    Figure 2 Basic Information

  3. On the Column page, click Add and set Column Name, Type, Length, Nullable, Primary Key, and Extended Information as needed.

    • If you do not need to add virtual columns, indexes, or foreign keys, click Create at the bottom of the page. In the displayed SQL Preview dialog box, click Execute.
      Figure 3 Configuring fields
    • If you need to add virtual columns, indexes, and foreign keys, click Next. Then, set the column name, type, length, nullable, primary key, expression, storage type, comment, and extended information. After the settings are complete, click Create.
    Figure 4 (Optional) Adding virtual columns
    Figure 5 (Optional) Adding indexes
    Figure 6 (Optional) Adding foreign keys

    When you create a foreign key, the type of columns in the referenced table must be the same as that of included columns, and must be the primary key or have a unique index.

  4. In the SQL Preview dialog box, click Execute to create a table.
  • The length of a column name is limited. Enter no more than 64 characters.
  • In the Type column, you can select only the parameters from the drop-down list box.
  • In the Length column, you can change the length for some types of columns.
  • If Primary Key is selected, Nullable will be grayed out.
  • Auto Increment can be set for one column only. When it is selected, Primary Key must be selected, and a default value cannot be set.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel